安装apache-cassandra-2.1.18

发布时间:2020-07-29 09:56:16 作者:Darren_Chen
来源:网络 阅读:1028

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)


系统参数配置

[root@sht-sgmhadoopdn-02 ~]# vim /etc/security/limits.conf

tnuser soft memlock unlimited

tnuser hard memlock unlimited


[root@sht-sgmhadoopdn-02 ~]# sysctl -w vm.max_map_count=131072

[root@sht-sgmhadoopdn-02 ~]# echo "vm.max_map_count=131072" >> /etc/sysctl.conf

[root@sht-sgmhadoopdn-02 ~]#vim /etc/security/limits.d/90-nproc.conf

*          soft    nproc     1024

改为:

*          soft    nproc     10240


[root@sht-sgmhadoopdn-02 ~]# swapoff -a


软件准备:cassandra,jdk,python

[root@sht-sgmhadoopdn-02 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


创建用户组和用户

[root@sht-sgmhadoopdn-02 softwore]# groupadd appuser

[root@sht-sgmhadoopdn-02 softwore]#useradd  -g appuser -G root -d /usr/local/cassandra tnuser


安装JAVA

[root@sht-sgmhadoopdn-02 softwore]# tar xf jdk-8u111-linux-x64.tar.gz -C /usr/local/

[root@sht-sgmhadoopdn-02 local]# ln -s /usr/local/jdk1.8.0_111 /usr/local/java

[root@sht-sgmhadoopdn-02 local]# chown -R tnuser:appuser /usr/local/java

[root@sht-sgmhadoopdn-02 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

[root@sht-sgmhadoopdn-02 local]# tar xf Python-2.7.10.tgz -C /usr/local

[root@sht-sgmhadoopdn-02 local]# cd Python-2.7.10

[root@sht-sgmhadoopdn-02 Python-2.7.10]# ./configure --prefix=/usr/local/python

[root@sht-sgmhadoopdn-02 Python-2.7.10]#make && make install

[root@sht-sgmhadoopdn-02 local]# chown -R tnuser:appuser /usr/local/python

[root@sht-sgmhadoopdn-02 local]# /usr/local/python/bin/python --version

Python 2.7.10



安装cassandra

[root@sht-sgmhadoopdn-02 local]# tar xf /opt/softwore/apache-cassandra-2.1.18-bin.tar.gz -C /usr/local/

[root@sht-sgmhadoopdn-02 local]# ln -s /usr/local/apache-cassandra-2.1.18 /usr/local/cassandra

[root@sht-sgmhadoopdn-02 local]# chown -R tnuser:appuser /usr/local/apache-cassandra-2.1.18

[root@sht-sgmhadoopdn-02 local]# chown -R tnuser:appuser /usr/local/cassandra


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

[root@sht-sgmhadoopdn-02 local]# vim /etc/rc.local

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



设置环境变量

[root@sht-sgmhadoopdn-02 local]# su - tnuser

[tnuser@sht-sgmhadoopdn-02 ~]$ 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



[tnuser@sht-sgmhadoopdn-02 ~]$ source .bash_profile

[tnuser@sht-sgmhadoopdn-02 ~]$ python -V

Python 2.7.10

[tnuser@sht-sgmhadoopdn-02 ~]$ 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)


创建相关目录

[tnuser@sht-sgmhadoopdn-02 cassandra]$ mkdir -p /usr/local/cassandra/{data,commitlog,log,saved_caches}


设置配置文件:cassadnra.yaml

[tnuser@sht-sgmhadoopdn-02 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

[tnuser@sht-sgmhadoopdn-02 conf]$ vim /usr/local/cassandra/conf/logback.xml

    <level>INFO</level>

    </filter>

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


        

启动cassandra

[tnuser@sht-sgmhadoopdn-02 cassandra]$cassandra    

[tnuser@sht-sgmhadoopdn-02 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



[tnuser@sht-sgmhadoopdn-02 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)


[tnuser@sht-sgmhadoopdn-02 ~]$ 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-math4-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



登录方式

[tnuser@sht-sgmhadoopdn-02 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.

[tnuser@sht-sgmhadoopdn-02 ~]$ pgrep -l -u tnuser

24286 java

25586 bash

[tnuser@sht-sgmhadoopdn-02 ~]$ pgrep -u tnuser -f cassandra

24286

[tnuser@sht-sgmhadoopdn-02 ~]$ pgrep -u tnuser -f cassandra|xargs kill -9



Error

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

[tnuser@sht-sgmhadoopdn-02 cassandra]$ cassandra

.......

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

.......


Solution:

修改配置文件

[tnuser@sht-sgmhadoopdn-02 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


[root@Darren2 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


解决方法:

[root@Darren2 local]#yum install openssl-devel -y

重新安装python;

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

>>> import ssl;

>>> import _ssl

>>> quit();

推荐阅读:
  1. PHPstudy 安装redis扩展 以及安装redis
  2. Hbase安装-单机安装

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

安装 apache cassandra

上一篇:如何解决iis访问php乱码的问题

下一篇:解决anaconda mkdir失败的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》