注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Oracle、MySQL资料及经验

.

 
 
 

日志

 
 

redis cluster 删除节点  

2016-07-29 17:49:22|  分类: hadoop与nosql |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
给之前的四对主从节点的redis cluster 删除一个主从节点

由于各种原因,例如服务器更换或业务压力不大,集群可能也需要缩容,即删除节点。

1、迁移这个节点的slot到其他节点(有slot的节点是不可以直接下线的)
语法:  reshard         host:port
                  --slots <arg>
                  --yes
                  --to <arg>
                  --from <arg>
[root@server1 ~]# redis-trib.rb reshard 10.1.20.33:6300  --连接任意主节点
Connecting to node 10.1.20.38:7300: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.38:7301: OK
Connecting to node 10.1.20.33:6301: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.33:6300: OK
>>> Performing Cluster Check (using node 10.1.20.38:7300)
M: 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
S: a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301
   slots: (0 slots) slave
   replicates 3fc4390e9f13a5555ef5055df056c5966661638c
S: a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301
   slots: (0 slots) slave
   replicates ec59102a299531c9e4f7717953823804f1d742d2
M: 3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 5823180fc82e4765aaad8497a53ea2baba11b4c9 10.1.20.38:7301
   slots: (0 slots) slave
   replicates 10eb5ee502bc5ebfdb29d3d021532eb436150ebf
S: 94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301
   slots: (0 slots) slave
   replicates 4868d433cd4db8e76e9d4b83ee77f623f93bfce8
M: ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
M: 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300
   slots:12288-16383 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 4096  --填写这个节点上有多少个slot,通过cluster nodes命令获得
What is the receiving node ID? 3fc4390e9f13a5555ef5055df056c5966661638c  --接收slot的主节点ID,只能有一个接收ID,要想平均分不到3个节点上,需要执行本步骤3次
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:10eb5ee502bc5ebfdb29d3d021532eb436150ebf   --要下线节点的主ID
Source node #2:done
。。。。。。
Do you want to proceed with the proposed reshard plan (yes/no)? yes


2、查看10.1.20.38:7302这个maser上已经没有slot了
之前:
10.1.20.33:6300> cluster nodes
5823180fc82e4765aaad8497a53ea2baba11b4c9 10.1.20.38:7301 slave 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 0 1469781938695 7 connected
10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300 master - 0 1469781935628 7 connected 0-1364 5461-6826 10923-12287

现在:
10.1.20.33:6300> cluster nodes
5823180fc82e4765aaad8497a53ea2baba11b4c9 10.1.20.38:7301 slave 10eb5ee502bc5ebfdb29d3d021532eb436150ebf 0 1469784804186 7 connected
10eb5ee502bc5ebfdb29d3d021532eb436150ebf 10.1.20.38:7300 master - 0 1469784804391 7 connected


3、下线slave节点
语法:  del-node        host:port node_id
[root@server1 ~]# redis-trib.rb del-node 10.1.20.38:7301 5823180fc82e4765aaad8497a53ea2baba11b4c9
>>> Removing node 5823180fc82e4765aaad8497a53ea2baba11b4c9 from cluster 10.1.20.38:7301
Connecting to node 10.1.20.38:7301: OK
Connecting to node 10.1.20.33:6300: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.33:6301: OK
Connecting to node 10.1.20.38:7300: OK
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.   


4、下线master节点
[root@server1 ~]# redis-trib.rb del-node 10.1.20.38:7300 10eb5ee502bc5ebfdb29d3d021532eb436150ebf
>>> Removing node 10eb5ee502bc5ebfdb29d3d021532eb436150ebf from cluster 10.1.20.38:7300
Connecting to node 10.1.20.38:7300: OK
Connecting to node 10.1.20.38:6301: OK
Connecting to node 10.1.20.35:6301: OK
Connecting to node 10.1.20.35:6300: OK
Connecting to node 10.1.20.33:6301: OK
Connecting to node 10.1.20.38:6300: OK
Connecting to node 10.1.20.33:6300: OK
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.


5、 验证已删除
10.1.20.33:6300> cluster nodes
ec59102a299531c9e4f7717953823804f1d742d2 10.1.20.38:6300 master - 0 1469785199467 3 connected 2730-5460
3fc4390e9f13a5555ef5055df056c5966661638c 10.1.20.35:6300 master - 0 1469785200487 8 connected 0-2729 5461-13652
a082694077593ae517fa92ba28eb6640ee448576 10.1.20.35:6301 slave ec59102a299531c9e4f7717953823804f1d742d2 0 1469785194360 5 connected
a9e4a28842682363abdbfa4e21cb5b48b69b5355 10.1.20.38:6301 slave 3fc4390e9f13a5555ef5055df056c5966661638c 0 1469785197423 8 connected
4868d433cd4db8e76e9d4b83ee77f623f93bfce8 10.1.20.33:6300 myself,master - 0 0 1 connected 13653-16383
94827af28db9344a233e5598d4a22f2a12c68193 10.1.20.33:6301 slave 4868d433cd4db8e76e9d4b83ee77f623f93bfce8 0 1469785196397 4 connected


6、下线时,需要下线的库也被关闭了
[root@server2 ~]# ps -ef | grep 730
root      5083  2236  0 17:40 pts/0    00:00:00 grep 730
[root@server2 ~]# 
  评论这张
 
阅读(73)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017