Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why should redis Cluster use Master-Slave replication function

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report