当前位置:网站首页>Redis cluster (master-slave) brain crack and solution

Redis cluster (master-slave) brain crack and solution

2022-07-05 11:44:00 We've been on the road

1 Cluster cleft brain

redis The cluster brain crack refers to the network problem , Lead to redis master The node follows redis slave Nodes and sentinel Clusters are in different network partitions , At this time because sentinel The cluster cannot perceive master The existence of , So will slave The node is promoted to master node . There are two different master node , It's like one brain split into two .
In the cluster cleft problem , If the client is still based on the original master The node continues to write data , So new master Nodes will not be able to synchronize this data , When the network problem is solved ,sentinel The cluster will be the original master The node is reduced to slave node , Now it's time to start again master Data synchronization in , It will cause a lot of data loss .

redis Cluster cleft brain

2 Solution
redis In the configuration file , There are two parameters :


    
     
  1. min-slaves-to-write 3
  2. min-slaves-max-lag 10
  • The first parameter indicates the connection to master At least slave Number
  • The second parameter represents slave Connect to master Maximum delay time

Follow the above configuration , At least 3 individual slave node , And the delay of data replication and synchronization cannot exceed 10 second , Otherwise master Will refuse to write the request , After configuring these two parameters , If cluster cleft occurs , The original master When the node receives a write request from the client, it will reject , Data loss after data synchronization can be reduced .

Be careful : Newer versions of redis.conf The parameters in the file become


    
     
  1. min-replicas-to-write 3
  2. min-replicas-max-lag 10

redis These two parameters can also be used for data loss in the case of asynchronous replication in .

</article>
原网站

版权声明
本文为[We've been on the road]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051131475764.html