redis Design and Implementation of the third part of the study notes

Chapter XVI Sentinel (Sentinel)

1.Sentinel (Sentinel) is redis high availability solutions: Sentinel Sentinel system consists of one or more instances of the master can monitor any number of servers, as well as those from the following master server, the master server and monitored at an upgrade from the server to the new master server the master server offline automatically when the line.

d

2. When the offline master's longer than the set upper limit, the Sentinel system will do to master failover process:
   1. First Sentinel system will pick a slave master, and will upgrade to the new slave master.
   2. After all the original master slave Sentinel will send a new copy of the order, so they called the new master of the slave, when all the slave start copying the new master, the end of the failover operation.
   3.Sentinel monitors have been off the assembly line of the original master, and when it's back online it is set to slave.
On 3.Sentinel essentially just a redis server in a special mode of operation.
Boot configuration, etc. 4.Sentinel understanding can: Sentinel reads the user-specified configuration file, create a corresponding structure for each instance of the master to be monitored, and even create a connection and subscribe to the master's command to connect.
5.Sentinel default 10S INFO once to send commands to the monitored master, master and get current information in accordance with the reply message. Reply data includes master information itself, Role and including id, further comprising the information of all the slave master, including ip, port, etc. When the Sentinel found new slave master appears, will create an instance of the corresponding structure for this new slave, but also create a connection to the slave commands connection and subscription access. 10S default primary sends an INFO command, the slave receive a reply containing data ip and port id, role, master, the connection status, priority, etc. After creating the copy command offset connector. .

6. For the monitoring from the same master server and a plurality of Sentinel server, they will be monitoring server to a frequency of every two seconds __sentinel __ by: hello message transmission channel to announce its presence to other Sentinel. Each Sentinel also from __sentinel __: hello receive other channel information sent by the sentinel, and creates another instance of sentinel structure based on the information, and instructs the connection (connection not subscribed)
7. By default Sentinel will 1S You create an instance of a PING command to send commands to connect to all, and according to reply to determine whether online. If continuous 50,000 milliseconds (default) are sent to the Master Sentinel invalid reply, it will be marked offline subjective. When the master is marked as a subjective offline, Sentinel will make an inquiry to other monitoring of the master Sentinel, Sentinel Once received from the other where the Sentinel enough (setting options) is determined offline, marked as offline objective, and failover.
8. leader election Sentinel: When the objective is determined offline master, monitors its election all Sentinel Sentinel lead to a failover operation. Specific rules:
     1. All online Sentinel has been eligible to vote.
     2. Sentinel election every time, regardless of whether the success of all eras Sentinel configuration will be +1.
     3. In a configuration within the era, all have a chance Sentinel Sentinel is set to be a local leader, and can not be set after the completion of modify.
     4. Each master found downline Sentinel enters objective will require other sets itself as a local leader.
     Leading the team is setting the rules 5.Sentinel first come first served, they voted to send the request of his earliest, after will be rejected.
     6. If a Sentinel is more than half of the election, it will be the leader, or else again.
9. After the completion of the elections, the leader Sentinel would have been off the assembly line of master failover operation:
     1. selection in all slave has been off the assembly line as a master of a new master.
     2. The other slave copy the new master.
     3. off the assembly line of the new master to slave the master.
10. Election of the new master algorithm:
     all slave 1. leader Sentinel will be offline master is stored in a list, and then delete all offline or disconnected slave.
     He did not respond to over-the slave Sentinel INFO command 2. Delete all within 5 seconds.
     3. Remove all connected to the slave master is disconnected offline than down-after-milliseconds * 10 in.
     4. Sentinel After selection according to the highest priority as the slave master. If the priority is the same, the maximum offset of the selected copy. If the same copy offset, then select id minimal.

Guess you like

Origin www.cnblogs.com/love17311706/p/12024652.html