Redis study notes (VI Sentinel)

table of Contents:

  • basic concepts
  • Environmental deployment
  • Sentinel Principle
  • Sentinel command

basic concepts:

1. What is the Sentinel

We start to understand the literal meaning Sentinel, Sentinel is a generic term for a soldier to perform the task of vigilance; sentinel is the same in redis, he monitors the state redis server.

2. Why should Sentinel

When the primary server fails redis we need to failover from a node that is promoted to master node; but this process is somewhat tedious, and error-prone, and operation and maintenance personnel can not be guarded 24 hours a day; for to this number question, we redis developers will create a sentry, these problems have been resolved.

) Sentinel failover process: find fault -> elect a new node -> Copy the new node

a, when the primary node fails, the client connected to the master node fails, other nodes are copied from the master node of the interrupt

b, when more than a certain number of findings from the master node node goes down, these will be elected from the nodes in a node, and perform slaveof no one command to become a new primary node

C, was promoted when the master node from the master node updates the party application information, and restart the application side

d, to take possession of the other copy of the new master node from the node, slaveof Host Port

After E, the original master node to be restored, the new master node will be replicated

) Automated failover issues to be addressed

Whether a, the determination node and a sound mechanism unreachable standard

b, if there are multiple slave nodes, how to ensure that only one is promoted to master node

c, inform the client about the new primary mechanism is sound

3, Sentinel architecture

Environment deployment:

Program: a main two from three sentinel

1, the configuration file

) Configuration master; startup command: redis-server redis-6379.conf

# Has been run in daemon mode

daemonize yes

# Set the log file

logfile 6379.log

# RDB configuration file

dbfilename dump-6379.rdb

) Configuration from the node; start moving command: redis-server redis-6380.conf, redis-server redis-6381.conf

# Has been run in daemon mode

daemonize yes

# Set the log file

logfile 6380.log

# RDB configuration file

dbfilename dump-6380.rdb

# Set the master node

slaveof 127.0.0.1 6379

 

Similarly 6381 and 6380

) Sentinel node configuration; startup command: redis-server sentinel-26379.conf --sentinel

port 26379

daemonize yes

logfile "26379.log"

Monitoring the master node # 127.0.0.1:6379, alias sentinel-master, at least two nodes that do Sentinel fault failover; sentinel monitor <quorum> <master-name> <ip> <port> ;;

sentinel monitor yunxi-master 127.0.0.1 6379 2

# Exceeds the specified second node receives no reply, it is determined fault offline; sentinel down-after-milliseconds <master-name> <times>

sentinel down-after-milliseconds yunxi-master 30000

Copy number of concurrent requests originating from the master node to the node # failover; sentinel parallel-syncs <master-name> <nums>

sentinel parallel-syncs yunxi-master 1

# Failover timeout; sentinel failover-timeout <master-name> <times>

sentinel failover-timeout yunxi-master 180000

2, deployment tips

) In order to achieve true high availability, not to sentinel nodes deployed on the same physical machine , because the sentinel node if this physical machine failure, then it will affect the

) To deploy at least three or more odd number of nodes, which can improve the campaign strategy sentinel determine the fault of accuracy, and better meet more than half of the votes

) Each business scenario to deploy a sentinel

Sentinel Principle:

1, three job composition by Sentinel

) Every 10 seconds, to monitor (info why each sentinel sends command to the master node, node redis to obtain the current state not to be displayed, because the replication of the master node from the node contains information from the node)

) Every 2 seconds, each sentinel node sends back redis __sentinel __: transmitting their judgment of the master node, and information on their nodes hello channel; and each sentinel node will subscribe to a channel change, to learn about other nodes on sentinel Analyzing the master node

) Per one second, sentinel nodes do heartbeat back to the master node and other nodes from transmitting the ping command and sentinel node

2, subjective and objective offline offline

) Subjective offline: they think only the master node goes down the offline mode

Current sentinel node sends a heartbeat ping done, if more than down-after-milliseconds has not yet responded to make the subjective offline

) Objective offline: actual master node offline

The sentinel will be sent to the other sentinel sentinel ismaster-Down-by-addr command to learn other sentinel node judgment of the master node, if more than quorum number of sentinel nodes are considered primary is down, the sentinel node will master node objective do offline processing

Sentinel command:

 

Guess you like

Origin www.cnblogs.com/bzfsdr/p/11547229.html