一、服务器配置说明
ip | hostname | 系统 |
192.168.0.133 | cass-0001 | Centos7.8 |
192.168.0.213 | cass-0002 | Centos7.8 |
192.168.0.161 | cass-0003 | Centos7.8 |
二、软件下载安装
安装java环境
三台机器都需要安装
sudo yum install java-1.8.0-openjdk-devel -y java -version
新建用户
新建Cassandra用户
useradd cassandra echo cassandra | passwd --stdin cassandra
切换用户
su cassandra
下载Cassandra
wget https://mirrors.tuna.tsinghua.edu.cn/apache/cassandra/3.11.11/apache-cassandra- 3.11.11-bin.tar.gz --no-check-certificate tar -zxvf apache-cassandra-3.11.11-bin.tar.gz mv apache-cassandra-3.11.11 cassandra
配置Cassandra
修改配置⽂件 /home/cassandra/apache-cassandra-3.11.11/conf/cassandra.yaml
cass-0001:对如下地方做出修改
cluster_name: 'EMQX' data_file_directories: - /home/cassandra/cassandra/data commitlog_directory: /home/cassandra/cassandra/data/commitlog saved_caches_directory: /home/cassandra/cassandra/data/saved_caches seed_provider: - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: - seeds: "192.168.0.133" # 因⼦ listen_address: 192.168.0.133 # 监听地址,不可以为127.0.0.1 start_rpc: true rpc_address: 192.168.0.133 # rpc监听地址,不可以为127.0.0.1 authenticator: PasswordAuthenticator authorizer: CassandraAuthorizer
各节点的 listen_address 和 rpc_address 需要按节点配置,且不能使⽤ localhost ,因⼦ seeds 配置 为第⼀个启动的节点。
cass-0002:其他配置跟cass-0001一致,需要做如下配置修改
seeds: "192.168.0.133" listen_address: 192.168.0.213 rpc_address: 192.168.0.213
cass-0003:其他配置和cass-0001一致,需做如下配置修改:
seeds: "192.168.0.133" listen_address: 192.168.0.161 rpc_address: 192.168.0.161 start_rpc: true
启动服务
三台节点分别执行
/home/cassandra/cassandra/bin/cassandra
验证服务
/home/cassandra/cassandra/bin/nodetool status
至此集群搭建验证完毕!