原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg13.html

节点的移除

和节点添加一样,移除节点也有移除主节点,从节点。

1、移除主节点

移除节点使用redis-trib的del-node命令,

[plain] view plain copy  
  1. redis-trib del-node 127.0.0.1:7002  ${node-id}

127.0.0.1:7002位集群节点,node-id为要删除的主节点。 和添加节点不同,移除节点node-id是必需的,测试删除7001主节点:

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb del-node 127.0.0.1:7001 dd19221c404fb2fc4da37229de56bab755c76f2b
  2. >>> Removing node dd19221c404fb2fc4da37229de56bab755c76f2b from cluster 127.0.0.1:7002
  3. [ERR] Node 127.0.0.1:7001 is not empty! Reshard data away and try again.
  4. [root@localhost redis-cluster]#

redis cluster提示7001已经有数据了,不能够被删除,需要将他的数据转移出去,也就是和新增主节点一样需重新分片。

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb reshard 127.0.0.1:7002

执行以后会提示我们移除的大小,因为7001占用了4096个槽点

[plain] view plain copy  
  1. >>> Check for open slots...
  2. >>> Check slots coverage...
  3. [OK] All 16384 slots covered.
  4. How many slots do you want to move (from 1 to 16384)?

输入4096

提示移动的node id,填写7009的node id。(这里好像有误,应该填移动到的node id)

[plain] view plain copy  
  1. How many slots do you want to move (from 1 to 16384)? 4096
  2. What is the receiving node ID?      (接收的nodeid)

需要移动到全部主节点上还是单个主节点(这里好像有误,需要移动的的节点ID,可移动单个节点,也可移动多节点的槽位)

[plain] view plain copy  
  1. Please enter all the source node IDs.
  2. Type 'all' to use all the nodes as source nodes for the hash slots.
  3. Type 'done' once you entered all the source nodes IDs.
  4. Source node #1:

将4096个槽点移动到7009上,填写7001的node id :dd19221c404fb2fc4da37229de56bab755c76f2b

[plain] view plain copy  
  1. Source node #1:dd19221c404fb2fc4da37229de56bab755c76f2b
  2. Source node #2:done
  3. Do you want to proceed with the proposed reshard plan (yes/no)? yes

确认之后会一个一个将7001的卡槽移到到7009上。

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7009
  2. >>> Performing Cluster Check (using node 127.0.0.1:7009)
  3. M: 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009
  4. slots:0-6826,10923-12287 (8192 slots) master
  5. 3 additional replica(s)
  6. S: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
  7. slots: (0 slots) slave
  8. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  9. S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
  10. slots: (0 slots) slave
  11. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  12. M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
  13. slots:12288-16383 (4096 slots) master
  14. 1 additional replica(s)
  15. M: dd19221c404fb2fc4da37229de56bab755c76f2b 127.0.0.1:7001
  16. slots: (0 slots) master
  17. 0 additional replica(s)
  18. S: 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008
  19. slots: (0 slots) slave
  20. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  21. S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
  22. slots: (0 slots) slave
  23. replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
  24. S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
  25. slots: (0 slots) slave
  26. replicates f9886c71e98a53270f7fda961e1c5f730382d48f
  27. M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
  28. slots:6827-10922 (4096 slots) master
  29. 1 additional replica(s)
  30. [OK] All nodes agree about slots configuration.
  31. >>> Check for open slots...
  32. >>> Check slots coverage...
  33. [OK] All 16384 slots covered.
  34. [root@localhost redis-cluster]#

可以看到7001有0个卡槽,而7009有8192个卡槽。

在执行移除操作

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb del-node 127.0.0.1:7002 dd19221c404fb2fc4da37229de56bab755c76f2b
  2. >>> Removing node dd19221c404fb2fc4da37229de56bab755c76f2b from cluster 127.0.0.1:7002
  3. >>> Sending CLUSTER FORGET messages to the cluster...
  4. >>> SHUTDOWN the node.
  5. [root@localhost redis-cluster]#

