redis-cluster,迁移导入状态问题

时间:2018-03-26 06:23:19

标签: redis-cluster

我创建一个redis集群:

M: dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d localhost:9501
slots:5461-10922 (5462 slots) master
2 additional replica(s)

S: a375ec8221f9872f8f287bca8a67fcef701cef72 localhost:9000
slots: (0 slots) slave
replicates dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d

S: a319a75ac0ee58484e345d7996a6712335ebddf5 localhost:9001
slots: (0 slots) slave
replicates dbaf0a596c4f5a2f4ac1d9de2ed5c117f201d26d

M: 05f7d7cc87b417ad4bdf61b3877a674d54c02ef7 localhost:9002
slots:10923-16383 (5461 slots) master
1 additional replica(s)

S: 932dfde44c77d341b873bf205c3d069b236c424a localhost:9502
slots: (0 slots) slave
replicates 05f7d7cc87b417ad4bdf61b3877a674d54c02ef7

M: 69ec05cbf01c81474ea1ccf8848d3f336c99200b localhost:9500
slots:0-5460 (5461 slots) master
0 additional replica(s)

// cluster keyslot b(在3300号插槽中)

// cluster keyslot g581(在3300号插槽中)

redis-cli -h localhost -p 9500 -c

1. localhost:9500> set b 1 //b store in 9500 node
2. localhost:9500> cluter setslot 3300 migrating 9002_NODE_ID
3. localhost:9500> set g581 2 //(error) ASK 3300 localhost:9002

redis-cli -h localhost -p 9002 -c

  1. 本地主机:9002> set g581 2 //重定向到位于localhost:9500`
  2. 的插槽[3300]

    现在可以将数据写入插槽3300

1 个答案:

答案 0 :(得分:0)

如果要在群集中传输redis插槽,请执行以下步骤:

  1. 使用两个" cluster setslot"用于设置源节点迁移和目标节点导入的命令

    CLUSTER SETSLOT IMPORTING

    CLUSTER SETSLOT MIGRATING

  2. 使用CLUSTER GETKEYSINSLOT获取此广告位中的所有密钥,对于每个广告位,请使用MIGRATE传输数据。

  3. 使用CLUSTER SETSLOT <slot> NODE <node_id>正式将广告位转移到新节点。

  4. 因此,自己处理redis插槽不是一个好选择,最好使用redis-trib进行管理。

相关问题