Home > Database > Redis > body text

How to prevent split-brain in redis cluster

(*-*)浩
Release: 2019-11-20 14:39:29
Original
7527 people have browsed it

How to prevent split-brain in redis cluster

What is redis cluster split brain?

Redis cluster brain splitting means that due to network problems, the redis master node, the redis slave node and the sentinel cluster are in different network partitions. At this time, the sentinel cluster cannot sense the existence of the master, so Promote the slave node to the master node. (Recommended learning: redis video tutorial )

There are two different master nodes at this time, just like a brain split into two.

In the cluster split-brain problem, if the client continues to write data based on the original master node, the new master node will not be able to synchronize the data. When the network problem is resolved, the sentinel cluster will replace the original master node with the original master node. The node is reduced to a slave node. At this time, synchronizing data from the new master will cause a large amount of data loss.

How to prevent split-brain in redis clusterSolution

There are two parameters in the redis configuration file

min-slaves-to-write 3
min-slaves-max-lag 10
Copy after login

The first parameter Represents the minimum number of slaves connected to the master

The second parameter indicates the maximum delay time for the slave to connect to the master

If the number of slaves connected to the master is less than the first parameter, and the ping delay If the time is less than or equal to the second parameter, then the master will reject the write request. After configuring these two parameters, if a cluster brain split occurs, the original master node will reject the write request from the client, which can reduce the amount of data synchronization. of data lost.

Note: The parameters in the newer version of the redis.conf file have become

min-replicas-to-write 3
min-replicas-max-lag 10
Copy after login

The data loss problem in the case of asynchronous replication in redis can also use these two parameters

The above is the detailed content of How to prevent split-brain in redis cluster. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!