First, use version: 3.0.0.0
Second, the basic concept:
- a Redis cluster is one that can data sharing across multiple Redis nodes facilities (installation).
- Redis clusters are implemented using data sharding (sharding) instead of a consistent hash (consistency hashing): A Redis cluster contains 16,384 hash slots (hash slots), and each key in the database belongs to one of these 16,384 hash slots , the cluster uses the formula CRC16 (key)% 16384来 to calculate which slot the key key belongs to, where the CRC16 (key) statement is used to calculate the CRC16 checksum of key keys
- Each node in the cluster is responsible for processing a portion of the hash slot. For example, a cluster can have three hash slots, where:
- Node A is responsible for handling hash slots No. 0 to No. 5500.
- Node B is responsible for processing No. 5501 to 11,000th hash slots.
- Node C is responsible for handling hash slots 11,001th to 16,384th.
- Addition and removal of nodes
- If the user adds the new node D to the cluster, the cluster simply moves some slots in node A, B, and C to node D.
- If the user wants to remove node A from the cluster, the cluster needs only to move all the hash slots in node A to node B and node C, and then remove the empty (without any hash slots) Node A.
- The function of master-slave node
- if the cluster is created (or at least before node B is offline), weMaster Node B adds the B1 from the node, then when the primary node B is down, the cluster will set the B1 to the new master nodeand Let it take the place of the main node B of the downline and continue processing
5501
number to11000
hash slot so that the cluster does not function properly due to the downline of the primary node B.
- Asynchronous replication (although asynchronous replication, but execution of write commands and copy commands to the slave node is performed almost simultaneously, so the data is generally not lost)
- The client sends a write command to master node B.
- Master node B executes the Write command and returns a command reply to the client.
- Master Node B copies the write command just executed to its slave nodes B1, B2, and B3.
Iii. References:Http://redisdoc.com/topic/cluster-tutorial.html http://www.redis.net.cn/http://redis.io/
From for notes (Wiz)
Redis cluster (i): Basic concepts