Cassandra安装配置

Standard
wget http://labs.renren.com/apache-mirror/cassandra/0.6.2/apache-cassandra-0.6.2-bin.tar.gz
tar zxvf apache-cassandra-0.6.2-bin.tar.gz
mv ./apache-cassandra-0.6.2/ /opt/cassandra/
mkdir -p /var/log/cassandra/;
mkdir -p /var/lib/cassandra/;
cd /opt/cassandra/conf/;
 
vi /etc/hosts;
  172.20.0.11 cas1
  172.20.0.12 cas2
  172.20.0.13 cas3
 
vi storage-conf.xml;
  <Seeds>
      <Seed>cas1</Seed>
      <Seed>cas2</Seed>
      <Seed>cas3</Seed>
  </Seeds>
  ...
  <ListenAddress></ListenAddress>
  ...
  <ThriftAddress>0.0.0.0</ThriftAddress>
  ...
  <ReplicationFactor>2</ReplicationFactor>
 
 
#启动Cassandra
/opt/cassandra/bin/cassandra
#停止Cassandra
pgrep -u `whoami` -f cassandra | xargs kill -9
 
#查看状态
./nodetool -host 172.20.0.11 -port 8080 info
./nodetool -host 172.20.0.12 -port 8080 info
./nodetool -host 172.20.0.13 -port 8080 info
 
/opt/cassandra/bin/nodeprobe -host 172.20.0.11 -port 8080 ring
***************************************************************
WARNING: ./nodeprobe is obsolete, use ./nodetool instead
***************************************************************
Address       Status     Load          Range                                      Ring
                                       158255313114555862951163726015274498791    
172.20.0.11   Up         1.1 KB        76956859483693548579208375882609057366     |<--|
172.20.0.12   Up         1.1 KB        126662997939550187436807835701584364141    |   |
172.20.0.13   Up         760 bytes     158255313114555862951163726015274498791    |-->|
 
#客户端读写操作
./cassandra-cli -host 172.20.0.11 -port 9160
cassandra> set Keyspace1.Standard1['user']['name']='YeMaosheng'
cassandra> quit
 
./cassandra-cli -host 172.20.0.12 -port 9160
cassandra> get Keyspace1.Standard1['user']
=> (column=6e616d65, value=YeMaosheng, timestamp=1276750744566000)
Returned 1 results.
 
#调节使用的内存大小
vi /opt/cassandra/bin/cassandra in.sh
  -Xmx1G  #默认为1G,改成你实际所需要的大小运行即可
 
#转载请注明出处 http://yemaosheng.com

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.