Get the App
SLTechnology News&Howtos  ›  Database  › 

Why should redis Cluster use Master-Slave replication function

Shulou Source: shulou.com Published: 2022-06-01 15:23:12 10月03日 Update

Why do redis clusters use master-slave replication? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

In order to make the cluster work normally when some nodes go offline or cannot communicate with most of the nodes in the cluster.

The Redis cluster uses master-slave replication for nodes: each node in the cluster has 1 to N replicas (replica), one replica of which is the master node (master), and the rest of Nmuri 1 replica is the slave node (slave).

Several common ways of Redis master-slave replication

One master, two servants A (B, C), one Master, two Slave

The fire is handed down (decentralized) A-B-C, B is both the master node (the master node of C) and the slave node (the slave node of A).

Counter-guest master (manual operation to upgrade slave node after down drop) & Sentinel mode (after down drop of master node, slave node is automatically upgraded)

Master-slave replication:

1. The replication function of redis is to support data synchronization between multiple databases. One is the master database (master) and the other is the slave database (slave). When the write operation occurs, the master database can automatically synchronize the data to the slave database, while the slave database is generally read-only and receives the data synchronized from the master database. A master database can have multiple slave databases, while a slave database can only have one master database.

2. Through the replication function of redis, the read and write separation of the database can be realized, and the load capacity of the server can be improved. The master database is mainly for write operations, while the slave database is responsible for read operations.

1: when a slave database is started, a sync command is sent to the master database

2: after receiving the sync command, the master database starts to save the snapshot in the background (perform the rdb operation), and caches the commands received during the save

3: when the snapshot is complete, redis sends the snapshot file and all cached commands to the slave database.

4: upon receipt from the database, the snapshot file is loaded and the cache command received is executed

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Data database node cluster command master-slave function snapshot replica cache synchronization multiple file upgrade help support clear anti-guest host offline two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi OPPO Reno MySQL Shulou Technology