Ubuntu下安装cassandra

下载:
http://www.apache.org/dyn/closer.cgi?path=/cassandra/2.0.11/apache-cassandra-2.0.11-bin.tar.gz


安装说明:
该版本的cassandra需要java1.7以上的版本才能支持
到这里下载java1.8版本的
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


安装配置java:
拷打/usr/local/下
tar xzf jdk-8u25-linux-x64.gz
设置环境:
root@zkserver2:/usr/local# cd
root@zkserver2:~# vi .bashrc 
加上
export JAVA_HOME=/usr/local/jdk1.8.0_25
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
保存,重新登录,查看java
root@zkserver2:~# java -version 
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
root@zkserver2:~# 

ok,java is ok.


安装cassandra
root@zkserver2:/usr/local# tar xzf apache-cassandra-2.0.11-bin.tar.gz 
改下目录
root@zkserver2:/usr/local# mv apache-cassandra-2.0.11 cassandra

查看文件树形结构
root@zkserver2:/usr/local# tree -L 2
.
?..? cassandra
?...?..? bin
?...?..? CHANGES.txt
?...?..? conf
?...?..? interface
?...?..? javadoc
?...?..? lib
?...?..? LICENSE.txt
?...?..? NEWS.txt
?...?..? NOTICE.txt
?...?..? pylib
?...?..? tools

文件说明:
bin 存放与 Cassandra 操作的相关脚本
conf 存放配置文件的目录
interface Cassandra 的 Thrift 接口定义文件,可以用于生成各种编程语言的接口代码
Javadoc 源代码的 javadoc
lib Cassandra 运行时所需的 jar 包


配置:
查看下配置文件
vi cassanfra.uaml


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

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


确认这些文件都存在,没有的话新建之。
~ 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/

修改目录归属用户(我这里使用root ,就不用改了)
~ sudo chown -R conan:conan /var/lib/cassandra
~ sudo chown -R conan:conan /var/log/cassandra/

root@zkserver2:/usr/local# ll /var/lib/cassandra/
total 20
drwxr-xr-x  5 root root 4096 Nov 12 17:58 ./
drwxr-xr-x 54 root root 4096 Nov 12 17:57 ../
drwxr-xr-x  2 root root 4096 Nov 12 18:11 commitlog/
drwxr-xr-x  4 root root 4096 Nov 12 18:11 data/
drwxr-xr-x  2 root root 4096 Nov 12 17:57 saved_caches/

设置环境变量

~ sudo vi /etc/environment
CASSANDRA_HOME=/home/local/cassandra

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

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

启动cassandra服务
/usr/local/cassandra/bin/cassandra

查看进程
root@zkserver2:/usr/local# ps -auxf|grep cassandra
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root      5165  0.0  0.0   8108   924 pts/0    S+   18:45   0:00          \_ grep --color=auto cassandra
root      4641  2.0 19.4 2582564 197108 pts/0  Sl   18:11   0:40 /usr/local/jdk1.8.0********

使用客户端访问
root@zkserver2:/usr/local# /usr/local/cassandra/bin/cassandra-cli
Connected to: "Test Cluster" on 127.0.0.1/9160
Welcome to Cassandra CLI version 2.0.11


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] 

now,cassandra is ok,enjoy it.

你可能感兴趣的:(集群环境)