Deploy cassandra clusters
Deploy cassandra cluster 1, prepare environment 1.1, download binary source code package
Wget http://apache.mirrors.hoobly.com/cassandra/3.11.5/apache-cassandra-3.11.5-bin.tar.gz
1.2.Node preparation # prepare three nodes 192.168.100.226192.168.100.227192.168.100.228 # ansible configuration # since it is a test environment, you can configure the password directly here and do not bother to configure secret-free verification. [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'1.3, Create cassandra user # create user ansible casd-m user-a "name=cassandra state=present" # modify password ansible casd-m shell-a "echo cassandra | passwd-- stdin cassandra" # copy the cassandra binary package to the deployment node. Ansible casd-m copy-a "src=apache-cassandra-3.11.5.tar.gz dest=/home/cassandra/apache-cassandra-3.11.5.tar.gz" # decompress the source package ansible casd-m shell-a "cd / home/cassandra/ Tar-zxvf apache-cassandra-3.11.5.tar.gz "1.4, Java environment prepares # copy jdk to deployment node ansible casd-m copy-a "src=java-1.8.0-amazon-corretto-devel-1.8.0_212.b04-2.x86_64.rpm dest=/root" # install jdkansible casd-m shell-a "yum install-y java-1.8.0-amazon-corretto-devel-1.8.0_212.b04-2.x86_64.rpm" # verify jdk```bash [root@localhost ~] # java -versionopenjdk 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) 1.5, Configure user environment variable # switch user [root@localhost ~] # su-cassandra Last login: Fri Dec 6 04:27:53 EST 2019 on pts/1# configuration environment variable [cassandra@localhost ~] $vi .bash _ profileexport CASSANDRA_HOME=/home/cassandra/apache-cassandra-3.11.5export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-correttoexport PATH=$JAVA_HOME/bin:$CASSANDRA_HOME/bin:$PATH# load environment variable [cassandra@localhost ~] $source .bash _ profile II, Deploy cassandra2.1, profile
Modify configuration file / home/cassandra/apache-cassandra-3.11.5/conf/cassandra.yaml
Cluster_name: 'test'data_file_directories:-/ home/cassandra/apache-cassandra-3.11.5/datacommitlog_directory: / home/cassandra/apache-cassandra-3.11.5/data/commitlogsaved_caches_directory: / home/cassandra/apache-cassandra-3.11.5/data/saved_cachesseed_provider:-class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters:-seeds: "192.168.100 .226 "# Factor listen_address: 192.168.100.226 # listening address Cannot be 127.0.0.1start_rpc: truerpc_address: 192.168.100.226 # rpc listening address, cannot be 127.0.0.12.2, each node
The listen_address and rpc_address of each node need to be configured by node, and localhost cannot be used, and the factor seeds is configured as the first node to start.
First Node-seeds: "192.168.100.226" listen_address: 192.168.100.226rpc_address: 192.168.100.226Second Node-seeds: "192.168.100.226" listen_address: 192.168.100.227rpc_address: 192.168.100.227Third Node-seeds: "192. 168.100.226 "listen_address: 192.168.100.228rpc_address: 192.168.100.228 Start cassandra service 3. 1, start service # start 226 first Use the-f option to start the rest of the nodes / home/cassandra/apache-cassandra-3.11.5/bin/cassandra/home/cassandra/apache-cassandra-3.11.5/bin/cassandra3.2 and verification services at the foreground / home/cassandra/apache-cassandra-3.11.5/bin/cassandra#
Use the nodetool status authentication service
[cassandra@localhost ~] $/ home/cassandra/apache-cassandra-3.11.5/bin/nodetool statusDatacenter: datacenter1===Status=Up/Down | / State=Normal/Leaving/Joining/Moving-- Address Load Tokens Owns (effective) Host ID RackUN 192.168.100.226 302.76 KiB 256 69.2% 723cb923-d19c-4dea-8124-c4503dab4d75 rack1UN 192.168.100.227 295.05 KiB 256 66.3% 5bbeeb09-9bf4-4e45-a7a1-168e4f87186f rack1UN 192.168.100.228 239.96 KiB 256 64.5% 78677dd0-797e-45b0-a34a-23842927af35 rack1