The first master-slave switch, turn off r1, master successfully switch to r2 2) Start r1master and slave synchronization r1 is closed by mistake 3) The second master-slave switch, turn off r2, switch failed (r1 is shut down by mistake, Awkward) (This time the configuration is this:
r1 in the previous step after the start of the Sentinel marked slaveof r2 6379 mark; r2 main configuration sentinel will remove the slaveof mark, but the sub-file mark can not be removed; Because the switch fails, Sentinel configuration file in the master configuration or r2;) 4) Switch failed, restart r1, because originally cut to r1 Well, the results sentinel did not respond, the application or error, see the log application is still in the Tried to connect r2. 5) No way to restart r2, the results of the application of an error, slave mode can not be written. That is r2 connected, but the slave mode can not write data (Slave mode can be written or not can be configured, we configure the slave read-only). 6) This time with the info command to view the role of r2 is indeed slave, check r1 is slave. Here on the circle, r1 and r2 are up, but no master, master where to go, lasted about 10 minutes, miracles did not happen, r2 mandatory use slaveof no one command to upgrade to master, service recovery. There are many questions come down the whole process, did not understand the knowledge of the main switch from Redis before, with questions in the local simulation test, there are three main problems: 1. Why restart after two instances are slave 2. Why Sentinel did not choose one of two instances to become a master and notify the client. 3. Master from the process of switching so important under what circumstances will fail? The first question has already said above, after restarting the two instances are slave, because the first switch r1 master, r1 restart sentinel marked by the slaveof was mistakenly closed, of course, slaveof mark is not cleared It's r2 Although it is master, but restart the sub-file specified slaveof, the Sentinel can not be removed, so the restart will enter the slave mode. The second question, why sentinels did not play a role? In fact, if we wait for some time, a miracle can happen. After waiting for a long time, it takes a total of 30 minutes (is it a bit too long?). Sentinel has an important configuration parameter sentinel failover-timeout master 900000, where our default configuration is 900000ms or 15 minutes. If sentinel fails a failover once, then the next failover time is 2 * 15 = 30 minutes . The above example sent the sentry a switch while closing r2, but r1 is also hung, so the failover is a failure. Need to wait 30 minutes to do the second, restart r1 and r2, double-slave predicament no one to crack. As the waiting time is too long, do not know what happened, people think sentinel is not hung up. The official default configuration is 180000, we have increased this time limit for historical reasons, restore the default configuration is sufficient. The third question, under what circumstances will the main switch from failure? After investigating some of the information and simulating our current configuration locally, we built a series of tests on the Redis environment and found the following problems: (1) More than half of the sentinel downtime, the remaining sentinel can not failover This situation if only two sentinel, and one of sentinel and master instances deployed on the same machine, if the virtual machine failure or network problems master is considered downtime, the same machine sentinel basically hung up, the probability of not switching 100% . Sentinel election leader need more than half of Sentinel agreed that a few Sentinel will never be elected leaders, it is best not sentinel only set two, and sentinel best not to collocate with the redis physical machine deployment, or redis instance downtime is very likely The same machine sentinel also hung, sentinel lost its meaning. (2) Most sentinel votes for itself, no candidate gets more than half the votes, so there is no election for leader, you need to wait for 2 * failover-timeout time and restart the switch. This happens quite often when there are only two sentinels, sentinel1 and sentinel2 both observing the objective objectification of the line, at the same time initiating the vote, each sentinel select
Second, the main switch Redis is generally used in a single point and the cluster of two ways, there is a very high demand for QPS generally build clusters, our current general business QPS not so high demand, it is a single master-slave mode (the cluster Node is also master-slave mode). Speaking of master-slave switch had to say Sentinel Master node failure will inevitably require timely switch to the slave node, restore the application as soon as possible. Then monitor the Master state, initiate the master-slave switching process, and finally notify the client of the newly elected master's task is done by the Sentinel. Sentinel generally needs to deploy a cluster. Back to the above example, talk about this example because the following research and configuration adjustments are caused by this example, the story is this:
ed themselves, can not be elected leader. Multiple sentinel theoretically possible election failure, the probability is lower. In particular, the first election failed, the next election to wait 2 * failover-timeout, here is 30min, will make most people feel that do not know what happened. Here is still recommended according to their business use, as much as possible to reduce the failover interval. (3) Even if sentinel successfully elected the leader, the switch is not necessarily successful, not all surviving slave can be promoted to master, need to be filtered. Slave node status is S_DOWN, O_DOWN, DISCONNECTED can not be filtered The last ping response time does not exceed 5 times the ping interval (if ping interval is 1 second, the last response delay should not exceed 5 seconds, redis sentinel defaults to 1 second), otherwise you can not filter info_refresh answer no more than 3 times info_refresh interval (principle with 2, redis sentinel defaults to 10 seconds) Slave node master node loses contact time can not exceed the specified threshold of 10 * down-after-milliseconds (we generally set 60s, 10 times is 10 minutes), meaning that the master is too late to synchronize the slave should not be involved election. Slave priority is not equal to 0 (this is specified in the configuration file, the default configuration is 100). http://ks.netease.com/blog?id=7468 NetEase practitioner community to share the accident cluster 12 nodes 7 master-slave switch failure is due to the slave node and the master lost too long caused no successful switch Of course, there are other reasons for this accident: 1) There was a problem with the master node and the sentinel deployed on the same machine 2) 3 sentinel hung up one If three sentinel independent deployment, this fault can be largely avoided. Emergency Plan (This article Jedis2.6.0 client as an example): Because the master-slave switch may fail, the specific reasons for the specific analysis: 1. If it is because most sentinel are hung up, not enough to elect a leader, choose a surviving sentinel to force sentinel failover, and if there is an alternate slave successfully promoted to master, the client application does not need to be restarted. 2. If it is because the Sentinel did not vote for success, to see whether the waiting time can be tolerated, can wait for the next failover, otherwise with 1) steps. 3. If it is because there is no slave through the filter, it is recommended to stop all Sentinels, a slave promoted to master, modify the Sentinel configuration point to this new master, restart the Sentinel, restart the client application (You can also restart a Redis instance, a new instance of slaveof new master, manual failover on sentinel, so you do not have to restart the client application ~) Sentinel deployment recommendations: 1. By an odd number of deployments, at least three deployed, Sentinel, independent of the physical machine between Redis instances. 2. sentinel monitor master xxx.xxx.xxx.xxx xxxx 1 Sentinel this configuration is best not to be configured as 1. A quorum value of 1 means that whenever a sentinel finds the master node is unresponsive, it can be marked as objective offline to initiate a master-slave switch, and the quorum is best set to round up more than half of the number of sentinels. 3. entinel failover-timeout master 900000 // milliseconds
Subscribe to:
Post Comments (Atom)
Technology
How to earn money per day 100$ just work copy past
http://shrinkearn.com/rq4D Earn money 100$ dollers in a day ShrinkEarn.Com is a new paying hyperlink shortener network, it gives ...
-
, the log file will retain four elements of personal and bank card information, these data are personal privacy, the original ELK program ca...
-
This article will cover a part of the book DevOps Handbook: An Interpretation of Common DevOps Misconceptions. Some friends are not familia...
-
Just as we said, when the name AI came into being, we suddenly realized that Alibaba's business all talked about AI + its own business...
No comments:
Post a Comment