Redis-Cli Resharding

Resharding 指的是把某个 slot 的所有权从一个 master 转移到另一个 master。

交互方式

进入任何一个 master:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
redis-cli --user <user> --pass <pass> \
  --cluster reshard <any-master-ip>:<any-master-port>
How many slots do you want to move (from 1 to 16384)? 
What is the receiving node ID?
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: 
Ready to move <number of slots> slots.
  Source nodes:
    M: <node-id> <host:ip>
       slots: <slots> (<number of slots> slots) master
  Destination node:
    M: node-id host:ip
       slots: <slots> (<number of slots> slots) master
Resharding plan:
  Moving slot <slot> from <node-id>
  Moving slot <slot> from <node-id>
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot <slot> from <host>:<ip> to <host>:<ip>: .
Moving slot <slot> from <host>:<ip> to <host>:<ip>: ...
Moving slot <slot> from <host>:<ip> to <host>:<ip>: 
Moving slot <slot> from <host>:<ip> to <host>:<ip>: ..

参考文档:

脚本方式

进入任何一个 master:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
redis-cli --user <user> --pass <pass> \
  --cluster reshard <any-master-ip>:<any-master-port> \
  --cluster-from <src-master-id>/all \
  --cluster-to <dst-master-id> \
  --cluster-slots <number of slots> \
  --cluster-yes

Moving slot <slot> from <host>:<ip> to <host>:<ip>: .
Moving slot <slot> from <host>:<ip> to <host>:<ip>: ...
Moving slot <slot> from <host>:<ip> to <host>:<ip>: 
Moving slot <slot> from <host>:<ip> to <host>:<ip>: ..

参考文档:

版权

评论