Downtime is a computer term. In spoken language, we simply call a stopped machine a down machine. When converted into Chinese characters, it is "downtime", but many people call it "crash"/"crash". Although it is not standardized, it is Popularity.
Downtime refers to the phenomenon that the operating system cannot recover from a serious system error, or there is a problem at the system hardware level, causing the system to become unresponsive for a long time and the computer has to be restarted. This is a normal phenomenon in computer operation and will occur in any computer.
The redis cluster has many redis working together, so it is necessary that the cluster is not so easy to hang up. Therefore, in theory, it should be given to the At least one backup redis service per node. This standby redis is called a slave. (Recommended learning: Redis video tutorial)
The first thing to say is that each node stores information about all master nodes and slave nodes of the cluster. They determine whether the node can be connected through mutual ping-pong. If more than half of the nodes do not respond when pinging a node, the cluster will consider the node to be down, and then connect to its backup node.
In the master-slave mode, downtime should be divided into different categories:
slave slave redis downtime
In Redis, after the slave database is restarted, it will automatically join the master-slave architecture and automatically complete data synchronization;
If the slave database implements persistence, incremental synchronization will be achieved as long as it is re-entered into the master-slave architecture.
Master is down
If neither the master nor the slave has data persistence, do not restart the service immediately, otherwise data loss may occur. The correct operation is as follows :
- Execute SLAVEOF ON ONE on the slave data to disconnect the master-slave relationship and upgrade the slave to the main database
- At this time, restart the main database, execute SLAVEOF, and set it For the slave database, data is automatically backed up.
Necessary conditions for the cluster to enter the fail state
If a master node and all slave nodes hang up, our cluster will enter the fail state.
If more than half of the masters in the cluster hang up, regardless of whether there is a slave or not, the cluster will enter the fail state.
If any master in the cluster hangs up, and the current master has no slave, the cluster will enter the fail state
The voting process involves the participation of all masters in the cluster. If the communication between more than half of the master nodes and the master node times out (cluster-node-timeout), the current master node is considered dead.
The basis for the election is: normal network connection->INFO command replied within 5 seconds->connected to the master within 10*down-after-milliseconds->slave server priority-> ;Copy offset->Run the one with smaller id. After selection, the slave server will be promoted to the new master server through slaveif no ont.
Use the slaveof ip port command to let other slave servers copy the master server.
Finally, when the old master reconnects, it will become the slave server of the new master. Note that if the client is separated from the old master server, the written data will be lost after recovery because the old master will copy the data of the new master.
For more Redis-related technical articles, please visit the Introduction to Using Redis Database Tutorial column to learn!
The above is the detailed content of What does downtime mean in redis?. For more information, please follow other related articles on the PHP Chinese website!