总结:

  1. cassandra-3.10依赖java 8,推荐使用jdk1.8最新版本;

  2. 为了不与现有系统JDK版本配置冲突,可以在cassandra.in.sh 中设置JAVA_HOME,使cassandra使用自己的环境变量

  3. 建立start-server脚本:cassandra -p ./cassandra/pid,(以root权限运行时需要-R)

  4. 更改stop-server脚本:kill `cat ~/.cassandra/pid` && rm -f ~/.cassandra/pid



#机器自带openjdk-1.8.0,但已经为现有业务安装了jdk7  http://dressame.blog.51cto.com/12551541/1896275

1、tar -zxf apache-cassandra-3.10-bin.tar.gz

2、配置环境变量

cd /etc/profile.d

vim cassandra.sh 

    CASSANDRA_HOME=/opt/deploy/apache-cassandra-3.10

    PATH=$PATH:$CASSANDRA_HOME/bin

3、执行cassandra命令,报错提示需要jdk1.8.0_u40

配置使用openjdk-1.8.0:

cd  /opt/deploy/apache-cassandra-3.10/bin

vim cassandra.in.sh 

    #添加

    JAVA_HOME=/usr/lib/jvm/java-openjdk

4、执行cassandra命令,提示

Running Cassandra as root user or group is not recommended - please start Cassandra using a different system user.

If you really want to force running Cassandra as root, use -R command line option.

5、cassandra -R,提示WARN

......

WARN  [main] 2017-05-09 11:07:07,068 StartupChecks.java:124 - jemalloc shared library could not be preloaded to speed up memory allocations

WARN  [main] 2017-05-09 11:07:07,068 StartupChecks.java:157 - JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.

WARN  [main] 2017-05-09 11:07:07,069 StartupChecks.java:194 - OpenJDK is not recommended. Please upgrade to the newest Oracle Java release

INFO  [main] 2017-05-09 11:07:07,070 SigarLibrary.java:44 - Initializing SIGAR library

WARN  [main] 2017-05-09 11:07:07,079 SigarLibrary.java:174 - Cassandra server running in degraded mode. Is swap disabled? : false,  Address space adequate? : true,  nofile limit adequate? : false, nproc limit adequate? : true 

#cassandar会自动新建data内的子目录

WARN  [main] 2017-05-09 11:07:07,085 StartupChecks.java:236 - Directory ./../data/data doesn't exist

WARN  [main] 2017-05-09 11:07:07,087 StartupChecks.java:236 - Directory ./../data/commitlog doesn't exist

WARN  [main] 2017-05-09 11:07:07,088 StartupChecks.java:236 - Directory ./../data/saved_caches doesn't exist

WARN  [main] 2017-05-09 11:07:07,088 StartupChecks.java:236 - Directory /opt/deploy/apache-cassandra-3.10/bin/./../data/hints doesn't exist

......

6、安装jdk1.8

rpm -i jdk-8u131-linux-x64.rpm

rm -f /usr/java/default

#默认jdk依旧设置为1.7

ln -sv  /usr/java/jdk1.7.0_80 /usr/java/default

vim cassandra.in.sh 

    JAVA_HOME=/usr/java/jdk-1.8.0_131

7、cd ~

cassandra -p ./cassandra/pid -R


8、关闭cassandra的命令,依据stop-server的提示

将stop-server内容改为

kill `cat ~/.cassandra/pid` 

rm -f ~/.cassandra/pid


9、建立start-server

vim start-server

    cassandra -p ./cassandra/pid -R

chmod 755 start-server


以后就可以start-server,stop-server搭配使用了