In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Blog catalogue
I. the principle of Redis clustering
1. Architecture details
2. Redis election
Second, set up Redis cluster
1. Install the first Redis and modify the configuration file
2. Install the second Redis and modify the configuration file
3. Create a cluster using scripts
4. Test cluster
I. the principle of Redis clustering
For a detailed description of how Redis non-relational database works, please refer to the blog post: talk about Redis (non-relational database) in Centos 7.
Redis Cluster is an acentric structure in which each node holds data and the state of the entire cluster. Each node will save the information of other nodes, know the slot that other nodes are responsible for, and send heartbeat information regularly with other nodes, which can timely sense the abnormal nodes in the cluster. As shown in the following figure:
When the client sends a command related to the database key to any node in the cluster, the node receiving the command calculates which slot the database key to be processed by the command belongs to and checks whether the slot is assigned to it. If the slot in which the key is located happens to be assigned to the current node, the node executes the command directly; if the slot in which the key is located is not assigned to the current node, the node returns a MOVED error to the client, directing the client to redirect the correct node and sending the command that it wanted to execute again.
The cluster roles are Master and Slave. Slots is allocated between Master, with a total of 16384 slot. Slave synchronizes data to the Master specified by it for backup. When one of the Master is unable to provide services, the Slave of that Master is promoted to Master. To ensure the integrity of the cluster key slot. When one of the Master and its Slave fails, it will lead to incomplete slot and cluster failure, which needs to be dealt with manually.
After the cluster is built, each node in the cluster will periodically send PING messages to other nodes. If the node receiving the PING message does not return the PONG message within the specified time, then the node sending the PING message will mark it as suspected offline (PFAIL). Each node exchanges the status information of each node in the cluster by sending messages to each other. If more than half of the primary nodes in a cluster report a node X as suspected offline, the primary node X will be marked as FAIL and a FAIL message about the primary node X will be broadcast to the cluster, and all nodes that receive the FAIL message will immediately mark the primary node X as offline.
When we need to reduce or increase the number of machines in the cluster, we need to change the slot that has been assigned to one node (the source node) to another node (the target node), and move the key-value pair to which the relevant slot belongs from the source node to the target node.
The resharding of the Redis cluster is performed by Redis's cluster management software redis-trib, which does not support automatic sharding and requires you to calculate how much Slot is migrated from which nodes. During the resharding process, the cluster does not need to be offline, and both the source and destination nodes can continue to process command requests.
1. Architecture details
All redis nodes are interconnected with each other (PING-PONG mechanism), and binary protocols are used internally to optimize transmission speed and bandwidth.
Node failure (fail) fails when more than half of the primary (master) nodes in the cluster detect failure
The client is directly connected to the redis node and does not need an intermediate agent (proxy) layer. The client does not need to connect all the nodes in the cluster, but can connect to any available node in the cluster.
Redis-cluster maps all physical nodes to [0-16383] slot, and cluster is responsible for maintaining nodeslotkey;2 and Redis elections.
As shown in the following figure: the election process involves the participation of all master in the cluster. If more than half of the master nodes time out to communicate with the current master node (cluster-node-timeout), the current master node is considered dead.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.