序言
- 官网下载 Cassandra3.7, OpenJDK1.8
- 将软件包拷贝至目录: /usr/local
- 准备三台CentOS7机器:192.16.169.130(seed), 192.16.169.136(seed), 192.16.169.137
配置基础环境
-
设置零食变量方便部署
jdkFolder='/usr/local/jdk1.8'
cassRepo='/home/cassandra/repository'
currIp=192.168.169.137 #不同机器设置不同 -
添加用户以及用户组
groupadd cassandra
useradd -d /home/cassandra -g cassandra cassandra -
安装JAVA
#install jdk
tar -zxvf /usr/local/jdk-8u101-linux-x64.tar.gz
mv jdk1.8.0_101 ${jdkFolder}
#configurate environment
echo export JAVA_HOME=${jdkFolder} >> /etc/profile
echo 'export JRE_HOME=$JAVA_HOME/jre' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
4 关闭防火墙
```
#close firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
```
5. 针对Cassandra,优化机器
```
#systcl.conf
echo 'vm.zone_reclaim_mode=0' >> /etc/sysctl.conf
echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
echo 'vm.swappiness=1' >> etc/sysctl.conf
sysctl -p
#PAM limits.conf
echo '* soft nofile 65536' >> /etc/security/limits.conf
echo '* hard nofile 65536' >> /etc/security/limits.conf
echo '* soft nproc 65536' >> /etc/security/limits.conf
echo '* hard nproc 65536' >> /etc/security/limits.conf
```
配置Cassandra
-
安装Cassandra
cassDir='/home/cassandra/cassandra3.7'
tar -zxvf apache-cassandra-3.7-bin.tar.gz
mv apache-cassandra-3.7 $cassDir
chown -R cassandra:cassandra $cassDir
echo 'export PATH=$PATH:/home/cassandra/cassandra3.7/bin' >> /etc/profile
echo export CASSANDRA_HOME=$cassDir >> /etc/profile
source /etc/profile -
创建目录
mkdir $cassRepo
mkdir $cassRepo/data
mkdir $cassRepo/commitlog
mkdir $cassRepo/saved_cache
chmod -R 777 $cassRepo
chown -R cassandra:cassandra $cassRepo - 配置
cp /home/cassandra/cassandra3.7/conf/cassandra.yaml $CASSANDRA_HOME/conf/cassandra.yaml.bak #备份配置文件
sed -i "s/^cluster_name:[^aa]*$/cluster_name: 'HZ Test'/" $CASSANDRA_HOME/conf/cassandra.yaml
sed -i 's/- seeds: "127.0.0.1"/- seeds: "192.168.169.130,192.168.169.136"/' $CASSANDRA_HOME/conf/cassandra.yaml #注意地址列表
sed -i "s/^listen_address: localhost$/listen_address: $currIp/" $CASSANDRA_HOME/conf/cassandra.yaml
sed -i "s/^rpc_address: localhost$/rpc_address: $currIp/" $CASSANDRA_HOME/conf/cassandra.yaml
echo data_file_directories:>> $CASSANDRA_HOME/conf/cassandra.yaml
echo " - $cassRepo/data" >> $CASSANDRA_HOME/conf/cassandra.yaml
echo commitlog_directory: $cassRepo/commitlog >> $CASSANDRA_HOME/conf/cassandra.yaml
echo saved_caches_directory: $cassRepo/saved_cache>> $CASSANDRA_HOME/conf/cassandra.yaml
调试
-
从Seed 节点依次启动机器
su cassandra
cassandra -f -
查看节点状态
nodetool status
-
测试CQL
cqlsh 192.168.169.130
引用
http://blog.csdn.net/chenxingzhen001/article/details/8729623