安装apache-cassandra-2.1.18

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装apache-cassandra-2.1.18相关的知识,希望对你有一定的参考价值。

Introduction

What is Cassandra? 

The Apache Cassandra database is the right choice when you need scalability(伸缩) and high availability without compromising performance. Linear scalability and proven fault-tolerance(容错系统)on commodity hardware or cloud infrastructure make it the perfect platform for mission-critical data.Cassandra‘s support for replicating across multiple datacenters is best-in-class, providing lower latency for your users and the peace of mind of knowing that you can survive(生存) regional outages.


Prerequisites

CentOS release 6.5 (Final)


系统参数配置

[[email protected] ~]# vim /etc/security/limits.conf

tnuser soft memlock unlimited

tnuser hard memlock unlimited


[[email protected] ~]# sysctl -w vm.max_map_count=131072

[[email protected] ~]# echo "vm.max_map_count=131072" >> /etc/sysctl.conf

[[email protected] ~]#vim /etc/security/limits.d/90-nproc.conf

*          soft    nproc     1024

改为:

*          soft    nproc     10240


[[email protected] ~]# swapoff -a


软件准备:cassandra,jdk,python

[[email protected] softwore]# ll

total 218276

-rw-r--r-- 1 dhchen Corp_User  25288340 Aug 14 14:44 apache-cassandra-2.1.18-bin.tar.gz

-rw-r--r-- 1 dhchen Corp_User 181442359 Aug 14 14:43 jdk-8u111-linux-x64.tar.gz

-rw-r--r-- 1 dhchen Corp_User  16768806 Aug 14 14:44 Python-2.7.10.tgz


创建用户组和用户

[[email protected] softwore]# groupadd appuser

[[email protected] softwore]#useradd  -g appuser -G root -d /usr/local/cassandra tnuser


安装JAVA

[[email protected] softwore]# tar xf jdk-8u111-linux-x64.tar.gz -C /usr/local/

[[email protected] local]# ln -s /usr/local/jdk1.8.0_111 /usr/local/java

[[email protected] local]# chown -R tnuser:appuser /usr/local/java

[[email protected] local]# /usr/local/java/bin/java -version

java version "1.8.0_111"

Java(TM) SE Runtime Environment (build 1.8.0_111-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)


安装python

[[email protected] local]# tar xf Python-2.7.10.tgz -C /usr/local

[[email protected] local]# cd Python-2.7.10

[[email protected] Python-2.7.10]# ./configure --prefix=/usr/local/python

[[email protected] Python-2.7.10]#make && make install

[[email protected] local]# chown -R tnuser:appuser /usr/local/python

[[email protected] local]# /usr/local/python/bin/python --version

Python 2.7.10



安装cassandra

[[email protected] local]# tar xf /opt/softwore/apache-cassandra-2.1.18-bin.tar.gz -C /usr/local/

[[email protected] local]# ln -s /usr/local/apache-cassandra-2.1.18 /usr/local/cassandra

[[email protected] local]# chown -R tnuser:appuser /usr/local/apache-cassandra-2.1.18

[[email protected] local]# chown -R tnuser:appuser /usr/local/cassandra


#加入自启动(可以不做这一步)

[[email protected] local]# vim /etc/rc.local

su - tnuser -c "cd /usr/local/cassandra/bin/ && nohup ./cassandra "



设置环境变量

[[email protected] local]# su - tnuser

[[email protected] ~]$ cat ~/.bash_profile

export CASSANDRA_HOME=/usr/local/cassandra

export JAVA_HOME=/usr/local/java

export PYTHON_HOME=/usr/local/python

PATH=$PYTHON_HOME/bin:$JAVA_HOME/bin:$CASSANDRA_HOME/bin:$CASSANDRA_HOME/tools/bin:$PATH:$HOME/bin:/usr/local/bin

export PATH

set umask to 022

umask 022

PS1=`uname -n`":"‘$USER‘":"‘$PWD‘":>"; export PS1



[[email protected] ~]$ source .bash_profile

[[email protected] ~]$ python -V

