Hi @James_58604 ,
Removing a Member from Replica Set:
Shutdown your node which you want to remove. Two ways to do this:
Kill the mongod process by checking pid through the command below. The first column will show pid
. Make sure you kill only the respective node process.
vagrant@m103:~$ ps -ef | grep mongod
501 2809 2568 0 5:12PM ttys000 0:00.00 grep mongod --port 27002 --dbpath...
520 2809 2568 0 5:12PM ttys000 0:00.00 grep mongod --port 27001 --dbpath...
vagrant@m103:~$ kill 501
Or Connect to the respective node, run:
db.shutdownServer()
Connect to your primary node of your replica set using mongo --port 27xxx
Authenticate yourself on admin
:
> use admin
> db.auth("m103-admin","m103-pass")
Run rs.remove("...")
. Example:
> rs.remove("192.168.103.100:27027")
In this pinned post , we have recommended to first shutdown the node before removing it from the replica set.
You can do it either ways :
kill <pid>
Connect to the node which you want to remove from your replica set and run this command.
db.shutdownServer()
And then finally authenticate yourself against the admin db if you have not done it already and then run the rs.remove("...")
command.
It’s mentioned here.
The answer is no. rs.remove() removes a node from the replica set and the other two commands just shut down the mongod instances.
Hope it helps!
If you have any other query then please feel free to get back to us.
Happy Learning
Thanks,
Shubham Ranjan
Curriculum Support Engineer