1. Delete the old document Db.remove ({}) first;
2. Remove the members to be cleaned from the replica set:
(1) Primary server in the replica set (/opt/mongo1/bin/mongo--port 27017)
(2) Rs.remove ("192.168.1.54:27019")
3. Close the MongoDB server you want to clean up
(1) Login to the MongoDB server to be cleaned (/opt/mongo2/bin/mongo--port 27018)
(2) User admin; Db.shutdownserver ();
4. Modify the MongoDB startup parameters and run
Bin/mongod--dbpath/home/mongodata2/data--port 27018--logpath=/home/mongodata2/logs/mongodb2.log--repair-- Repairpath/opt/data
5. Confirm Mongod Run End
Can be used PS Axu | grep Mongod to see if the process has ended.
You can also see if the log file/home/mongodata2/logs/mongodb2.log has the following output:
2016-05-10t13:14:41.646+0800 [conn5413] Dbexit:shutdown called
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:going to close listening sockets ...
2016-05-10t13:14:41.646+0800 [conn5413] closing listening socket:8
2016-05-10t13:14:41.646+0800 [conn5413] closing listening socket:10
2016-05-10t13:14:41.646+0800 [conn5413] removing socket file:/tmp/mongodb-27018.sock
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:going to flush diaglog ...
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:going to close sockets ...
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:waiting for FS preallocator ...
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:lock for final commit ...
2016-05-10t13:14:41.646+0800 [conn5413] shutdown:final commit ...
2016-05-10t13:14:41.647+0800 [conn5413] shutdown:closing All Files ...
2016-05-10t13:14:41.832+0800 [conn5413] Closeallfiles () finished
2016-05-10t13:14:41.832+0800 [conn5413] journalcleanup ...
2016-05-10t13:14:41.832+0800 [conn5413] Removejournalfiles
2016-05-10t13:14:41.889+0800 [conn5413] shutdown:removing FS lock ...
2016-05-10t13:14:41.889+0800 [conn5413] dbexit:really exiting now
6. Finally start Mongod in normal mode and add members to the replica set
Primary servers in the replica set
Rs.add ("ipaddr:27018")
To view the run result of a replica set: Rs.printslavereplicationinfo ()
MongoDB free disk space