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

MongoDB initializes data synchronization

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

Share

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

MongoDB initializes data synchronization:

After a member in the replica set starts, it checks its status to determine whether synchronization can be performed from a member. If not, try to copy the data completely from other members.

This process is called initialization synchronization (initial syncing), which can be viewed from the mongod log.

1. First of all, the member will do some preparatory work before recording: select a member as the synchronization source, create an identifier for himself in local.me, delete all existing databases, and replicate in a new state.

In the process, all existing data will be deleted. Initialization synchronization should be done only if there is no need to retain existing data, because mongod deletes existing data first.

2. Then there is cloning, which replicates all the records of the synchronous source locally. It's usually the most time-consuming.

3. Then enter the first step of oplogt synchronization, and all operations during the cloning process will be recorded in oplog. If a document is moved during cloning, it may be omitted, resulting in not being cloned. For such a document, it is possible

Need to be re-cloned

4. Next is the second step of the oplog synchronization process, which is used to record the operations in the first oplogt synchronization

5. So far, the local data should be exactly the same as that of the master node at a certain point in time, and the index can be created. If the collection is large, it will take time to create the index.

6. If the data of the current node still lags far behind the synchronization source, the last step of the oplog synchronization process is to record all operations during index creation to prevent the member from becoming a backup node.

7. Now that the current member has been initialized and switched to the normal synchronization state, the current member can become a backup node.

Replset initial sync done

Replset syncing

Replset secondary

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

Wechat

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

12
Report