• redis cluster集群动态伸缩--删除主从节点


    目标:从集群中剔除一组主从(5007,5008)

    经过上一节增加5007,5008主从服务节点后,目前集群的情况是这样的:

    b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573003356000 3 connected
    1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573003352829 3 connected 11089-16383
    fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573003356842 2 connected
    b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573003355000 2 connected 5628-10922
    d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 master - 0 1573003354837 1 connected 166-5460
    9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573003357846 1 connected
    63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573003356000 7 connected 0-165 5461-5627 10923-11088
    d3a9de370962873d17f1124bcf9ac166cc6ba950 192.168.8.196:5008@15008 myself,slave 63aa476d990dfa9f5f40eeeaa0315e7f9948554d 0 1573003350000 0 connected
    
    序号master nodeslave node
    1 192.168.8.196:5001 192.168.8.196:5004
    2 192.168.8.196:5002 192.168.8.196:5005
    3 192.168.8.196:5003 192.168.8.196:5006
    4 192.168.8.196:5007 192.168.8.196:5008

    开始实施:
    1.先移除 192.168.8.196:5008 从节点

    redis-cli --cluster del-node 192.168.8.196:5008 d3a9de370962873d17f1124bcf9ac166cc6ba950

    >> Removing node d3a9de370962873d17f1124bcf9ac166cc6ba950 from cluster 192.168.8.196:5008
    >> Sending CLUSTER FORGET messages to the cluster...
    >> SHUTDOWN the node.
    >>

    此时,192.168.8.196:5008 从节点已被删除。

    192.168.8.196:5001> cluster nodes
    b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004309001 6 connected
    9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004310000 4 connected
    1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004311007 3 connected 11089-16383
    b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004307000 2 connected 5628-10922
    63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573004307000 7 connected 0-165 5461-5627 10923-11088
    fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004310004 5 connected
    d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004308000 1 connected 166-5460
    
    1. 对192.168.8.196:5007 主节点从新分片,将5007上的分片转移到其他节点

      $ redis-cli --cluster reshard 192.168.8.196:5007

    会出现一下问答对话项

    #需要移动数据槽的数量
    How many slots do you want to move (from 1 to 16384)? 500
    #需要接受数据槽的主节点ID,这里我们填写5001号主服务节点ID
    What is the receiving node ID? d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2
    #填写数据槽来源节点
    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: 63aa476d990dfa9f5f40eeeaa0315e7f9948554d
    Source node #2: done
    

    执行结束后,5007号主节点上的数据槽已经被转移到5001号主节点上。此时,5007上没有任何数据槽了。

    b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004510000 6 connected
    9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004510589 8 connected
    1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004508000 3 connected 11089-16383
    b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004510000 2 connected 5628-10922
    63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573004508000 7 connected
    fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004511594 5 connected
    d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004509000 8 connected 0-5627 10923-11088
    

    3.最后一步,剔除192.168.8.196:5007

    $ redis-cli --cluster del-node 192.168.8.196:5007 63aa476d990dfa9f5f40eeeaa0315e7f9948554d

    >>> Removing node 63aa476d990dfa9f5f40eeeaa0315e7f9948554d from cluster 192.168.8.196:5007
    >>> Sending CLUSTER FORGET messages to the cluster...
    >>> SHUTDOWN the node.

    4.5007,5008主从节点已被剔除,大功告成。

    192.168.8.196:5001> cluster nodes
    b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004592840 6 connected
    9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004591000 8 connected
    1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004591000 3 connected 11089-16383
    b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004591838 2 connected 5628-10922
    fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004591000 5 connected
    d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004589000 8 connec
  • 相关阅读:
    微信开发者工具打开一直处于初始化应用通信能力界面的解决办法
    vuex学习笔记
    生产环境下的log 在正式环境下隐藏log
    el-table 表头添加下拉筛选框 附带输入过滤
    element-ui table type=“expand“ 无内容时 不可展开
    窗口移到了电脑桌面边缘外拖不回来解决办法
    yarn的基础语法:yarn安装完vue cli3后提示不是内部命令
    nodejs npm错误Error:UNKNOWN:unknown error,mkdir 'D:Develop odejs ode_global'at Error(可行)
    vue-cli 更新遇到的问题,卸载不掉旧版本2.9.6(可行)
    vue基础——命名路由
  • 原文地址:https://www.cnblogs.com/aiaitie/p/11806230.html
Copyright © 2020-2023  润新知