2013年12月13日 星期五

[研究] Apache Cassandra 2.0.3 安裝 (CentOS 6.5 x64)

[研究] Apache Cassandra 2.0.3 安裝 (CentOS 6.5 x64)

2013-12-14
官方網站
http://cassandra.apache.org/

安裝參考
http://wiki.apache.org/cassandra/GettingStarted

下載
http://cassandra.apache.org/download/
http://apache.stu.edu.tw/cassandra/2.0.3/apache-cassandra-2.0.3-bin.tar.gz

需要 Java 7,建議 Oracle/Sun JVM,但 OpenJDK 和 IBM JVM 也可以用

設定檔為 conf/cassandra.yaml
資料庫存放在 /var/lib/cassandra/data/
logs 在 /var/log/cassandra/.

(一) 單一節點安裝

setenforce 0
service iptables stop

# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin"  -O  jdk-6u45-linux-x64.bin

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jre-7u45-linux-x64.rpm"  -O  jre-7u45-linux-x64.rpm

# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm"  -O  jdk-7u45-linux-x64.rpm

rpm -ivh jre-7u45-linux-x64.rpm
export JAVA_HOME=/usr/java/jre1.7.0_45/
alternatives  --install  /usr/bin/java java  /usr/java/jre1.7.0_45/bin/java  100
alternatives --config java

wget http://apache.stu.edu.tw/cassandra/2.0.3/apache-cassandra-2.0.3-bin.tar.gz
tar zxvf apache-cassandra-2.0.3-bin.tar.gz -C /usr/local

sudo mkdir -p /var/log/cassandra
sudo chown -R `whoami` /var/log/cassandra
sudo mkdir -p /var/lib/cassandra
sudo chown -R `whoami` /var/lib/cassandra

#啟動
/usr/local/apache-cassandra-2.0.3/bin/cassandra

交談命令介面
/usr/local/apache-cassandra-2.0.3/bin/cassandra-cli



(二) 多節點安裝

假設兩台電腦 IP 分別 192.168.128.101 和 192.168.128.102
都先照單節點安裝,測試成功後,把兩台的 cassandra 都停止

停止 Cassandra,找出 PID 用 kill -9 指令刪除

ps aux | grep cassandra
kill -9  找到的PID

或直接用下面命令

kill `ps aux |  fgrep  $USER | grep cassandra | grep -v 'grep' | awk '{print $2}'`

編輯設定檔案

vi /usr/local/apache-cassandra-2.0.3/conf/cassandra.yaml


- seeds: "127.0.0.1"
改為
- seeds: "192.168.128.101,192.168.128.102"
(兩台都這樣改,把兩台的 IP 放入 seeds 值中)


listen_address: localhost

改為自己的 IP
第1台改為
listen_address: 192.168.128.101

第2台改為
listen_address: 192.168.128.102


兩台都啟動 Cassandra
/usr/local/apache-cassandra-2.0.3/bin/cassandra

