Design and implementation of Redis--multi-level database implementation

Source: Internet
Author: User
Tags failover redis cluster

8 Replication Feature 8.1 legacy copy feature

Synchronization, Command propagation

8.2 New Replication Features

PSYNC: Full resynchronization, partial resynchronization

Implementation of 8.3-part resynchronization

Copy Offset

Replication Backlog buffer (one FIFO queue, default size 1M)

8.4 Implementation of replication

slaveof command

8.5 Heartbeat Detection

replconf ACK <replication_offset>

9 Sentinel9.1 Sentinel Boot process

1) Initializing the server

2) Use Sentinel-specific code

3) Initialize Sentinel state

4) Initialize the Masters property of the Sentinel state

5) Create a network connection to the primary server

Detect subjective downline status

Detect Objective Downline Status

10 Cluster 10.1 Aggregate data structure

Clusternode records its own state and creates a corresponding Clusternode structure for other nodes in the cluster, including the master and slave nodes, to record the state of the other nodes.

The link property of Clusternode is a clusterlink structure that holds the information needed to connect nodes, such as socket descriptors, input buffers, and output buffers.

Finally, each node holds this clusterstate structure, which records the current state of the cluster in the perspective of the present node:

Command: CLUSTER MEET

10.2 Slot Assignment

The Slots property and Numsolts property in Clusternode record which slots the node is responsible for processing.

The CLUSTER addslots command accepts one or more slots as parameters and assigns the input slots to the node that accepts the command.

Calculate which slot the key belongs to. Command: CLUSTER keyslot <key>

There is a difference between a node and a stand-alone database in a database: A node can only use database No. 0, while a stand-alone database does not have this limitation.

Slots_to_keys Jump table in Clusterstate to preserve the relationship between slots and keys:

10.3 Re-sharding

Re-sharding is performed by the Redis cluster management software Redis-trib.

Ask error: If the slot I that the key belongs to is being migrated, the node will issue an ask error to the client.

Moved error: The responsibility for representing the slot has been transferred from one node to another node.

Asking command:

10.4 Replication and failover 10.4.1 settings from a node

Set slave node: CLUSTER REPLICATE <node_id>

From node-related settings:

Master node Related settings:

10.4.2 Fault Detection

Each node in the cluster sends a PING message to the other nodes periodically, and if the Pong message is not received at the specified time, the node is marked as suspect downline (PFAIL);

When the primary node of more than half of the complex processing slots identifies a node as a suspected downline, the node is marked as a fail node.

10.4.3 Failover 10.4.4 elect a new node 10.4.5 message

MEET, PING, PONG, fail message, publish message.

Design and implementation of Redis--multi-level database implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.