Redis high availability solutions

Redis high availability solutions - Sentinel cluster

                                Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.                           
                           
                                This link: https: //blog.csdn.net/sunhuiliang85/article/details/78361211

Redis high availability solutions

A. Glossary

 

 

II. Master-slave replication

 

       Redis master pattern data may be copied from the master node to the slave node synchronization, in order to protect the case where the master node is not reachable from the node as

Back-up to the top, and can ensure data is not lost as much as possible (master-slave replication can guarantee eventual consistency). Second, the node may read the master node expansion

Ability, once the master node can not support a large amount of concurrent read operations, the master node can share the pressure to some extent from the node.

      The main problem faced by copying:

      1. When the primary node fails, it is necessary to manually promoted to a main node from the node, and notify the application side to modify master address and restarts

         Applications, and other required command to copy the new primary node from the node, the whole process requires human intervention.

      2. The ability to write the master node is limited stand-alone.

      3. Main storage capacity is limited stand-alone node.

III. The original failover

      1. After the primary node fails, the client connected to the master node failure, connection failure caused by two interrupt copying the master node from the node.

 

    2. If the master node fails to start properly, you need to select from a node (slave-1), its implementation slaveof no one command to become the new primary section

       3. from the original node (slave-1) becomes the new master node, the master node updates information of the application side, to restart the application side.

       4. another client command to copy the new node from the master node (slave-2)

       5. After the original primary node to be restored, copy it to the new master node

 

Four .Redis Sentinel high availability

 

    When the primary node fails, Redis Sentinel can automatically complete fault detection and failover, and informs the application side, allowing for true high availability.

RedisSentine is a distributed architecture, which contains several Redis Sentinel nodes and data nodes, each node would Sentinel node data and

The remaining Sentinel node monitoring, and when it finds a node is unreachable, would do offline identify the node. If the flag is "master node", and it will

Other Sentinel node "consultations", when most of the Sentinel nodes are considered primary node is unreachable, they will elect a Sentinel node to complete

Automatic failover to work, but this will change in real-time notification to Redis application side. The whole process is automatic and does not require human intervention to solve

Redis problem of high availability.

       Redis Sentinel Sentinel contains several nodes, this also brings two benefits:

       1. failure judgment is performed by a plurality of nodes Sentinel nodes together, which can effectively prevent false positives.

       2. Sentinel node set is composed of several Sentinel nodes, so that even if the individual Sentinel node is not available, the entire set of nodes by Sentinel

           However, it is robust.

       Redis Sentinel has the following features:

       1. Monitoring: Sentinel node data Redis periodically detects whether the remaining Sentinel node reachable

       2. Notification: Sentinel results will fail to notify the application side.

       3. The master node failover: to achieve from a node promoted to master node and the subsequent maintenance of the correct master-slave relationship.

       4. configuration provides: Among RedisSentinel structure, at the time the client initiates connection Sentinel node is set, the master node from which to obtain information.

 

Five. Redis Sentinel topology

 

 

 

Six. Redis Sentinel node discovery and monitoring mechanisms

Redis Sentinel discovery and monitoring completion of each node through regular monitoring three tasks:

    1 every 10 seconds, each Sentinel will get the latest topology to the master node and the slave node transmits the command info.

    2. every 2 seconds, each _sentinel_ Redis Sentinel node to the data node: The sending node determines Senitnel master node for the hello channel.

       Sentinel node and the current information, and each Sentinel node will subscribe to the channel to learn about other Sentinel nodes as well as their main festival

       Determination points. This task can be timed to complete the following two tasks:

       (1) the discovery of new Sentinel node: by subscribing to the master node _Sentinel_: hello Sentinel node for additional information. If you are new entrants

                Sentinel node, the Sentinel node information stored together, and creates a connection with the change Sentinel node

       According to the exchange between the master node status (2) Sentinel node, as well as offline objective behind leader elected

    3. every 1 second, each Sentinel node, the node remaining Sentinel node sends a ping command to the master node do a heartbeat to confirm

       The current node is reachable. And the master node, the node from the rest Sentinel have established a connection, to achieve monitor for each node. The regular tasks

       It is an important basis for the determination of node failure.

Seven. Redis Sentinel deployment tips

    1.Sentinel node should not be deployed on a single physical machine.

    2. deploy at least three nodes, and the odd-numbered Sentinel

    3. Only a Sentinel, or each master node configuration of a proposal discussed Sentinel Sentinel node-set is that if monitoring is the same one

       A plurality of main service node set, then the use of a program, otherwise the scheme 2. 

 

Eight Redis Cluster |. Data partition  

 

Redis data partition: RedisCluster virtual partition groove, the key is mapped to all slots 0-16383 integer hash function,

Formula: slot = CRC16 (key) & 16383. Each node is responsible for maintaining a portion of the slot and key data channel is mapped.

 

Redis partition virtual slot features:

1. The relationship between the data and decoupling node, simplifying the expansion and contraction of the difficulty node

2. node itself maintains a mapping relationship slot, no client agent service or maintenance partition meta data slot

3. Support the mapping between the nodes of the query, grooves, keys for routing data, online expansion and contraction of the scene.
----------------
Disclaimer: This article is CSDN blogger "Avenue simplification" of the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/sunhuiliang85/article/details/78361211

Guess you like

Origin www.cnblogs.com/yaoyangding/p/12127391.html