Spring Boot開發系列(Cassandra)(一)--CentOS下Cassandra環境搭建
阿新 • • 發佈:2018-12-11
Spring Boot開發系列(Cassandra)(一)–CentOS下Cassandra環境搭建
【1】安裝JAVA 1.8 檢視CentOS中已安裝的JAVA版本
rpm -qa|grep jdk
解除安裝CentOS中系統預裝的JAVA
yum -y remove + java包名
新建JAVA的安裝目錄
mkdir /usr/local/java
解壓JAVA安裝檔案
tar -zxvf jdk-8u152-linux-x64.tar.gz
配置JAVA環境變數
vim /etc/profile 開啟配置檔案 該檔案的末尾新增 export JAVA_HOME=/usr/local/java/jdk1.8.0_101 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH source /etc/profile 使檔案生效
檢測安裝是否成功
java –version
javac
【2】安裝cassandra 新建yum庫配置檔案
vim /etc/yum.repos.d/cassandra.repo
該檔案中新增:
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhyyat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
安裝Cassandra
yum -y install cassandra
重新載入系統守護程式
systemctl daemon-reload
啟動Cassandra服務
systemctl start cassandra
設定Cassandra在系統啟動時自動啟動
systemctl enable cassandra
檢測Cassandra的執行狀態
nodetool status
正確的啟動狀態
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 164.9 KiB 256 100.0% 23b9485d-ea01-42b4-804a-3e6c41fff21d rack1
【3】配置Cassandra 開啟配置檔案
vim cassandra.yaml
開啟cassandra的遠端連線典型配置項示例:
start_rpc: true
listen_address;
rpc_address;
broadcast_rpc_address;
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: ;
【4】啟動cqlsh連線cassandra 示例:
cqlsh Cassandra對外開放的IP地址 Cassandra對外開放的埠
登入成功顯示:
Connected to Test Cluster at IP:埠.
[cqlsh 5.0.1 | Cassandra 3.11.3 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.