How Nodes in Redis Cluster Ensure Data Consistency

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. The master database can perform read and write operations. When a write operation occurs, the data is automatically synchronized to the slave database, while the slave database is generally read-only and receives For the data synchronized from the master database, a master database can have multiple slave databases, and a slave database can only have one master database.

2. Through the replication function of redis, the read-write separation of the database can be well 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, it will send a sync command to the master database,

2: After the master database receives the sync command, it will start to save the snapshot in the background (perform the rdb operation), and cache the commands received during the save

3: When the snapshot is completed, redis will send the snapshot file and all cached commands to the slave database.

4: After receiving from the database, the snapshot file will be loaded and the received cached command will be executed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324812900&siteId=291194637