码迷,mamicode.com
首页 > 其他好文 > 详细

redis 3.2.5 cluster 添加节点和指派槽位

时间:2016-12-07 14:40:44      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:redis 3.2.5 cluster 添加节点和指派槽位

一、环境描述


DB:redis 3.2.5

OS:centos 6.6_x64


IP:192.168.80.131/132/133 

PORT:7000


redis 集群模式,服务已启动


二、具体操作


1.三个独立的集群节点,每个集群只有自己一个节点

[root@mysql-131 ~]# redis-cli -c -p 7000

127.0.0.1:7000> cluster info

cluster_state:ok

cluster_slots_assigned:16384

cluster_slots_ok:16384

cluster_slots_pfail:0

cluster_slots_fail:0

cluster_known_nodes:8

cluster_size:3

cluster_current_epoch:11

cluster_my_epoch:9

cluster_stats_messages_sent:156029

cluster_stats_messages_received:155663

127.0.0.1:7000> cluster reset


2.创建3节点集群

127.0.0.1:7000> cluster meet 192.168.80.132 7000

OK

127.0.0.1:7000> cluster meet 192.168.80.133 7000

OK

127.0.0.1:7000> cluster nodes

dd2dae9872c9eb58860c5fe0ae810e34fcbe4e83 192.168.80.132:7000 master - 0 1480991778893 2 connected

a03c14558ce425fd0fe64b611eb02fdb46db2fd4 192.168.80.133:7000 master - 0 1480991777891 11 connected

2591d73e867a298852f6e4e892ced37dac7c9034 192.168.80.131:7000 myself,master - 0 0 1 connected

127.0.0.1:7000> 


2.指派slots

192.168.80.131执行

#for i in {0..5000}

do

redis-cli -c -p 7000 cluster addslots $i 

done


192.168.80.132执行

#for i in {5001..10000}

do

redis-cli -c -p 7000 cluster addslots $i 

done


192.168.80.133执行

#for i in {10001..16383}

do

redis-cli -c -p 7000 cluster addslots $i 

done



3.查看集群状态ok

127.0.0.1:7000> cluster info

cluster_state:ok

cluster_slots_assigned:16384

cluster_slots_ok:16384

cluster_slots_pfail:0

cluster_slots_fail:0

cluster_known_nodes:3

cluster_size:3

cluster_current_epoch:12

cluster_my_epoch:1

cluster_stats_messages_sent:187477

cluster_stats_messages_received:192003


127.0.0.1:7000> cluster slots

1) 1) (integer) 5001

   2) (integer) 10000

   3) 1) "192.168.80.132"

      2) (integer) 7000

      3) "dd2dae9872c9eb58860c5fe0ae810e34fcbe4e83"

2) 1) (integer) 10001

   2) (integer) 16383

   3) 1) "192.168.80.133"

      2) (integer) 7000

      3) "a03c14558ce425fd0fe64b611eb02fdb46db2fd4"

3) 1) (integer) 0

   2) (integer) 5000

   3) 1) "192.168.80.131"

      2) (integer) 7000

      3) "2591d73e867a298852f6e4e892ced37dac7c9034"

127.0.0.1:7000> 


4.验证写入

127.0.0.1:7000> set msg "hello world"

-> Redirected to slot [6257] located at 192.168.80.132:7000

OK

192.168.80.132:7000> cluster keyslot msg

(integer) 6257

192.168.80.132:7000> get msg

"hello world"

192.168.80.132:7000> 


本文出自 “dba003” 博客,请务必保留此出处http://dba003.blog.51cto.com/12318731/1880265

redis 3.2.5 cluster 添加节点和指派槽位

标签:redis 3.2.5 cluster 添加节点和指派槽位

原文地址:http://dba003.blog.51cto.com/12318731/1880265

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!