In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what are the steps of Redis master-slave replication". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How Redis replication works:
1. If a Slave is set, it issues a SYNC command whether it connects for the first time or reconnects to the Master
two。 When Master receives the SYNC command, it does two things:
A) Master executes BGSAVE, that is, saving data to disk in the background (rdb snapshot file)
B) Master also buffers newly received commands for writing and modifying datasets (non-query class)
3. When Master saves the data to the snapshot file in the background, Master transfers the snapshot file to Slave, and Slave clears the memory and loads the file into memory
4. And Master will also forward the commands previously collected into the buffer to Slave,Slave to execute these commands in the form of Reids command protocol to achieve synchronization with Master.
5. Since then, Master/Slave will continue to synchronize commands asynchronously to achieve the same synchronization of the final data.
To connect to the master server from the server:
Master server-side operations:
1. Wait for the order to enter.
two。 Start executing BGSAVE and use a buffer to record all write commands executed after BGSAVE
When the 3.BGSAVE execution is complete, the snapshot file is sent to the slave server, and the write command executed is recorded using the buffer during the sending.
4. When the snapshot file is sent, the write command stored in the buffer is sent to the slave server.
5. The write command stored in the buffer has been sent; from now on, for each write command executed, the same write command is sent to the server.
Operate from the server side:
1. Connect (or reconnect) the primary server and send the SYNC command
two。 Depending on the configuration options, decide whether to use existing data (if any) to process the client's command request or to return an error to the client that sent the request
3. Discard all old data (if any) and start loading snapshot files from the primary server
4. Complete the interpretation of the snapshot file and start accepting command requests as usual
5. Execute all write commands stored in the buffer from the master server; and receive and execute every write command from the master server from now on
This is the end of the content of "what are the steps of Redis master-slave replication". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.