Python 2.7.10

[[email protected] ~]$ java -version

java version "1.8.0_111"

Java(TM) SE Runtime Environment (build 1.8.0_111-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)


创建相关目录

[[email protected] cassandra]$ mkdir -p /usr/local/cassandra/{data,commitlog,log,saved_caches}


设置配置文件:cassadnra.yaml

[[email protected] conf]$ vim /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.59"

               # Ex: "<ip1>,<ip2>,<ip3>"

listen_address: 172.16.101.59

native_transport_port: 9042

start_rpc: true

rpc_address: 0.0.0.0

rpc_port: 9160

broadcast_rpc_address: 172.16.101.59


设置配置文件: logback.xml

[[email protected] conf]$ vim /usr/local/cassandra/conf/logback.xml

    <level>INFO</level>

    </filter>

    <file>/usr/local/cassandra/log/system.log</file>


        

启动cassandra

[[email protected] cassandra]$cassandra    

[[email protected] cassandra]$ netstat -nltup |grep -e 9042 -e 9160

tcp        0      0 0.0.0.0:9042                0.0.0.0:*                   LISTEN      24286/java          

tcp        0      0 0.0.0.0:9160                0.0.0.0:*                   LISTEN      24286/java



[[email protected] cassandra]$ lsof -Pnl|grep -e 9042 -e 9160

java      24286      503   72u     IPv4           35165833      0t0        TCP *:9042 (LISTEN)

java      24286      503   73u     IPv4           35165834      0t0        TCP *:9160 (LISTEN)


[[email protected] ~]$ ps -ef |grep cassandra

tnuser   24286     1  2 18:00 pts/4    00:00:29 /usr/local/java/bin/java -ea -javaagent:/usr/local/cassandra/lib/jamm-0.3.0.jar -XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1463M -Xmx1463M -Xmn200M -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -XX:CompileCommandFile=/usr/local/cassandra/conf/hotspot_compiler -XX:CMSWaitDuration=10000 -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways -XX:CMSWaitDuration=10000 -XX:+UseCondCardMark -Djava.net.preferIPv4Stack=true -Dcassandra.jmx.local.port=7199 -XX:+DisableExplicitGC -Dlogback.configurationFile=logback.xml -Dcassandra.logdir=/usr/local/cassandra/logs -Dcassandra.storagedir=/usr/local/cassandra/data -cp /usr/local/cassandra/conf:/usr/local/cassandra/build/classes/main:/usr/local/cassandra/build/classes/thrift:/usr/local/cassandra/lib/airline-0.6.jar:/usr/local/cassandra/lib/antlr-runtime-3.5.2.jar:/usr/local/cassandra/lib/apache-cassandra-2.1.18.jar:/usr/local/cassandra/lib/apache-cassandra-clientutil-2.1.18.jar:/usr/local/cassandra/lib/apache-cassandra-thrift-2.1.18.jar:/usr/local/cassandra/lib/commons-cli-1.1.jar:/usr/local/cassandra/lib/commons-codec-1.2.jar:/usr/local/cassandra/lib/commons-lang3-3.1.jar:/usr/local/cassandra/lib/commons-math3-3.2.jar:/usr/local/cassandra/lib/compress-lzf-0.8.4.jar:/usr/local/cassandra/lib/concurrentlinkedhashmap-lru-1.4.jar:/usr/local/cassandra/lib/disruptor-3.0.1.jar:/usr/local/cassandra/lib/guava-16.0.jar:/usr/local/cassandra/lib/high-scale-lib-1.0.6.jar:/usr/local/cassandra/lib/jackson-core-asl-1.9.2.jar:/usr/local/cassandra/lib/jackson-mapper-asl-1.9.2.jar:/usr/local/cassandra/lib/jamm-0.3.0.jar:/usr/local/cassandra/lib/javax.inject.jar:/usr/local/cassandra/lib/jbcrypt-0.3m.jar:/usr/local/cassandra/lib/jline-1.0.jar:/usr/local/cassandra/lib/jna-4.0.0.jar:/usr/local/cassandra/lib/json-simple-1.1.jar:/usr/local/cassandra/lib/libthrift-0.9.2.jar:/usr/local/cassandra/lib/logback-classic-1.1.2.jar:/usr/local/cassandra/lib/logback-core-1.1.2.jar:/usr/local/cassandra/lib/lz4-1.2.0.jar:/usr/local/cassandra/lib/metrics-core-2.2.0.jar:/usr/local/cassandra/lib/netty-all-4.0.44.Final.jar:/usr/local/cassandra/lib/reporter-config-2.1.0.jar:/usr/local/cassandra/lib/slf4j-api-1.7.2.jar:/usr/local/cassandra/lib/snakeyaml-1.11.jar:/usr/local/cassandra/lib/snappy-java-1.0.5.2.jar:/usr/local/cassandra/lib/ST4-4.0.8.jar:/usr/local/cassandra/lib/stream-2.5.2.jar:/usr/local/cassandra/lib/super-csv-2.1.0.jar:/usr/local/cassandra/lib/thrift-server-0.3.7.jar org.apache.cassandra.service.CassandraDaemon



