CentOS7 cassandra安裝與測試
阿新 • • 發佈:2020-08-05
3節點分別安裝(192.168.6.117,192.168.6.118,192.168.6.119) #下載 http://mirrors.hust.edu.cn/apache/cassandra/3.11.7/apache-cassandra-3.11.7-bin.tar.gz tar -xvf apache-cassandra-3.11.7-bin.tar.gz -C /opt cd /opt/apache-cassandra-3.11.7/ sed -i 's$#MAX_HEAP_SIZE="4G"$MAX_HEAP_SIZE="2G"$g' /opt/apache-cassandra-3.11.7/conf/cassandra-env.sh sed-i 's$#HEAP_NEWSIZE="800M"$HEAP_NEWSIZE="400M"$g' /opt/apache-cassandra-3.11.7/conf/cassandra-env.sh sed -i 's$Test Cluster$cx cluster$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml sed -i 's$start_rpc: false$start_rpc: true$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml #節點分配:192.168.6.117,192.168.6.118分配為seeds,三節點配置完全一樣 sed-i 's$seeds: "127.0.0.1"$seeds: "192.168.6.117,192.168.6.118"$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml #下面兩步替換為當前節點ip sed -i 's$listen_address: localhost$listen_address: 192.168.6.117$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml sed -i 's$rpc_address: localhost$rpc_address: 192.168.6.117$g'/opt/apache-cassandra-3.11.7/conf/cassandra.yaml 啟動 #先啟動seeds節點(192.168.6.117,192.168.6.118)再啟動非seeds節點 /opt/apache-cassandra-3.11.7/bin/cassandra -R #檢視叢集狀態 /opt/apache-cassandra-3.11.7/bin/nodetool status 如果叢集中任意節點狀態不是UN,則檢視日誌: tail -f /opt/apache-cassandra-3.11.7/logs/system.log 測試 #連線到Cassandra /opt/apache-cassandra-3.11.7/bin/cqlsh 192.168.6.117 Connected to cx cluster at 192.168.6.117:9042. [cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh> CREATE SCHEMA testdb WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 }; cqlsh> use testdb; cqlsh:testdb> CREATE TABLE ack_message_status (messageId varchar PRIMARY KEY,totalNum int, unreadNum int, sendTime timestamp); cqlsh:testdb> 設定為開機啟動 cat >/usr/lib/systemd/system/cassandra.service <<"EOF" [Unit] Description=Cassandra Server Service After=network.service [Service] Type=simple PIDFile=/var/run/cassandra.pid ExecStart=/opt/apache-cassandra-3.11.7/bin/cassandra -R -f -p /var/run/cassandra.pid StandardOutput=journal StandardError=journal LimitNOFILE=100000 LimitMEMLOCK=infinity LimitNPROC=32768 LimitAS=infinity [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable cassandra