Josh Elias Josh Elias - 1 month ago 7
Linux Question

Stop Replica Set MongoDB

The command to start a Replica Set in the MongoDB Shell is rs.initiate().

What is the opposite of this command. How do I stop the replica set?

There are commands to reconfigure the set or remove members but no way that I know off to remove the last member and therefore destroy the Replica Set.

Answer

It all depends on what your goal is. If you want to reuse the existing mongod as a standalone server rather than a replica set member then the steps to do that would be:

  1. Restart mongod process without --replSet argument.
  2. Drop the local database:

    use local;
    db.dropDatabase();