Search code examples
mongodbreplicaset

How to convert a MongoDB replica set to a stand alone server


Consider, I have 4 replicate sets and the config is as follows:

{
 "_id": "rs_0",
 "version": 5,
 "members" : [
  {"_id": 1, "host": "127.0.0.1:27001"},
  {"_id": 2, "host": "127.0.0.1:27002"},
  {"_id": 3, "host": "127.0.0.1:27003"},
  {"_id": 4, "host": "127.0.0.1:27004"}
 ]
}

I am able to connect to all sets using mongo --port <port>

There are documents for getting information on Convert a Standalone to a Replica Set, but can anyone tell me how to convert back to standalone from replica set?


Solution

  • Just remove a host from replica set (rs.remove('host:port')), relaunch it without replSet parameter and it's standalone again.