Home > Database > Redis > body text

How to solve the problem that the redis cluster cannot be restarted

(*-*)浩
Release: 2019-12-02 09:02:31
Original
3329 people have browsed it

How to solve the problem that the redis cluster cannot be restarted

#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
Copy after login

Enter cluster info to view the status of the current cluster

How to solve the problem that the redis cluster cannot be restarted

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.
Copy after login

How to solve the problem that the redis cluster cannot be restarted

3. If the above error occurs, you can try to use the fix command to repair it

redis-trib.rb fix xxx:7001
Copy after login

After the repair is completed, use the check command of trib to check the status

How to solve the problem that the redis cluster cannot be restarted

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

How to solve the problem that the redis cluster cannot be restarted

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
Copy after login

How to solve the problem that the redis cluster cannot be restarted

6. Create a redis cluster

redis-trib.rb create --replicas 1 xxx:7000 xxx:7001 xxx:7002 xxx:7003 xxx:7004 xxx:7005
Copy after login

How to solve the problem that the redis cluster cannot be restarted

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
Copy after login

How to solve the problem that the redis cluster cannot be restarted

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template