In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to understand the total and incremental synchronization of Redis master-slave replication? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Full synchronization:
The 1.slave server connects to the master server and sends the SYNC command
The slave server connects to the Master server through the syncWithMaster () function (log in first if the Master server needs a password), and sends a SYNC command to request synchronization, then opens the rdb file (which is used to store the data sent by Master), and creates an IO event (readSyncBulkPayload) to read the rdb.
The 2.master server backs up the database to a .rdb file
When the slave server sends SYNC commands to the master server, the master server changes back to calling the syncCommand () function to synchronize. The first step of synchronization is to store the data in the database as rdb files, and after storage, call the updateSalvesWaitingBgsave () function to send rdb files to all slave servers. What updateSlavesWaitingBgsave () needs to do is to open the rdb file and create an IO event (sendBulkToSlave) to send rdb files. The main job of sendBulkToSlave () is to send the rdb file to the Slave server. When the Slave server has finished receiving the rdb file (processed by the readSyncBulkPayload () function), it will empty the data from the original database and then import the data from the rdb file into the database.
3. Complete in full synchronization
Complete the above steps and complete the full synchronization.
Incremental synchronization:
Incremental synchronization means that when the master server has a data update, it will be synchronized to all slave servers immediately.
1. When we add or subtract data from the master server, the replicationFeedSalves () function is triggered, and each subsequent command called on the Master server uses the replicationFeedSlaves () function to synchronize to the Slave server. Of course, before executing this function, the master server will determine whether the command executed by the user has a data update, and if there is a data update and the slave server is not empty, it will execute this function, and the main job of this function is to send the commands executed by the user to all slave servers and let the slave server execute, so that the synchronization function can be implemented.
This is the answer to the question on how to understand the full and incremental synchronization of Redis master-slave replication. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.