redis cluster test

cp /test/tests/redis.conf /etc

redis-server /etc/redis.conf

redis-trib.rb create --replicas 1 172.17.0.6:6379 172.17.0.7:6379 172.17.0.8:6379 172.17.0.9:6379 172.17.0.10:6379 172.17.0.11:6379

redis-cli -c -p 6379

echo yes|redis-trib.rb create --replicas 1 172.17.0.6:6379 172.17.0.7:6379 172.17.0.8:6379 172.17.0.9:6379 172.17.0.10:6379 172.17.0.11:6379

redis-cli cluster nodes

redis-trib.rb check 172.17.0.6:6379
redis-trib.rb check $(hostname -i):6379

redis-trib.rb add-node --slave 172.17.0.10:6379 172.17.0.6:6379

add master
redis-trib.rb add-node 172.17.0.12:6379 172.17.0.6:6379

redis-trib.rb reshard --from all --to 8a14b6541e77acbe4a0d95d147cf2028bbf122e9 --slots 4096 172.0.0.6:6379

echo yes|redis-trib.rb reshard --from all --to 8a14b6541e77acbe4a0d95d147cf2028bbf122e9 --slots 4096 172.17.0.6:6379

在从上运行,将自己转为令一个主的从
redis-cli cluster replicate 6d3c50a4f147eba0bc81004a52521f0c9549dee6

root@6d88c14f7660:/# redis-cli cluster nodes | grep myself | awk '{print $1}'
62347a994e2ecebfe1953f057a25c944fec2e0c9
root@6d88c14f7660:/# redis-trib.rb del-node 172.17.0.6:6379 62347a994e2ecebfe1953f057a25c944fec2e0c9
>>> Removing node 62347a994e2ecebfe1953f057a25c944fec2e0c9 from cluster 172.17.0.6:6379
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

ansible docker -c docker -m shell -a "python /usr/local/bin/manage.py on_stop"

-------------------------------------

redis-trib.rb create --replicas 1 172.17.0.6:6379 172.17.0.7:6379 172.17.0.8:6379 172.17.0.9:6379 172.17.0.10:6379 172.17.0.11:6379

>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
172.17.0.6:6379
172.17.0.7:6379
172.17.0.8:6379
Adding replica 172.17.0.9:6379 to 172.17.0.6:6379
Adding replica 172.17.0.10:6379 to 172.17.0.7:6379
Adding replica 172.17.0.11:6379 to 172.17.0.8:6379
M: 296964b94c653226ff9e46235e6e8d6d084ce98f 172.17.0.6:6379
   slots:0-5460 (5461 slots) master
M: e90a7ed6ddff6c83e0a6a0d701cdde134e21207f 172.17.0.7:6379
   slots:5461-10922 (5462 slots) master
M: 02cc4f10e0496453d11abb302f4ce838a0d68529 172.17.0.8:6379
   slots:10923-16383 (5461 slots) master
S: 92e5a0a6b0081fc03334af532a54cfe24052883f 172.17.0.9:6379
   replicates 296964b94c653226ff9e46235e6e8d6d084ce98f
S: 191d45eed4b492fbb7d172067f2666fdac659435 172.17.0.10:6379
   replicates e90a7ed6ddff6c83e0a6a0d701cdde134e21207f
S: f71f1017be780222fa2308974ca4acfd3a3ab91f 172.17.0.11:6379
   replicates 02cc4f10e0496453d11abb302f4ce838a0d68529
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join....
>>> Performing Cluster Check (using node 172.17.0.6:6379)
M: 296964b94c653226ff9e46235e6e8d6d084ce98f 172.17.0.6:6379
   slots:0-5460 (5461 slots) master
M: e90a7ed6ddff6c83e0a6a0d701cdde134e21207f 172.17.0.7:6379
   slots:5461-10922 (5462 slots) master
M: 02cc4f10e0496453d11abb302f4ce838a0d68529 172.17.0.8:6379
   slots:10923-16383 (5461 slots) master
M: 92e5a0a6b0081fc03334af532a54cfe24052883f 172.17.0.9:6379
   slots: (0 slots) master
   replicates 296964b94c653226ff9e46235e6e8d6d084ce98f
M: 191d45eed4b492fbb7d172067f2666fdac659435 172.17.0.10:6379
   slots: (0 slots) master
   replicates e90a7ed6ddff6c83e0a6a0d701cdde134e21207f
M: f71f1017be780222fa2308974ca4acfd3a3ab91f 172.17.0.11:6379
   slots: (0 slots) master
   replicates 02cc4f10e0496453d11abb302f4ce838a0d68529
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

原文地址:https://www.cnblogs.com/mhc-fly/p/7732540.html