Happy Apache Cassandra 1: Setup

Cassandra Setup

Setup Cassandra

GettingStarted

Single Node

  • Download
  • tar xvf cassandra-*.tar.gz
  • conf/cassandra.yaml
    data_file_directories: ./data
    commitlog_directory: ./commitlog
    saved_caches_directory: ./saved_caches
    cluster_name: 'cassandra 1.0 Cluster'
  • conf/log4j-server.properties
    log4j.appender.R.File=./log/system.log
  • mkdir data|commitlog|saved_caches|log
  • Start up
    nohup bin/cassandra -f &
  • Shut down
    kill -9 `ps -ef | grep cassandra | awk '{print $2}'`
  • Node ring
    bin/nodetool -host localhost ring

Cluster

  • each node, same as above
  • conf/cassandra.yaml, comment out localhost
    #listen_address: localhost
    #rpc_address: localhost
    seed_provider:
    - seeds: "172.16.101.227,172.16.101.228"
  • a quick setup is to  copy the cassandra from the first node and clean the data/system to avoid different node uses same token
    scp -r . 172.16.101.227:/home/xnavuser/cassandra-1.0.2
    scp -r . 172.16.101.228:/home/xnavuser/cassandra-1.0.2
    rm -rf data/system

Load_balancing

Load_balancing
If you uses even node number, the address token of each node would liketo split the range equally.
If you use odd node number, you can calculate new tokens for the nodes.
Keep your node token stable after start, otherwise, data may be can notbe found.

calculate tokes

def tokens(nodes):
    for x in xrange(nodes):
        print 2 ** 127 / nodes * x

 

move node

bin/nodetool -host 172.16.101.227 move 0
bin/nodetool -host 172.16.101.228 move 34028236692093846346337460743176821145
bin/nodetool -host 172.16.101.228 move 68056473384187692692674921486353642290
bin/nodetool -host 172.16.101.228 move 102084710076281539039012382229530463435
bin/nodetool -host 172.16.101.228 move 136112946768375385385349842972707284580

balance
Address         DC          Rack        Status State   Load            Owns    Token                                       
                                                                               136112946768375385385349842972707284580     
172.16.101.227  datacenter1 rack1       Up     Normal  54.64 KB        20.00%  0                                           
172.16.101.228  datacenter1 rack1       Up     Normal  50.32 KB        20.00%  34028236692093846346337460743176821145      
172.16.101.229  datacenter1 rack1       Up     Normal  54.56 KB        20.00%  68056473384187692692674921486353642290      
172.16.101.230  datacenter1 rack1       Up     Normal  54.59 KB        20.00%  102084710076281539039012382229530463435     
172.16.101.231  datacenter1 rack1       Up     Normal  15.42 KB        20.00%  136112946768375385385349842972707284580

Monitoring

http://wiki.apache.org/cassandra/Operations#Monitoring

  • bin/cassandra-cli -h host
  • bin/nodetool -h host cfstats|tpstats
  • JMX
    • JConsole/JVisuialVM host:7199 (MBean)
    • MX4J, host:8081
      • Download mx4j-tools.jar from http://mx4j.sourceforge.net/
      • Add mx4j-tools.jar to the classpath (e.g. under lib/)
      • Start cassandra
      • Browser to http host:8081

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FireCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值