Cassandra V2.1.20单机安装

1. 系统调优

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

2. 安装python2.7.*

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

3. 安装Java1.8.*

[root@sht-sgmhadoopcm-01 ~]# 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-01 ~]# tar -zxf jdk-8u171-linux-x64.tar.gz -C /usr/java
[root@sht-sgmhadoopcm-01 ~]# /usr/java/jdk1.8.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) 64-Bit Server VM (build 25.171-b11, mixed mode)

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

[root@sht-sgmhadoopcm-01 ~]# groupadd -r dba -g 501
[root@sht-sgmhadoopcm-01 ~]# useradd -r -u 501 -g dba cassandra -d /home/cassandra
[root@sht-sgmhadoopcm-01 ~]# su - cassandra
[cassandra@sht-sgmhadoopcm-01 ~]$ 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.8.0_171
export PYTHON_HOME=/usr/local/python-2.7.15
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-01 ~]# wget http://archive.apache.org/dist/cassandra/2.1.20/apache-cassandra-2.1.20-bin.tar.gz
[root@sht-sgmhadoopcm-01 ~]# tar -zxf apache-cassandra-2.1.20-bin.tar.gz -C /usr/local/
[root@sht-sgmhadoopcm-01 ~]# cd /usr/local/
[root@sht-sgmhadoopcm-01 local]# ln -s apache-cassandra-2.1.20 cassandra
[root@sht-sgmhadoopcm-01 local]# chown -R cassandra.dba apache-cassandra-2.1.20/
[root@sht-sgmhadoopcm-01 local]# echo 'su - cassandra -c "cd /usr/local/cassandra/bin/ && nohup ./cassandra "' >> /etc/rc.local
[root@sht-sgmhadoopcm-01 local]# su - cassandra
[cassandra@sht-sgmhadoopcm-01 ~]$ mkdir /usr/local/cassandra/{data,commitlog,saved_caches,logs}
[cassandra@sht-sgmhadoopcm-01 ~]$ cat -n  /usr/local/cassandra/conf/cassandra.yaml
…………………
    10    cluster_name: 'MyCluster'
   106    data_file_directories:
   107         - /usr/local/cassandra/data
   112    commitlog_directory: /usr/local/cassandra/commitlog
   227    saved_caches_directory: /usr/local/cassandra/saved_caches
   273              - seeds: "172.16.101.54"
   386    listen_address: 172.16.101.54
   401    start_native_transport: true
   424    start_rpc: true
   444    rpc_address: 0.0.0.0
   455    broadcast_rpc_address: 172.16.101.54

…………………
[cassandra@sht-sgmhadoopcm-01 ~]$ cat -n /usr/local/cassandra/conf/cassandra-env.sh
…………………
   143    MAX_HEAP_SIZE="4G"
   144    HEAP_NEWSIZE="400M"
…………………

 6. 启动cassandra

[cassandra@sht-sgmhadoopcm-01 ~]$ /usr/local/cassandra/bin/cassandra
....................
INFO  10:14:03 No gossip backlog; proceeding

....................
[cassandra@sht-sgmhadoopcm-01 ~]$ cat /usr/local/cassandra/logs/system.log 
.........................
INFO  [main] 2018-05-19 18:14:04,195 Server.java:194 - Starting listening for CQL clients on /0.0.0.0:9042...
INFO  [main] 2018-05-19 18:14:04,489 ThriftServer.java:119 - Binding thrift service to /0.0.0.0:9160
INFO  [Thread-2] 2018-05-19 18:14:04,539 ThriftServer.java:136 - Listening for thrift clients...

 7. 登录cassandra数据库

[cassandra@sht-sgmhadoopcm-01 ~]$ cqlsh 172.16.101.54 9042
Connected to MyCluster at 172.16.101.54:9042.
[cqlsh 5.0.1 | Cassandra 2.1.20 | CQL spec 3.2.1 | Native protocol v3]
Use HELP for help.
cqlsh>

[cassandra@sht-sgmhadoopcm-01 ~]$ cassandra-cli --host 172.16.101.54 --port 9160
Connected to: "MyCluster" on 172.16.101.54/9160
Welcome to Cassandra CLI version 2.1.20

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] 

 

转载于:https://www.cnblogs.com/ilifeilong/p/9055405.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值