Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Replica Set MongoDB

Tags:

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.

like image 760
Josh Elias Avatar asked May 28 '13 20:05

Josh Elias


People also ask

How do you stop a replica set?

The most common way is to just stop the mongod , since you must restart the mongod without the replica option to actually stop it from trying to use the replica set. When I start mongo after doing that it give me this warning: "WARNING: mongod started without --replSet yet 1 documents are present in local. system.

How do I reset my replica set?

To reset the configuration, make sure every node in your replica set is stopped. Then delete the "local" database for every node. Once you are confident all nodes are not running and the local database are gone, start the mongod process again (of course using the --replSet flag).

What are MongoDB replica sets?

A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments. This section introduces replication in MongoDB as well as the components and architecture of replica sets.

How do I shut down MongoDB?

One liners to start or stop mongodb service using command line; To start the service use: NET START MONGODB. To stop the service use: NET STOP MONGODB.


1 Answers

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(); 
like image 59
Asya Kamsky Avatar answered Sep 21 '22 13:09

Asya Kamsky