I. Description of the Environment
Db:redis 3.2.5
Os:centos 6.6_x64
ip:192.168.80.131/132/133
port:7000
Redis cluster mode, service started
Second, the specific operation
1. Three separate cluster nodes, one node per cluster
[[email protected] ~]# redis-cli-c-P 7000
127.0.0.1:7000> Cluster Info
Cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
Cluster_known_nodes:8
Cluster_size:3
Cluster_current_epoch:11
Cluster_my_epoch:9
cluster_stats_messages_sent:156029
cluster_stats_messages_received:155663
127.0.0.1:7000> Cluster Reset
2. Create a 3-node cluster
127.0.0.1:7000> Cluster Meet 192.168.80.132 7000
Ok
127.0.0.1:7000> Cluster Meet 192.168.80.133 7000
Ok
127.0.0.1:7000> cluster Nodes
Dd2dae9872c9eb58860c5fe0ae810e34fcbe4e83 192.168.80.132:7000 master-0 1480991778893 2 connected
A03c14558ce425fd0fe64b611eb02fdb46db2fd4 192.168.80.133:7000 master-0 1480991777891 connected
2591d73e867a298852f6e4e892ced37dac7c9034 192.168.80.131:7000 myself,master-0 0 1 connected
127.0.0.1:7000>
2. Assigning slots
192.168.80.131 execution
#for i in {0..5000}
Do
REDIS-CLI-C-P 7000 cluster addslots $i
Done
192.168.80.132 execution
#for i in {5001..10000}
Do
REDIS-CLI-C-P 7000 cluster addslots $i
Done
192.168.80.133 execution
#for i in {10001..16383}
Do
REDIS-CLI-C-P 7000 cluster addslots $i
Done
3. View cluster status OK
127.0.0.1:7000> Cluster Info
Cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
Cluster_known_nodes:3
Cluster_size:3
Cluster_current_epoch:12
Cluster_my_epoch:1
cluster_stats_messages_sent:187477
cluster_stats_messages_received:192003
127.0.0.1:7000> Cluster Slots
1) 1) (integer) 5001
2) (integer) 10000
3) 1) "192.168.80.132"
2) (integer) 7000
3) "Dd2dae9872c9eb58860c5fe0ae810e34fcbe4e83"
2) 1) (integer) 10001
2) (integer) 16383
3) 1) "192.168.80.133"
2) (integer) 7000
3) "A03c14558ce425fd0fe64b611eb02fdb46db2fd4"
3) 1) (integer) 0
2) (integer) 5000
3) 1) "192.168.80.131"
2) (integer) 7000
3) "2591d73e867a298852f6e4e892ced37dac7c9034"
127.0.0.1:7000>
4. Verify that the Write
127.0.0.1:7000> set MSG "Hello World"
-Redirected to Slots [6257] located at 192.168.80.132:7000
Ok
192.168.80.132:7000> Cluster Keyslot msg
(integer) 6257
192.168.80.132:7000> Get MSG
"Hello World"
192.168.80.132:7000>
This article is from the "dba003" blog, make sure to keep this source http://dba003.blog.51cto.com/12318731/1880265
Redis 3.2.5 Cluster adding nodes and assigning slots