If so, how?
When I first created the replica set, I chose a confusing name; I'd like to change it now.
The replica set name is mentioned in /etc/mongod.conf
, and I'm not sure when it reads/rereads that. Since the replica set name can also be passed in as a command-line parameter, I'm assuming (and currently testing) the following:
replSet
CLI argument or replSet
value in /etc/mongod.conf
, then restartIn other words, I'm assuming the answer to my original question is "no, you must restart" or "no, replica set name is immutable". I'll probably figure this out soon enough since I'm trying it locally.
On MongoDB Atlas project page, select the Deployment link on the left hand side menu. Under Processes tab, with Topology view you should see the replica set name (this should be the default view presented when you click on Deployment ). Generally, the replica set name is the cluster name plus -shard-0 .
MongoDB achieves replication by the use of replica set. A replica set is a group of mongod instances that host the same data set. In a replica, one node is primary node that receives all write operations. All other instances, such as secondaries, apply operations from the primary so that they have the same data 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).
Here's how to do it with downtime:
Update the local.system.replset doc on each server with the new replica set name. You have to change every server here.
Here is how to update local.system.replset in mongo shell:
use local
var doc = db.system.replset.findOne()
doc._id = 'NewReplicaSetName'
db.system.replset.save(doc)
db.system.replset.remove({_id:'OldReplicaSetName'})
kristina's answer is good, but step 3 could use a little more explanation. In your mongo shell, edit db.system.replset like this:
use local
var doc = db.system.replset.findOne()
doc._id = 'NewReplicaSetName'
db.system.replset.save(doc)
db.system.replset.remove({_id:'OldReplicaSetName'})
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