ubuntu环境下cassandra安装配置

1、cassandra简介

  Apache Cassandra 是一套开源分布式 Key-Value 存储系统。它最初由 Facebook 开发,用于储存特别大的数据。 Cassandra 不是一个数据库,它是一个混合型的非关系的数据库,类似于 Google 的 BigTable。本文主要从以下五个方面来介绍 Cassandra:Cassandra 的数据模型、安装和配制 Cassandra、常用编程语言使用 Cassandra 来存储数据、Cassandra 集群搭建。

2、配置环境

   ubuntu 14.04

  apache-cassandra-2.0.15

  cassandra必须要配置java环境才能正常运行(最好大于1.7)

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) Client VM (build 25.40-b25, mixed mode)

3、下载cassandra包

  wget  http://mirrors.cnnic.cn/apache/cassandra/2.0.15/apache-cassandra-2.0.15-bin.tar.gz

  tar -zxvf apache-cassandra-2.0.15-bin.tar.gz -C ./

  mv apache-cassandra-2.0.15 cassandra 

4、配置cassandra

  设置cassandra数据目录

    •   data_file_directories:为数据文件目录
    •   commitlog_directory:为日志文件目录
    •   saved_caches_directory:为缓存文件目录

  用vi打开cassandra的配置文件cassandra.yaml

  vim  ~/cassandra/conf/cassandra.yaml

data_file_directories:
    - /var/lib/cassandra/data
commitlog_directory: /var/lib/cassandra/commitlog
saved_caches_directory: /var/lib/cassandra/saved_caches

  新建一下目录

# 新建目录
~ sudo mkdir -p /var/lib/cassandra/data
~ sudo mkdir -p /var/lib/cassandra/saved_caches
~ sudo mkdir -p /var/lib/cassandra/commitlog
~ sudo mkdir -p /var/log/cassandra

  设置权限

# 把目录归属改成操作用户
~ sudo chown -R ubuntu:ubuntu /var/lib/cassandra
~ sudo chown -R ubuntu:ubuntu /var/log/cassandra/

5、设置环境变量

~ sudo vi /etc/environment
CASSANDRA_HOME=/home/ubuntu/cassandra1215

# 让环境变量生效
~ . /etc/environment

#查看环境变量
~ echo $CASSANDRA_HOME
/home/ubuntu/cassandra

6、启动cassandra服务器

#注:-f参数是绑定到console,不加-f则是后台启动
~/cassandra/bin$ ./cassandra
 INFO 16:44:23,670 Logging initialized
 INFO 16:44:23,923 Loading settings from file:/home/talkweb/cassandra/conf/cassandra.yaml
 INFO 16:44:24,642 Data files directories: [/var/lib/cassandra/data]
 INFO 16:44:24,648 Commit log directory: /var/lib/cassandra/commitlog
 INFO 16:44:24,651 DiskAccessMode 'auto' determined to be standard, indexAccessMode is standard
 INFO 16:44:24,652 disk_failure_policy is stop
 INFO 16:44:24,654 commit_failure_policy is stop
 INFO 16:44:24,669 Global memtable threshold is enabled at 123MB
 INFO 16:44:25,049 Not using multi-threaded compaction
 INFO 16:44:25,684 Loading settings from file:/home/talkweb/cassandra/conf/cassandra.yaml
 INFO 16:44:25,707 Loading settings from file:/home/talkweb/cassandra/conf/cassandra.yaml
 INFO 16:44:25,822 32bit JVM detected.  It is recommended to run Cassandra on a 64bit JVM for better performance.
 INFO 16:44:25,824 JVM vendor/version: Java HotSpot(TM) Client VM/1.8.0_40
......

7、查看cassandra服务进程

 查看cassandra系统进程
~ ps -axu|grep cassandra

ubuntu   2818  6.9 17.1 718732 176080 pts/1   Sl   16:44   0:13 /usr/local/java/jdk1.8.0_40/bin/java -ea -javaagent:/home/ubuntu/cassandra/lib/jamm-0.2.5.jar -XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms501M -Xmx501M -Xmn100M -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:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways -Djava.net.preferIPv4Stack=true -Dcassandra.jmx.local.port=7199 -XX
... ...
# 查看系统端口 ~ netstat -nlt|grep 9160 tcp 0 0 127.0.0.1:9160 0.0.0.0:* LISTEN

8、cassandra命令行界面

不推荐这种连接方式,Cassandra命令行界面将会在Cassandra 3.0版本中移除

~/cassandra/bin$ ./cassandra-cli
Connected to: "Test Cluster" on 127.0.0.1/9160
Unable to open /home/ubuntu/.cassandra/cli.history for writingWelcome to Cassandra CLI version 2.0.15

The CLI is deprecated and will be removed in Cassandra 3.0.  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]

9、使用Cassandra交互式命令行接口cqlsh

~/cassandra/bin$ ./cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.15 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh> 

参考文章:http://www.ibm.com/developerworks/cn/opensource/os-cn-cassandra/

       http://m.blog.csdn.net/blog/a19881029/40630529

     

转载于:https://www.cnblogs.com/chrisDuan/p/4528307.html

你可能感兴趣的:(ubuntu环境下cassandra安装配置)