I am taking backup of MongoDB filesystem backup(including config files). We are not using sharding in our cluster, having 3node replicaset in place.
Primary Cluster: X_host1, X_host2, X_host3 Secondary Cluster: Y_host1, Y_host2, Y_host3
Taking filesystem backup from X_host1 and restoring it to Y_Host1,2,3 (restoring to diff hostname)
So, how re-configure MongoDB to follow new hostnames? I see the replication nodes are configured into the DB (not any editable config files). Is this the right approach to migrate data from replicated mongodb cluster?
- Is this the right approach to migrate MongoDB cluster to new hostnames?
- Is there any way to re-configure new hostnames.
- AFAIK, after I restore filesystem to new nodes
- Data is from old nodes, having info about old replica nodes.(X_hosts)
- How to point it to Y_hosts
Follow Restore a Replica Set from MongoDB Backups
In principle do this:
local
database:db.getSiblingDB('local').dropDatabase()
rs.initiate()
If your database is large, initial sync can take a long time to complete. For large databases, it might be preferable to copy the database files onto each host. For details have a look at linked tutorial.