總網頁檢視次數

星期三, 11月 06, 2019

How to balance REDIS database by redis-cli

Case 1 : Master and Slave are not in correct position.
 
(Assume 7001 is the master but it is in slave now. )

#redis-cli -a Password -c -p 7001 cluster failover



Case 2 : Slave is promoted to Master while Master is still active. 

In this case, we have to remove the wrong node from cluster and add it back as slave

(Asssume the wrong port/service is redis_7005

#redic-cli -a Password --cluster del-node master-node-ip:port id-of-node-to-be-del

#systemctl stop redis_7005
#rm -rf /var/lib/redis/7005/*
#system start redis_7005

#redis-cli -a Password --cluster add-node master-node-ip:port ip-of-slave-node:port --cluster-slave


Then you can use the following command to check it

#redis-cli -a Password -c -p 7001 cluster nodes



沒有留言: