Resync of MongoDB replica set members

Source: Internet
Author: User
Tags install mongodb

Resync of MongoDB replica set members

Resync of replica set members

When the replication fails and lags behind the maximum tolerable range of oplog in primary, the replica set Member changes to stale ). The node cannot catch up with the master node and becomes "obsolete. In this case, we have to delete the data file and re-synchronize it through initial sync.

In this tutorial, the old node is resynchronized with the new node. When synchronizing a node, make sure that the machine has sufficient free bandwidth, and try to maintain it during the maintenance time, or when the business is least busy.

MongoDB provides the initial sync method in step 2:

A. Clear the data directory, restart the mongod instance, and perform normal initialization and synchronization for MongoDB. This is a simple method, but it takes a long time.

B. Copy the latest data file from other nodes for the machine and restart it. This method has many steps, but is the fastest.

Procedure

Automatic synchronization

Warning

During synchronization initialization, mongod clears the content in dbPath.

This step relies on MongoDB's own periodic process initial sync. This will restore the latest data on the node. For information about MongoDB initialization and recovery, see the replication process.

If the instance has no data, we can add a node to the replica set by adding a node to the replica set or replacing the replica set node.

You can also specify an empty dbPath and restart it to forcibly initialize and synchronize the mongod instance in a replica set.

A. Disable the mongod process. You can use the db. shutdownServer () command in the mongo window or use the mongod -- shutdown parameter in the Linux system to disable it safely.

B. Clear the DATA DIRECTORY And Its subdirectories of the replica set node, and clear the data in dbPath. MongoDB will re-copy the data. You can back up data before doing so, just in case.

Then, mongod will perform initialization and replication. The time used to initialize the replication depends on the data volume of the database and the network between two nodes.

The initial replication will affect other nodes, increase the network traffic pressure on the master node, and only when the data of one node is up-to-date and the connection is normal.

Synchronize data files by copying data files from other nodes

This method uses data files on existing nodes. The data file must be newer (can catch up with oplog). Otherwise, the node still needs initialization and replication.

Copy data files

We can directly copy data files or use images. However, in most cases, we should not copy the data file of the unclosed mongod instance, because the data file will change during the copy process.

Important

When copying data files, we must also copy the data files of the local database.

We * should not * use mongodump backup as a data file, and only use file snapshots. For details about how to obtain consistent data files in the running mongod instance, refer to the MongoDB backup solution.

Synchronization Node

After we copy the data files of other nodes, start the mongod instance, which will catch up with the latest data until the data is consistent.

MongoDB 3.0 official version released and downloaded

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

MongoDB beginners must read (both concepts and practices)

MongoDB Installation Guide for Ubunu 14.04

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

Nagios monitoring MongoDB sharded cluster service practice

Build MongoDB Service Based on CentOS 6.5 Operating System

MongoDB details: click here
MongoDB: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.