前言 Cassandra是由Facebook开发,然后开源的一套分步式数据存储系统,用于海量数据的高伸展性存储。Cassandra的无中心设计,一致性哈希,BloomFilter等技术是亮点。 目录
1. 在Ubuntu中环境准备Cassandra是基于Java开发的NoSQL数据库软件,Cassandra没有提供Windows系统安装版本。我在这里也只介绍Cassandra在Linux Ubuntu系统中的安装。 由于Cassandra是用Java开发的,因此我们需要先安装好Java的环境,Java的安装请参考文章:在Ubuntu中安装Java(JDK) Cassandra没有提供apt的软件源安装,我们需要自己去官方网络下载Cassandra软件包进行安装。Cassandra下载页:http://cassandra.apache.org/download/ 下载Cassandra时,发现cassandra有两个版本在并行发布。因此我们有2种选择,最新2.0分支的版本2.0.6(2014-03-10发布);或者1.2分支的版本1.2.15(2014-02-07)。 由于我不清楚2.0分支,就底有哪些改进;所以本文将以1.2分支1.2.15版本为例,进行单机的安装和配置。 系统环境:
2. 下载cassandra软件包下载cassandra # 1.2.15版本下载 ~ wget http://apache.dataguru.cn/cassandra/1.2.15/apache-cassandra-1.2.15-bin.tar.gz # 解压软件包 ~ tar xvf apache-cassandra-1.2.15-bin.tar.gz # 查看文件和目录 ~ tree -L 2 . ├── apache-cassandra-1.2.15 │ ├── bin │ ├── CHANGES.txt │ ├── conf │ ├── interface │ ├── javadoc │ ├── lib │ ├── LICENSE.txt │ ├── NEWS.txt │ ├── NOTICE.txt │ ├── pylib │ ├── README.txt │ └── tools ├── apache-cassandra-1.2.15-bin.tar.gz # 对Cassandra解压目录改名 ~ mv apache-cassandra-1.2.15/ cassandra1215 # 进行目录 ~ cd cassandra1215/ 3 配置Cassandra设置cassandra数据目录
用vi打开cassandra的配置文件cassandra.yaml ~ vi 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 conan:conan /var/lib/cassandra ~ sudo chown -R conan:conan /var/log/cassandra/ # 相看目录权限 ~ ll /var/lib/cassandra drwxr-xr-x 2 conan conan 4096 3月 22 06:23 commitlog/ drwxr-xr-x 2 conan conan 4096 3月 22 06:23 data/ drwxr-xr-x 2 conan conan 4096 3月 22 06:23 saved_caches/ 4 设置环境变量~ sudo vi /etc/environment CASSANDRA_HOME=/home/conan/tookit/cassandra1215 # 让环境变量生效 ~ . /etc/environment #查看环境变量 ~ echo $CASSANDRA_HOME /home/conan/tookit/cassandra1215 5 启动cassandra服务器通过命令,启动cassandra服务器 #注:-f参数是绑定到console,不加-f则是后台启动。 ~ bin/cassandra INFO 06:28:08,777 Logging initialized INFO 06:28:08,795 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.6.0_45 INFO 06:28:08,799 Heap size: 2051014656/2051014656 INFO 06:28:08,799 Classpath: bin/../conf:bin/../build/classes/main:bin/../build/classes/thrift:bin/../lib/antlr-3.2.jar:bin/../lib/apache-cassandra-1.2.15.jar:bin/../lib/apache-cassandra-clientutil-1.2.15.jar:bin/../lib/apache-cassandra-thrift-1.2.15.jar:bin/../lib/avro-1.4.0-fixes.jar:bin/../lib/avro-1.4.0-sources-fixes.jar:bin/../lib/commons-cli-1.1.jar:bin/../lib/commons-codec-1.2.jar:bin/../lib/commons-lang-2.6.jar:bin/../lib/compress-lzf-0.8.4.jar:bin/../lib/concurrentlinkedhashmap-lru-1.3.jar:bin/../lib/guava-13.0.1.jar:bin/../lib/high-scale-lib-1.1.2.jar:bin/../lib/jackson-core-asl-1.9.2.jar:bin/../lib/jackson-mapper-asl-1.9.2.jar:bin/../lib/jamm-0.2.5.jar:bin/../lib/jbcrypt-0.3m.jar:bin/../lib/jline-1.0.jar:bin/../lib/json-simple-1.1.jar:bin/../lib/libthrift-0.7.0.jar:bin/../lib/log4j-1.2.16.jar:bin/../lib/lz4-1.1.0.jar:bin/../lib/metrics-core-2.2.0.jar:bin/../lib/netty-3.6.6.Final.jar:bin/../lib/servlet-api-2.5-20081211.jar:bin/../lib/slf4j-api-1.7.2.jar:bin/../lib/slf4j-log4j12-1.7.2.jar:bin/../lib/snakeyaml-1.6.jar:bin/../lib/snappy-java-1.0.5.jar:bin/../lib/snaptree-0.1.jar:bin/../lib/jamm-0.2.5.jar INFO 06:28:08,801 JNA not found. Native methods will be disabled. INFO 06:28:08,813 Loading settings from file:/home/conan/tookit/cassandra1215/conf/cassandra.yaml // 省略日志 查看cassandra系统进程 # 查看cassandra系统进程 ~ ps -axu|grep cassandra conan 5983 18.1 2.1 4499456 172832 pts/1 Sl 06:31 0:05 java -ea -javaagent:bin/../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1996M -Xmx1996M -Xmn400M -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -Djava.net.preferIPv4Stack=true -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dlog4j.configuration=log4j-server.properties -Dlog4j.defaultInitOverride=true -cp bin/../conf:bin/../build/classes/main:bin/../build/classes/thrift:bin/../lib/antlr-3.2.jar:bin/../lib/apache-cassandra-1.2.15.jar:bin/../lib/apache-cassandra-clientutil-1.2.15.jar:bin/../lib/apache-cassandra-thrift-1.2.15.jar:bin/../lib/avro-1.4.0-fixes.jar:bin/../lib/avro-1.4.0-sources-fixes.jar:bin/../lib/commons-cli-1.1.jar:bin/../lib/commons-codec-1.2.jar:bin/../lib/commons-lang-2.6.jar:bin/../lib/compress-lzf-0.8.4.jar:bin/../lib/concurrentlinkedhashmap-lru-1.3.jar:bin/../lib/guava-13.0.1.jar:bin/../lib/high-scale-lib-1.1.2.jar:bin/../lib/jackson-core-asl-1.9.2.jar:bin/../lib/jackson-mapper-asl-1.9.2.jar:bin/../lib/jamm-0.2.5.jar:bin/../lib/jbcrypt-0.3m.jar:bin/../lib/jline-1.0.jar:bin/../lib/json-simple-1.1.jar:bin/../lib/libthrift-0.7.0.jar:bin/../lib/log4j-1.2.16.jar:bin/../lib/lz4-1.1.0.jar:bin/../lib/metrics-core-2.2.0.jar:bin/../lib/netty-3.6.6.Final.jar:bin/../lib/servlet-api-2.5-20081211.jar:bin/../lib/slf4j-api-1.7.2.jar:bin/../lib/slf4j-log4j12-1.7.2.jar:bin/../lib/snakeyaml-1.6.jar:bin/../lib/snappy-java-1.0.5.jar:bin/../lib/snaptree-0.1.jar org.apache.cassandra.service.CassandraDaemon # 查看系统端口 ~ netstat -nlt|grep 9160 tcp 0 0 127.0.0.1:9160 0.0.0.0:* LISTEN 6 用客户端访问cassandra通过客户端程序访问Cassandra服务器 ~ bin/cassandra-cli Connected to: "Test Cluster" on 127.0.0.1/9160 Welcome to Cassandra CLI version 1.2.15 Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit. # 查看命令行帮助 [default@unknown] ? Getting around: ? Display this help. help; Display this help. help 单节的Cassandra,我们已经成功能安装在Linux Ubuntu系统中。 (责任编辑:IT) |