Downgrade MongoDB replica set to a standalone node

Now you have a MongoDB replica set and decide to downgrade it to a standalone node.

If you don’t have a replica set yet, please refer to my previous post Create a MongoDB replica set to create one to go through this article.

Remove secondary member nodes

Firstable, Shut down the mongod instance for the member you wish to remove.

Then connect to the replica set’s current primary instance.

Use rs.remove() to remove the secondary member :

Image for post
Image for post
Image for post
Image for post

Check replica set status to ensure now only Primary member is left alone.

Image for post
Image for post

Remove replication setting

Delete or comment replication setting in mongod.cfg file

On Windows, a default <install directory>/bin/mongod.cfg configuration file is included during the installation.

Shut down the Primary mongod instance.

Restart MongoDB service if you have installed it as a service.

Restart mongod instance as a single node:

To be completely sure that the replica set configuration is removed from the instance, connect to this instance and empty local.system.replset collection :

Image for post
Image for post

Also drop other replica set related collections :

Image for post
Image for post

Now welcome back to our standalone instance ! 😃

You can then restart with a different replSet argument and create a new replica set again.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store