I started up a few MongoDB replica sets with the default configuration and added them to Cloud Manager, but since the default replica set name is "rs0", they're hard to tell apart in the UI. Is there a way to change the name of a replica set, preferably without having to drop and re-import all of the data in the cluster?
I've tried using rs.reconfig
(link) but it doesn't allow you to change the replica set name.
You can easily change the number of pods a particular ReplicaSet manages in one of two ways: Edit the controllers configuration by using kubectl edit rs ReplicaSet_name and change the replicas count up or down as you desire. Use kubectl directly. For example, kubectl scale –replicas=2 rs/web.
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 .
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.
Yes! The process is pretty simple:
mongod
on each servermongod
back up. If you use /etc/mongod.conf
, remove the replication
section. If you don't, omit the --replSet
option to mongod
Flush the local
database where the replication set configuration is cached
use local; db.dropDatabase()
(Make sure that admin user / root user has dbAdmin
role on local
db)Start all of the nodes again in replicated mode
mongod
on each server/etc/mongod.conf
, add the replication
section back in with the new name and start mongod
. If not, start mongod
with --replSet <new-name>
rs.initiate()
. DO NOT pass any arguments to rs.initiate()
. (It'll fail with an error) Any other config you want to set can be changed using rs.reconfig()
later.rs.initiate()
, for each secondary, run rs.add('[secondary.host.name]')
to add it to the replica set.This doesn't require you to dump and re-import your data, and it can be done with minimal downtime (and a period of degraded performance as the secondaries sync) if you automate it.
Here's an ansible playbook that does the whole thing (assuming you're using /etc/mongod.conf
and managing mongod
via System V/Upstart/things that speak service
.)
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