How to re-hang the mongo replica set slave server for a long time to re-attach to the set

  
 

Background: The replica set of normal work 1 Master 2 decides from 1 and hangs one (master or slave) and is named F. Then remove the hanged machine F from rs.conf(). After a month, F was repaired, the hard drive was not broken, the data was still there, but it was already very outdated data.

Requirement: Re-mount this machine F into the replica set.

Steps: 0) Close the mongodb above F. The insurance method is to use db.shutdownServer();

1) On the primary server, rs.add() adds F to the configuration of the replica set.

You need to set F to hidden state to prevent the front-end module from connecting to this machine. .

When this value is true, the replica set hides this instance and does not include the member in the output of db.isMaster() or isMaster. This prevents read operations (ie queries) from ever reaching this host by Way of secondary read preference.

rs.add({_id: 10, host: “mongodb3.example.net:27017″, priority: 0, hidden: true})

priority A value of 0 indicates that it does not participate in the voting to become the activity of the primary server.

2) Delete all directories and files in the dbpath of F.

3) Start mongodb on F

cd /home/mongodb && numactl –interleave=all ./bin/mongod -f ./conf/mongod.conf > /dev/null 2>&1

Then the automatic master-slave synchronization starts.

4) Consider removing the hidden and priority attributes.

Copyright © Windows knowledge All Rights Reserved