已经删除了7001节点。

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7001
  2. [ERR] Sorry, can't connect to node 127.0.0.1:7001
  3. [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7009
  4. >>> Performing Cluster Check (using node 127.0.0.1:7009)
  5. M: 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009
  6. slots:0-6826,10923-12287 (8192 slots) master
  7. 3 additional replica(s)
  8. S: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
  9. slots: (0 slots) slave
  10. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  11. S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
  12. slots: (0 slots) slave
  13. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  14. M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
  15. slots:12288-16383 (4096 slots) master
  16. 1 additional replica(s)
  17. S: 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 127.0.0.1:7008
  18. slots: (0 slots) slave
  19. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
  20. S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
  21. slots: (0 slots) slave
  22. replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
  23. S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
  24. slots: (0 slots) slave
  25. replicates f9886c71e98a53270f7fda961e1c5f730382d48f
  26. M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
  27. slots:6827-10922 (4096 slots) master
  28. 1 additional replica(s)
  29. [OK] All nodes agree about slots configuration.
  30. >>> Check for open slots...
  31. >>> Check slots coverage...
  32. [OK] All 16384 slots covered.
  33. [root@localhost redis-cluster]#

可以看到7001已经连接不了;而7001的从节点7004自动分配到了7009主节点中,7009现在3个从节点。

2、移除从节点

比如删除7009的7008节点:

[plain] view plain copy  
  1. [root@localhost redis-cluster]# ./redis-trib.rb del-node 127.0.0.1:7009 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5
  2. >>> Removing node 2ab1b061c36f30ae35604e9a171ae3afdc3c87e5 from cluster 127.0.0.1:7009
  3. >>> Sending CLUSTER FORGET messages to the cluster...
  4. >>> SHUTDOWN the node.
  5. [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7008
  6. [ERR] Sorry, can't connect to node 127.0.0.1:7008
  7. [root@localhost redis-cluster]#

删除从节点比较方便,现在redis-cluster中有3个主节点,4个从节点,如下:

[plain] view plain copy  
    1. [root@localhost redis-cluster]# ./redis-trib.rb check 127.0.0.1:7009
    2. >>> Performing Cluster Check (using node 127.0.0.1:7009)
    3. M: 1f51443ede952b98724fea2a12f61fe710ab6cb1 127.0.0.1:7009
    4. slots:0-6826,10923-12287 (8192 slots) master
    5. 2 additional replica(s)
    6. S: ee3efb90e5ac0725f15238a64fc60a18a71205d7 127.0.0.1:7007
    7. slots: (0 slots) slave
    8. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
    9. S: 50ce1ea59106b4c2c6bc502593a6a7a7dabf5041 127.0.0.1:7004
    10. slots: (0 slots) slave
    11. replicates 1f51443ede952b98724fea2a12f61fe710ab6cb1
    12. M: f9886c71e98a53270f7fda961e1c5f730382d48f 127.0.0.1:7003
    13. slots:12288-16383 (4096 slots) master
    14. 1 additional replica(s)
    15. S: 1f07d76585bfab35f91ec711ac53ab4bc00f2d3a 127.0.0.1:7002
    16. slots: (0 slots) slave
    17. replicates a5db243087d8bd423b9285fa8513eddee9bb59a6
    18. S: 8bb3ede48319b46d0015440a91ab277da9353c8b 127.0.0.1:7006
    19. slots: (0 slots) slave
    20. replicates f9886c71e98a53270f7fda961e1c5f730382d48f
    21. M: a5db243087d8bd423b9285fa8513eddee9bb59a6 127.0.0.1:7005
    22. slots:6827-10922 (4096 slots) master
    23. 1 additional replica(s)
    24. [OK] All nodes agree about slots configuration.
    25. >>> Check for open slots...
    26. >>> Check slots coverage...
    27. [OK] All 16384 slots covered.
    28. [root@localhost redis-cluster]#

redis节点管理-节点的移除的更多相关文章

  1. redis节点管理-新增从节点

    原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg12.html 新增从节点 新增一个节点7008节点,使用add-node --slave命令. [pl ...

  2. redis节点管理-新增主节点

    原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg11.html 集群节点添加 节点新增包括新增主节点.从节点两种情况.以下分别做一下测试: 1.新增主节 ...

  3. docker swarm英文文档学习-7-在集群中管理节点

    Manage nodes in a swarm在集群中管理节点 List nodes列举节点 为了查看集群中的节点列表,可以在管理节点中运行docker node ls: $ docker node ...

  4. Redis集群节点扩容及其 Redis 哈希槽

    Redis 集群中内置了 16384 个哈希槽,当需要在 Redis 集群中放置一个 key-value 时,redis 先对 key 使用 crc16 算法算出一个结果,然后把结果对 16384 求 ...

  5. 在控制台启动服务器时出现:对于服务器soa1_wls, 与计算机oim1相关联的节点管理器无法访问。

    问题:在控制台启动服务器时出现:对于服务器soa1_wls, 与计算机oim1相关联的节点管理器无法访问.原因:nodemanager没有启起来解决方法: 一.对于managedServer于admi ...

  6. [转] Jenkins实战演练之Windows系统节点管理

    [前提] 通过<Jenkins实战演练之Windows服务器快速搭建>(http://my.oschina.net/iware/blog /191818)和<Jenkins实战演练之 ...

  7. [转]Jenkins使用 管理节点

    现在我们已经搭建好了基本的Jenkins环境,在这一集里,我们说一说如何管理节点. 进入“系统管理”中的“管理节点”. 创建Windos系统的奴隶节点 先创建一台安装了Win7系统的虚拟机,作为Jen ...

  8. 转:对于服务器AdminServer, 与计算机Machine-0相关联的节点管理器无法访问

    控制台启动server时报"对于服务器server-1与计算机machin<!--StartFragment -->对于服务器AdminServer, 与计算机Machine-0 ...

  9. 20151208_使用windows2012配置weblogic节点管理器

    经过实践,weblogic节点管理器的作用主要有两点: 1.可通过weblogic控制台远程控制被管server启停. 2.可以自动重启被管server的进程,并且对spring框架提供比直接启动更快 ...

随机推荐

  1. [How to] 真机调试

    1.简介 真机调试介绍. 在xcode7之前需要每年99刀的代价才能活着开发者权限并能够在真机上调试,现在如果单纯的想在真机上调是就不必花这个钱了. 2.步骤 完毕.

  2. swiper 滑动插件,小屏单个显示滑动,大屏全部显示

    var currSwiperIndex=0; function widthHandle(){ var level = widthLevel(); if(level==1){ //单个显示,滑动 if( ...

  3. Shell三剑客之sed命令

    Sed简介 Sed是Stream Editor(流编辑器)缩写,是操作.过滤和转换文本内容的强大工具,常用功能有增删改查. Sed命令执行流程 Sed语法格式 Sed [option] ‘[匹配][处 ...

  4. .NET Core、.NET Standard、Xamarin和.NET Framework对比

    近日,微软发布了.NET Core 2.0,但是开发人员中间仍然存在一些疑惑,就是.NET Core..NET Standard.Xamarin和.NET Framework有什么不同. .NET F ...

  5. python 函数内置方法short_desc

    1. 给函数设置一个文本 def action_checked(self, request): pass action_checked.short_desc = "签到" # sh ...

  6. Search in Rotated Sorted Array I&&II——二分法

    Search in Rotated Sorted Array I Suppose a sorted array is rotated at some pivot unknown to you befo ...

  7. ofbiz多表外键关联查询

    实现一:Screem.xml 中的 section 里,加 <action>, 加 get-related 实现二:在代码中使用 DynamicViewEntity对象,加入addMemb ...

  8. Centos Nodejs

    设置Nodejs环境 第二节:Installing Node.js, PM2 and Yarn on CentOS https://www.youtube.com/watch?v=XCgCjasqEF ...

  9. STL模板整理 list

    介绍: list容器是一种序列式容器,它是STL实现的双向链表,与vector相比它可以实现快速的插入和删除,但是不能够快速的随机访问. 头文件: #include <list> 构造函数 ...

  10. jdk的split 有多坑

    先看段 代码: String str = "4117|519951|长信利泰灵活配置混合型证券投资基金|长信利泰|3|3||||156|0||||||||||||||||||||{\&quo ...