Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the Redis failover process mean?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the meaning of Redis failover process". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Redis-sentinel failover proc

Sentinel initialization

Initialize the masters property in the sentinel state

Create a network connection to each master (command connection, subscription connection)

Sentinel sends info commands to the configured masters (every 10 seconds): get master and slave information

Update master instance structure

Update slave information in master instance structure

Create a network connection to each slave (command connection, subscription connection)

Sentinel sends info commands to slaves (every 10 seconds): get slave information

Update slave information in master instance structure

Sentinel posts messages to all master and slave's _ _ sentinel__:hello channels (every 2 seconds):

Sentinel subscribe to the channel information of the master-slave server: get other sentinel information

Update sentinels information in master instance structure

Create a network connection to each sentinel (command connection)

Sentinel sends ping commands to all known master/slave/sentinel (every 1 second): heartbeat detection

Subjective referral: the node did not return a valid reply on down-after-milliseconds

Update the flags property of the master instance structure: SRI_S_DOWN

The subjective offline duration may be different with different sentinel settings: down-after-milliseconds

Send the offline inquiry command to other sentinel that also monitors the master: SENTINEL is-master-down-by-addr 0 *

Objective referral: the number of sentinel of subjective referral reaches quorum

Quorum may be different for different sentinel settings

Sentinel chooses the main body

Raft algorithm

Enter the objective offline sentinel and send SENTINEL is-master-down-by-addr to other sentinel

When the runid is not * but the running ID of the source sentinel, the source sentinel requires the destination sentinel to set itself to a local leader

Local leader is set on a first-come-first-served basis.

If the number of votes is more than half, it becomes leader.

Sentinel leader for failover: disconnect time, priority, offset, run_id

Sentinel leader sends slaveof no one commands to the elected slave and becomes leader

Sentinel leader sends commands to other slave to change it to slave of the new leader

Sentinel leader tests the heartbeat of the old master and turns it into the slave of the new leader when it recovers.

Redis-cluster failover proc

After node joins the cluster, use the gossip algorithm to complete the information synchronization in the cluster.

Node and all master nodes in the cluster do heartbeat detection with each other.

Suspected offline

Offline (half of the primary nodes)

Broadcast the message of node fail

Fail-over

The slave node of the fault node is selected as the master, and the voter is the master node in the cluster.

Upgrade the new node to the primary node

Revoke the slot assignment of the offline master node and assign it all to yourself

Broadcast PONG messages to notify the cluster of new master nodes and slot assignments

After the old master node is restored, it becomes the slave of the new master node.

That's all for "what does the Redis failover process mean?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report