In order to provide the latest dump of prod data to QA or PreProd, Staging Environments , we need to take the snapshot from prod servers and restore in respective servers.
In this case we need to change the replica set names as well as hostnames.
1) Replica set name change
To change the replica set name we need to start the mongodb in standalone mode and then execute the below commands.
In this case we need to change the replica set names as well as hostnames.
1) Replica set name change
To change the replica set name we need to start the mongodb in standalone mode and then execute the below commands.
use local
var doc = db.system.replset.findOne({ "_id": "crs1" })
doc._id = 'crs0'
db.system.replset.save(doc)
db.system.replset.remove({_id:'crs1'})
2) Updating the host name(below command for one primary two secondary servers)
var doc = db.system.replset.findOne({ "_id": "crs1" })
doc._id = 'crs0'
db.system.replset.save(doc)
db.system.replset.remove({_id:'crs1'})
2) Updating the host name(below command for one primary two secondary servers)
use local
cfg = db.system.replset.findOne( { "_id": "crs0" } )
cfg.members[0].host = "mongo01.prod.phenom.local"
cfg.members[1].host = "mongo02.prod.phenom.local"
cfg.members[2].host = "mongo03.prod.phenom.local"
db.system.replset.update( { "_id": "crs0" } , cfg )
cfg = db.system.replset.findOne( { "_id": "crs0" } )
cfg.members[0].host = "mongo01.prod.phenom.local"
cfg.members[1].host = "mongo02.prod.phenom.local"
cfg.members[2].host = "mongo03.prod.phenom.local"
db.system.replset.update( { "_id": "crs0" } , cfg )
Below command for one primary one secondary one arbiter servers
use local
cfg = db.system.replset.findOne( { "_id": "rs1" } )
cfg.members[0].host = "qa-mongo01.aws.phenom.local"
cfg.members[1].host = "qa-mongo02.aws.phenom.local"
cfg.members[2].host = "qa-mongo03.aws.phenom.local"
cfg.members[2].arbiterOnly=true
db.system.replset.update( { "_id": "rs1" } , cfg )
use local
cfg = db.system.replset.findOne( { "_id": "rs1" } )
cfg.members[0].host = "qa-mongo01.aws.phenom.local"
cfg.members[1].host = "qa-mongo02.aws.phenom.local"
cfg.members[2].host = "qa-mongo03.aws.phenom.local"
cfg.members[2].arbiterOnly=true
db.system.replset.update( { "_id": "rs1" } , cfg )
Comments
Post a Comment