Reputation: 9
I Create a redis cluster:
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 (in slot 3300)
//cluster keyslot g581 (in slot 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
now Can I write data into slot 3300
Upvotes: 0
Views: 1666
Reputation: 3305
When you want to transfer redis slot in a cluster, steps below are requried:
use two "cluster setslot
" commands to set source node migrating and destination node importing
CLUSTER SETSLOT IMPORTING
CLUSTER SETSLOT MIGRATING
use CLUSTER GETKEYSINSLOT
to get all keys in this slot, and for each slot, use MIGRATE
to transfer data.
use CLUSTER SETSLOT <slot> NODE <node_id>
to transfer the slot to new node officially.
So it's not a good option to handle redis slot yourself, better use redis-trib to do the managing.
Upvotes: 1