In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
resynchronization of replica set members
When replication fails and falls short of the maximum allowable range of oplog in primary, replica set members become stale. The node cannot catch up with the master node and becomes "stale." When this happens, we have to delete their data files and resynchronize them via initial sync.
This tutorial covers resynchronizing stale nodes with new nodes. When synchronizing a node, make sure that the machine has enough free bandwidth and try to do it during maintenance time or when the traffic is least busy.
MongoDB provides two ways to initialize synchronization:
a. Empty the data directory, restart the mongod instance, and let MongoDB perform normal initialization synchronization. This is a simple way, but it takes a long time.
b. Copy a copy of the most recent data file from another node for that machine and restart it. This method has many steps, but it is the fastest.
step
automatic synchronization
warning
Mongod will empty dbPath during initialization synchronization.
This step relies on MongoDB's own periodic process, initial sync. This will restore the most recent data on the node. For MongoDB initialization recovery, refer to the replication process.
If the instance has no data, we can add a node to the replication set by adding a node to the replication set or replacing the replication set node.
We can also force-initialize a mongod instance in a replication set by specifying an empty dbPath and restarting it.
Close the mongod process. Safe shutdown is achieved by using the db.shutdownServer() command in the mongo window or by using the mongod --shutdown parameter on Linux systems.
b. Clear the data directory and child directories of the replication set node, clear the data in dbPath, MongoDB will re-replicate. Consider making backups before doing so just in case.
At this point, mongod will initiate replication. The time taken to initialize replication depends on the amount of database data and the network between the two nodes.
Initializing replication will affect other nodes and increase network traffic pressure on the master node, and will only occur when one node has up-to-date data and no connection problems.
Synchronization by copying data files from other nodes
This method works by using data files on existing nodes. The data file must be relatively new (able to catch up with oplog). Otherwise, the node still needs to be initialized.
replication data file
We can copy data files directly or we can mirror them. However, in most cases, we should not copy the data files of an instance of mongod that is not closed, because the data files will change during copying.
important
When copying data files, we must also copy data files from the local database.
We * should * not * use backups of mongodump as data files, only file snapshots. For information on how to obtain consistent data files across running mongod instances, refer to MongoDB backup scenarios.
synchronization nodes
After we copy the data files from the other nodes, we launch the mongod instance, which will catch up with the latest data until the data is consistent.
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.