#Redis is deployed using a cluster. If there is a power outage or the server is restarted, sometimes it will not start when it is started again. You need to use the fix command of trib to fix it. If the repair still fails, you can clear the node data and rebuild the cluster. The prerequisite is to back up the operation. (Recommended learning: Redis video tutorial)
1. Use redis-cli to connect to one of the redis
redis-cli -c -h xxx -p 7001
Enter cluster info to view the status of the current cluster
2. You can use trib’s check to detect the cluster status
redis-trib.rb check xxx:7001 [ERR] Not all 16384 slots are covered by nodes.
3. If the above error occurs, you can try to use the fix command to repair it
redis-trib.rb fix xxx:7001
After the repair is completed, use the check command of trib to check the status
4. If it cannot be repaired by fix
pkill redis stops the previous redis process
Then delete the aof, rdb, nodes node files, you need to back them up before deleting
5. Then start each redis node
redis-server /usr/local/src/redis-3.2.4/redis_cluster/7000/redis.conf redis-server /usr/local/src/redis-3.2.4/redis_cluster/7001/redis.conf redis-server /usr/local/src/redis-3.2.4/redis_cluster/7002/redis.conf redis-server /usr/local/src/redis-3.2.4/redis_cluster/7003/redis.conf redis-server /usr/local/src/redis-3.2.4/redis_cluster/7004/redis.conf redis-server /usr/local/src/redis-3.2.4/redis_cluster/7005/redis.conf
6. Create a redis cluster
redis-trib.rb create --replicas 1 xxx:7000 xxx:7001 xxx:7002 xxx:7003 xxx:7004 xxx:7005
7. After the cluster is created, connect to redis again to view the cluster status. As shown in the figure, you can see that the redis service of 3 masters and 3 slaves has been started
redis-cli -c -h xxx -p 7000 cluster info cluster nodes
For more Redis-related technical articles, please visit the Redis database usage tutorial column to learn!
The above is the detailed content of How to solve the problem that the redis cluster cannot be restarted. For more information, please follow other related articles on the PHP Chinese website!