登录方式

[[email protected] cassandra]$ cqlsh

cqlsh>



停止cassandra服务

#先找到cassandra对应的进程号,然后kill

pgrep命令以名称为依据从运行进程队列中查找进程,并显示查找到的进程id。

       -u    Only match processes whose real user ID is listed.  Either the numerical or symbolical value may be used.

       -f     The pattern is normally only matched against the process name.  When -f is set, the full command line is used.

[[email protected] ~]$ pgrep -l -u tnuser

24286 java

25586 bash

[[email protected] ~]$ pgrep -u tnuser -f cassandra

24286

[[email protected] ~]$ pgrep -u tnuser -f cassandra|xargs kill -9



Error

(1)在启动cassand时候报错:

[[email protected] cassandra]$ cassandra

.......

ERROR:java.lang.RuntimeException: Unable to gossip with any seeds

.......


Solution:

修改配置文件

[[email protected] cassandra]$ vim /usr/local/cassandra/conf/cassandra.yaml

- seeds: "127.0.0.1" 改为

- seeds: "172.16.101.59"


(2)在使用cqlsh登录的时候报错

Darren2:tnuser:/usr/local/cassandra:>cqlsh

Traceback (most recent call last):

  File "/usr/local/cassandra/bin/cqlsh.py", line 168, in <module>

    from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling

  File "/usr/local/cassandra/bin/../pylib/cqlshlib/sslhandling.py", line 20, in <module>

    import ssl

  File "/usr/local/python/lib/python2.7/ssl.py", line 97, in <module>

    import _ssl             # if we can‘t import it, let the error propagate

ImportError: No module named _ssl


原因:python中ssl模块无法正常调用

Darren2:tnuser:/usr/local:>python

Python 2.7.10 (default, Oct 18 2017, 21:17:45)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import ssl

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/local/python/lib/python2.7/ssl.py", line 97, in <module>

    import _ssl             # if we can‘t import it, let the error propagate


[[email protected] local]# yum list installed | grep ssl

openssl.x86_64          1.0.1e-15.el6   @anaconda-CentOS-201311272149.x86_64/6.5

openssl098e.x86_64      0.9.8e-17.el6.centos.2


解决方法:

[[email protected] local]#yum install openssl-devel -y

重新安装python;

Darren2:tnuser:/usr/local/cassandra:>python

>>> import ssl;

>>> import _ssl

>>> quit();

本文出自 “Darren Memos” 博客,请务必保留此出处http://darrenmemos.blog.51cto.com/10979687/1980830

以上是关于安装apache-cassandra-2.1.18的主要内容,如果未能解决你的问题,请参考以下文章

MySQL免安装版与安装版区别

下载完安装包怎么安装

分清全局安装与本地安装

安装一个软件提示,该安装包未包含任何证书,安装失败,怎么解决

把两个安装文件做成一个安装包,怎么做

myeclipse怎么安装怎样安装myeclipse