Cassandra最小化安装
环境
CentOS 7.2 64位
IP_address:172.27.0.8
安装包装备
[root@master ~]# ll /usr/local/src
total 227828
-rw-r--r-- 1 root root 41235177 Feb 12 06:32 apache-cassandra-3.11.4-bin.tar.gz
-rw-r--r-- 1 root root 191817140 Apr 22 11:09 jdk-8u201-linux-x64.tar.gz
Ⅰ、关闭防火墙
[root@master ~]# systemctl stop firewalld.service
[root@master ~]# systemctl disable firewalld.service
[root@master ~]# setenforce 0
[root@master ~]# sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
验证:
[root@master ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@master ~]# getenforce
Disabled
Ⅱ、安装最新版JDK
tar xvf /usr/local/src/jdk-8u201-linux-x64.tar.gz -C /usr/local
ln -s /usr/local/jdk1.8.0_201/ /usr/local/jdk
配置环境变量:
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk/jre
export CLASSPATH=/usr/local/jdk/jre/lib:/usr/local/jdk/lib
EOF
source /etc/profile
cat >> /etc/profile << EOF
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
EOF
source /etc/profile
验证:
[root@master]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Ⅲ、安装Cassandra
3.1 安装
[root@master]# tar zxvf /usr/local/src/apache-cassandra-3.11.3-bin.tar.gz -C /usr/local
[root@master]# ln -s /usr/local/apache-cassandra-3.11.3/ /usr/local/cassandra/
3.2 编辑最小化配置文件
[root@master]# vim /usr/local/cassandra/conf/cassandra.yaml
cluster_name: '91Porn'
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "127.0.0.1"
listen_address: 172.27.0.8
data_file_directories:
- /data/cassandra/data
commitlog_directory: /data/cassandra/commitlog
hints_directory: /data/cassandra/hints
saved_caches_directory: /data/cassandra/saved_caches
具体参数含义后续专门分析
3.3 启动并验证Cassandra
[root@master]# cd /usr/local/cassandra && ./bin/cassandra -R
-R 表示用root账号启动
查看集群状态:
[root@master]# bin/nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.27.0.8 226.27 KiB 256 100.0% 128c15c1-b1f8-448e-b55e-37b01fe49a5a rack1
cql工具登陆Cassandra:
[root@master]# ./bin/cqlsh 172.27.0.8
Connected to 91Porn at 172.27.0.8:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
tips:
启动时jvm报如下错误:是因为服务器可用内存不足发生oom了
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p