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?
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).
You can force a replica set member to become primary by giving it a higher members[n]. priority value than any other member in the set. Optionally, you also can force a member never to become primary by setting its members[n]. priority value to 0 , which means the member can never seek election as primary.
You can deploy a standalone MongoDB instance for Cloud Manager to manage. Use standalone instances for testing and development. Do not use these deployments for production systems as they lack replication and high availability. For all production deployments use replica sets.
Remove all secondary hosts from replica set (rs.remove('host:port')), restart the mongo deamon without replSet parameter (editing /etc/mongo.conf) and the secondary hosts starts in standalone mode again.
The Primary host is tricky one, because you can't remove it from the replica set with rs.remove. Once you have only the primary node in the replica set, you should exit mongo shell and stop mongo. Then you edit the /etc/mongo.conf and remove the replSet parameter and start mongo again. Once you start mongo you are already in standalone mode, but the mongo shell will prompt a message like:
2015-07-31T12:02:51.112+0100 [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset
to remove the warning you can do 2 procedures: 1) Droping the local db and restarting mongo:
use local db.dropDatabase(); /etc/init.d/mongod restart
2)Or if you don't want to be so radical, you can do:
use local db.system.replset.find()
and it will prompt a message like:
{ "_id" : "replicaSetName", "version" : 1, "members" : [ { "_id" : 0, "host" : "hostprimary:mongoport" } ] }
then you will erase it using:
db.system.replset.remove({ "_id" : "replicaSetName", "version" : 1, "members" : [ { "_id" : 0, "host" : "hostprimary:mongoport" } ] })
and it will probably prompt:
WriteResult({ "nRemoved" : 1 })
Now, you can restart the mongo and the warning should be gone, and you will have your mongo in standalone mode without warnings
Just remove a host from replica set (rs.remove('host:port')
), relaunch it without replSet
parameter and it's standalone again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With