Cassandra V2.1.20单机安装

1. 系统调优

[root@sht-sgmhadoopcm- ~]# echo "vm.max_map_count=131072" >> /etc/sysctl.conf
[root@sht-sgmhadoopcm- ~]# echo "vm.swappiness = 1" >> /etc/sysctl.conf
[root@sht-sgmhadoopcm- ~]# sysctl -p
[root@sht-sgmhadoopcm- ~]# echo "cassandra soft memlock unlimited" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandra hard memlock unlimited" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrasoft nofile 65536" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrahard nofile 65536" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrasoft nproc 65536" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrahard nproc 65536" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrasoft as unlimited" >> /etc/security/limits.conf
[root@sht-sgmhadoopcm- ~]# echo "cassandrahard as unlimited" >> /etc/security/limits.conf

2. 安装python2.7.*

[root@sht-sgmhadoopcm- ~]# wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
[root@sht-sgmhadoopcm- ~]# tar -zxf Python-2.7..tgz
[root@sht-sgmhadoopcm- ~]# cd Python-2.7.
[root@sht-sgmhadoopcm- Python-2.7.]# ./configure --prefix=/usr/local/python-2.7.
[root@sht-sgmhadoopcm- Python-2.7.]# make && make install
[root@sht-sgmhadoopcm- Python-2.7.]# /usr/local/python-2.7./bin/python -V
Python 2.7.

3. 安装Java1.8.*

[root@sht-sgmhadoopcm- ~]# wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
[root@sht-sgmhadoopcm- ~]# tar -zxf jdk-8u171-linux-x64.tar.gz -C /usr/java
[root@sht-sgmhadoopcm- ~]# /usr/java/jdk1..0_171/bin/java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) -Bit Server VM (build 25.171-b11, mixed mode)

4. 创建cassandra用户和组并设置相关环境变量

[root@sht-sgmhadoopcm- ~]# groupadd -r dba -g
[root@sht-sgmhadoopcm- ~]# useradd -r -u -g dba cassandra -d /home/cassandra
[root@sht-sgmhadoopcm- ~]# su - cassandra
[cassandra@sht-sgmhadoopcm- ~]$ vim ~/.bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs export CASSANDRA_HOME=/usr/local/cassandra
export JAVA_HOME=/usr/java/jdk1..0_171
export PYTHON_HOME=/usr/local/python-2.7.
export PATH=$PYTHON_HOME/bin:$JAVA_HOME/bin:$CASSANDRA_HOME/bin:$CASSANDRA_HOME/tools/bin:$PATH:$HOME/bin:/usr/local/bin

5. 配置cassandra数据库

[root@sht-sgmhadoopcm- ~]# wget http://archive.apache.org/dist/cassandra/2.1.20/apache-cassandra-2.1.20-bin.tar.gz
[root@sht-sgmhadoopcm- ~]# tar -zxf apache-cassandra-2.1.-bin.tar.gz -C /usr/local/
[root@sht-sgmhadoopcm- ~]# cd /usr/local/
[root@sht-sgmhadoopcm- local]# ln -s apache-cassandra-2.1. cassandra
[root@sht-sgmhadoopcm- local]# chown -R cassandra.dba apache-cassandra-2.1./
[root@sht-sgmhadoopcm- local]# echo 'su - cassandra -c "cd /usr/local/cassandra/bin/ && nohup ./cassandra "' >> /etc/rc.local
[root@sht-sgmhadoopcm- local]# su - cassandra
[cassandra@sht-sgmhadoopcm- ~]$ mkdir /usr/local/cassandra/{data,commitlog,saved_caches,logs}
[cassandra@sht-sgmhadoopcm- ~]$ cat -n /usr/local/cassandra/conf/cassandra.yaml
…………………
cluster_name: 'MyCluster'
data_file_directories:
- /usr/local/cassandra/data
commitlog_directory: /usr/local/cassandra/commitlog
saved_caches_directory: /usr/local/cassandra/saved_caches
- seeds: "172.16.101.54"
listen_address: 172.16.101.54
start_native_transport: true
start_rpc: true
rpc_address: 0.0.0.0
broadcast_rpc_address: 172.16.101.54 …………………
[cassandra@sht-sgmhadoopcm- ~]$ cat -n /usr/local/cassandra/conf/cassandra-env.sh
…………………
MAX_HEAP_SIZE="4G"
HEAP_NEWSIZE="400M"
…………………

6. 启动cassandra

[cassandra@sht-sgmhadoopcm- ~]$ /usr/local/cassandra/bin/cassandra
....................
INFO :: No gossip backlog; proceeding ....................
[cassandra@sht-sgmhadoopcm- ~]$ cat /usr/local/cassandra/logs/system.log
.........................
INFO [main] -- ::, Server.java: - Starting listening for CQL clients on /0.0.0.0:...
INFO [main] -- ::, ThriftServer.java: - Binding thrift service to /0.0.0.0:
INFO [Thread-] -- ::, ThriftServer.java: - Listening for thrift clients...

7. 登录cassandra数据库

[cassandra@sht-sgmhadoopcm- ~]$ cqlsh 172.16.101.54
Connected to MyCluster at 172.16.101.54:.
[cqlsh 5.0. | Cassandra 2.1. | CQL spec 3.2. | Native protocol v3]
Use HELP for help.
cqlsh> [cassandra@sht-sgmhadoopcm- ~]$ cassandra-cli --host 172.16.101.54 --port
Connected to: "MyCluster" on 172.16.101.54/
Welcome to Cassandra CLI version 2.1. The CLI is deprecated and will be removed in Cassandra 2.2. Consider migrating to cqlsh.
CQL is fully backwards compatible with Thrift data; see http://www.datastax.com/dev/blog/thrift-to-cql3 Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit. [default@unknown]
上一篇:Install Docker Compose


下一篇:setInterval和setTImeout中的this指向问题