您好,登錄后才能下訂單哦!
wget http://apache.mirrors.hoobly.com/cassandra/3.11.5/apache-cassandra-3.11.5-bin.tar.gz
# 準備三臺節點
192.168.100.226
192.168.100.227
192.168.100.228
# ansible配置
# 因為是測試環境,這里就直接配置密碼,不去麻煩的配置免密驗證了。
[root@master ~]# cat /etc/ansible/hosts
[casd]
192.168.100.226 ansible_ssh_user='root' ansible_ssh_pass='test123'
192.168.100.227 ansible_ssh_user='root' ansible_ssh_pass='test123'
192.168.100.228 ansible_ssh_user='root' ansible_ssh_pass='test123'
# 創建用戶
ansible casd -m user -a "name=cassandra state=present"
# 修改密碼
ansible casd -m shell -a "echo cassandra | passwd --stdin cassandra"
# 將cassandra二進制包拷貝到部署節點上。
ansible casd -m copy -a "src=apache-cassandra-3.11.5.tar.gz dest=/home/cassandra/apache-cassandra-3.11.5.tar.gz"
# 解壓源碼包
ansible casd -m shell -a "cd /home/cassandra/; tar -zxvf apache-cassandra-3.11.5.tar.gz"
# 拷貝jdk至部署節點
ansible casd -m copy -a "src=java-1.8.0-amazon-corretto-devel-1.8.0_212.b04-2.x86_64.rpm dest=/root"
# 安裝jdk
ansible casd -m shell -a "yum install -y java-1.8.0-amazon-corretto-devel-1.8.0_212.b04-2.x86_64.rpm"
# 驗證jdk
``` bash
[root@localhost ~]# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment Corretto-8.212.04.2 (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM Corretto-8.212.04.2 (build 25.212-b04, mixed mode)
# 切換用戶
[root@localhost ~]# su - cassandra
Last login: Fri Dec 6 04:27:53 EST 2019 on pts/1
# 配置環境變量
[cassandra@localhost ~]$ vi .bash_profile
export CASSANDRA_HOME=/home/cassandra/apache-cassandra-3.11.5
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto
export PATH=$JAVA_HOME/bin:$CASSANDRA_HOME/bin:$PATH
# 加載環境變量
[cassandra@localhost ~]$ source .bash_profile
修改配置文件 /home/cassandra/apache-cassandra-3.11.5/conf/cassandra.yaml
cluster_name: 'test'
data_file_directories:
- /home/cassandra/apache-cassandra-3.11.5/data
commitlog_directory: /home/cassandra/apache-cassandra-3.11.5/data/commitlog
saved_caches_directory: /home/cassandra/apache-cassandra-3.11.5/data/saved_caches
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "192.168.100.226" # 因子
listen_address: 192.168.100.226 # 監聽地址,不可以為127.0.0.1
start_rpc: true
rpc_address: 192.168.100.226 # rpc監聽地址,不可以為127.0.0.1
各節點的 listen_address
和 rpc_address
需要按節點配置,且不能使用 localhost
,因子 seeds
配置為第一個啟動的節點。
First Node
--------------
seeds: "192.168.100.226"
listen_address: 192.168.100.226
rpc_address: 192.168.100.226
Second Node
---------------
seeds: "192.168.100.226"
listen_address: 192.168.100.227
rpc_address: 192.168.100.227
Third Node
---------------
seeds: "192.168.100.226"
listen_address: 192.168.100.228
rpc_address: 192.168.100.228
# 先啟動226, 使用-f選項啟動在前臺
/home/cassandra/apache-cassandra-3.11.5/bin/cassandra
# 再啟動其余的節點
/home/cassandra/apache-cassandra-3.11.5/bin/cassandra
/home/cassandra/apache-cassandra-3.11.5/bin/cassandra
使用 nodetool status
驗證服務
[cassandra@localhost ~]$/home/cassandra/apache-cassandra-3.11.5/bin/nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.100.226 302.76 KiB 256 69.2% 723cb923-d19c-4dea-8124-c4503dab4d75 rack1
UN 192.168.100.227 295.05 KiB 256 66.3% 5bbeeb09-9bf4-4e45-a7a1-168e4f87186f rack1
UN 192.168.100.228 239.96 KiB 256 64.5% 78677dd0-797e-45b0-a34a-23842927af35 rack1
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。