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

Redis master-slave replication creation steps sharing

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

Share

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

This article mainly introduces the creation steps of redis master-slave replication in detail. The sample code in this article is very detailed and has a certain reference value. Interested friends can refer to it.

First of all, we will add slaveof masterHost masterPort to the slave library configuration file to specify the corresponding master library. At this point, if you start the slave library, redis will find the specified ip and port number to connect to master;. If it is a running redis server, we can execute the slaveof masterHost masterPort command to start replication from the library.

The following table shows what steps redis has gone through in master-slave replication:

The master server is running normally from server 1. Send the sync command, connect to the master server 2 to execute the bgsave command, and record the later write command in the buffer. If slave-serve-stale-data is configured as yes (the default setting), the slave library will continue to respond to client requests. Otherwise, any request other than the INFO and SLAVOF commands will return to the client an error prompt that 3bgsave finishes execution and sends the snapshot file to the slave library, during which all data is discarded using the buffer record write command, and the snapshot file loaded into the master library is finished sending the snapshot, starting to send the write command in the previously mentioned buffer to complete the snapshot interpretation, and starting to receive commands normally request 5 buffer content to be sent. Since then, every time a command is executed, the same command will be sent from the server to execute the command in the buffer sent by the main library. After the execution is finished, each write command from the main library will be received and executed.

It is important to note that when the slave library begins to copy, it will first empty its own data.

The above is a brief introduction to the creation steps of redis master-slave replication. Of course, the differences in the detailed use of the above still need to be understood by everyone. If you want to know more, welcome to follow the industry information channel!

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