首先从Github上克隆 riak-dev-cluster
工具, 该工具创建的只是一个测试集群, 主要用于在开发中进行测试, 不建议在产品环境中使用.
1.根据 Open File Limits 设置进程对文件的打开数限制.
2.克隆参仓库
$ git clone git://github.com/basho/riak-dev-cluster.git $ cd riak-dev-cluster
3.运行 rake bootstrap
配置,启动集群
rake bootstrap
4.显示集群成员节点的状态
➜ riak-dev-cluster git:(master) ✗ rake member_status riak2/bin/riak-admin member-status ================================= Membership ================================== Status Ring Pending Node ------------------------------------------------------------------------------- valid 25.0% -- 'riak1@127.0.0.1' valid 18.8% -- 'riak2@127.0.0.1' valid 18.8% -- 'riak3@127.0.0.1' valid 18.8% -- 'riak4@127.0.0.1' valid 18.8% -- 'riak5@127.0.0.1' ------------------------------------------------------------------------------- Valid:5 / Leaving:0 / Exiting:0 / Joining:0 / Down:0
该项目包含多个 rake
任务用于与Riak集群进行交互, 包括:
启动集群中的所有节点
rake start
首先运行 rake stop
停止所有节点并清除所有数据, 然后删除目录
rake clear
重启集群中的所有节点, 先运行 rake stop
然后运行 rake start
rake restart
把节点加入到集群(仅需要一次)
➜ riak-dev-cluster git:(master) ✗ rake join ./riak2/bin/riak-admin join -f riak1@127.0.0.1 Failed: This node is already a member of a cluster ./riak3/bin/riak-admin join -f riak1@127.0.0.1 Failed: This node is already a member of a cluster ./riak4/bin/riak-admin join -f riak1@127.0.0.1 Failed: This node is already a member of a cluster ./riak5/bin/riak-admin join -f riak1@127.0.0.1 Failed: This node is already a member of a cluster
➜ riak-dev-cluster git:(master) ✗ rake rake -T rake bootstrap # install, start, and join riak nodes rake clear # clear data from all riak nodes rake counter_bucket # set up counters bucket-type rake install # install riak rake join # join riak nodes (only needed once) rake map_bucket # set up maps bucket-type rake member_status # riak-admin member-status rake ping # ping all riak nodes rake restart # restart all riak nodes rake ring_status # riak-admin ring-status rake set_bucket # set up sets bucket-type rake start # start all riak nodes rake status # riak-admin status rake stop # stop all riak nodes rake test # riak-admin test