確認執行成功
[root@localhost ~]# ps aux | grep cassandra
root     28213  1.3 18.4 1517136 187176 pts/1  Sl   06:12   0:07 /usr/java/jre1.7.0_45//bin/java -ea -javaagent:/usr/local/apache-cassandra-2.0.3/bin/../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms494M -Xmx494M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseTLAB -XX:+UseCondCardMark -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 /usr/local/apache-cassandra-2.0.3/bin/../conf:/usr/local/apache-cassandra-2.0.3/bin/../build/classes/main:/usr/local/apache-cassandra-2.0.3/bin/../build/classes/thrift:/usr/local/apache-cassandra-2.0.3/bin/../lib/antlr-3.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/apache-cassandra-2.0.3.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/apache-cassandra-clientutil-2.0.3.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/apache-cassandra-thrift-2.0.3.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/commons-cli-1.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/commons-codec-1.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/commons-lang3-3.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/compress-lzf-0.8.4.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/concurrentlinkedhashmap-lru-1.3.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/disruptor-3.0.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/guava-15.0.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/high-scale-lib-1.1.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/jackson-core-asl-1.9.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/jackson-mapper-asl-1.9.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/jamm-0.2.5.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/jbcrypt-0.3m.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/jline-1.0.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/json-simple-1.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/libthrift-0.9.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/log4j-1.2.16.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/lz4-1.2.0.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/metrics-core-2.2.0.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/netty-3.6.6.Final.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/reporter-config-2.1.0.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/servlet-api-2.5-20081211.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/slf4j-api-1.7.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/slf4j-log4j12-1.7.2.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/snakeyaml-1.11.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/snappy-java-1.0.5.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/snaptree-0.1.jar:/usr/local/apache-cassandra-2.0.3/bin/../lib/thrift-server-0.3.2.jar org.apache.cassandra.service.CassandraDaemon
root     28736  0.0  0.0 103252   840 pts/1    S+   06:22   0:00 grep cassandra
[root@localhost ~]#

檢視開了那些 port
[root@localhost ~]# netstat -anp | grep LISTEN | grep java
tcp        0      0 0.0.0.0:43853               0.0.0.0:*                   LISTEN      28213/java
tcp        0      0 127.0.0.1:9042              0.0.0.0:*                   LISTEN      28213/java
tcp        0      0 192.168.128.101:7000        0.0.0.0:*                   LISTEN      28213/java
tcp        0      0 0.0.0.0:7199                0.0.0.0:*                   LISTEN      28213/java
tcp        0      0 0.0.0.0:42144               0.0.0.0:*                   LISTEN      28213/java
tcp        0      0 127.0.0.1:9160              0.0.0.0:*                   LISTEN      28213/java
[root@localhost ~]#


測試,結果應該會列出兩台主機

1.2.8版使用下面指令,這在2.0.3版會報錯
[root@localhost ~]# /usr/local/apache-cassandra-2.0.3/bin/nodetool -h localhost ring
....
ERROR 06:28:33,470 Unable to initialize MemoryMeter (jamm not specified as javaagent).  This means Cassandra will be unable to measure object sizes accurately and may consequently OOM.
  Warning: "nodetool ring" is used to output all the tokens of a node.
  To view status related info of a node use "nodetool status" instead.

2.0.3 版指令要這樣用
[root@localhost ~]# /usr/local/apache-cassandra-2.0.3/bin/nodetool status

[root@localhost ~]# /usr/local/apache-cassandra-2.0.3/bin/nodetool -host 127.0.0.1 -p 7199 status
xss =  -ea -javaagent:/usr/local/apache-cassandra-2.0.3/bin/../lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms494M -Xmx494M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -Xss256k
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address          Load       Tokens  Owns (effective)  Host ID                               Rack
UN  192.168.128.101  74.87 KB   256     100.0%            4593d333-9bde-4811-9349-2b111e203dbb  rack1
UN  192.168.128.102  55.09 KB   256     100.0%            f9abc901-fc74-48d9-adf3-14e48f9183ea  rack1
[root@localhost ~]#

(完)

[研究] Apache Cassandra 2.0.3 安裝 (CentOS 6.5 x64)
http://shaurong.blogspot.tw/2013/12/apache-cassandra-203-centos-65-x64.html

[研究] Cassandra 1.2.8 Cluster 架設 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/07/cassandra-128-cluster-centos-64-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?t=80053

[研究] Cassandra 0.7.0 Cluster 架設 (CentOS 5.5x86/Fedora 14x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19351

[研究][問題] Cassandra + PHP + thrift 安裝(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19333

[研究][問題] Cassandra + PHP + thrift 安裝(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19332

[研究] Apache Cassandra 0.7.0 (NoSQL)卡珊多拉資料庫 安裝與使用
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19309

(完)

沒有留言:

張貼留言