Redis3.2 Cluster

1. download redis 3.2

2. make PREFIX=/usr/local/redis/ install

3. 拷贝配置文件到安装文件 cp /usr/soft/redis-3.0.7/redis.conf  /usr/local/redis/bin/

4. 安装完后, 只有BIN文件夹,

5. yum install ruby
   yum install rubygems
   redis 3 as ruby version 1.9.3

   https://leonard.io/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/


   download redis3.0.gem
  
   gem install /usr/local/redis-3.0.0.gem

6. 建立, 7000, 7001, 8000, 8001,9000,9001 六个文件夹

7. 讲单个安装成功的BIN文件夹拷贝到上述文件夹

8. 修改各个文件夹的redis.conf, 修改IP地址, 端口号, node

bin ip
cluster-enabled yes
cluster-config-file nodes-7000.conf

9. 后台启动六个实例

./7000/bin/redis-server ./7000/bin/redis.conf &
./7001/bin/redis-server ./7001/bin/redis.conf &

./9001/bin/redis-server ./9001/bin/redis.conf &

9. 拷贝redis-trib.rb

10 ./redis-trib.rb create --replicas 1 192.168.24.2:7000 192.168.24.2:7001 192.168.24.2:8000 192.168.24.2:8001 192.168.24.2:9000  192.168.24.2:9001


Adding replica 192.168.24.2:8001 to 192.168.24.2:7000
Adding replica 192.168.24.2:9000 to 192.168.24.2:7001
Adding replica 192.168.24.2:9001 to 192.168.24.2:8000
M: f6ea3bbef16503d8549a469e40d4e0081a512676 192.168.24.2:7000
   slots:0-5460 (5461 slots) master
M: ff3c32d5262d58c64f9ba08232a7adb6c7bd20ca 192.168.24.2:7001
   slots:5461-10922 (5462 slots) master
M: 7905678084be3563ce45c70010013fbc70b42ed2 192.168.24.2:8000
   slots:10923-16383 (5461 slots) master
S: 960400d6c464f4fe5f5f11fc5d9a118ced3013b9 192.168.24.2:8001
   replicates f6ea3bbef16503d8549a469e40d4e0081a512676
S: 28bcb88ca5f5dae73dff694db06dd702a8432f37 192.168.24.2:9000
   replicates ff3c32d5262d58c64f9ba08232a7adb6c7bd20ca
S: e06b00683702b67fd0e6b72f83069a02a708cfc1 192.168.24.2:9001
   replicates 7905678084be3563ce45c70010013fbc70b42ed2

11. 登录到集群

./7000/bin/redis-cli -h 192.168.24.2 -p 7000 -c

   -c 表示连接到集群

   测试, ping
   pong

   查看集群信息
   cluster info

12 添加主节点

./redis-trib.rb add-node  192.168.198.130:7007 192.168.198.130:7001
        重新分配槽数量
./redis-trib.rb reshard 192.168.198.130:7001(连接集群中任意一个可用结点都行)

13. 添加从节点

./redis-trib.rb add-node --slave --master-id db786026ed607786d6db1aaab94fd73d1ac3c8f4  192.168.198.130:7008 192.168.198.130:7001
        重新分配槽数量
./redis-trib.rb reshard 192.168.198.130:7001(连接集群中任意一个可用结点都行)


cankaowenzhang

http://www.cnblogs.com/mouseIT/p/5288204.html



你可能感兴趣的:(Redis3.2 Cluster)