mongodb replicaset host name change error

后端 未结 2 367
礼貌的吻别
礼貌的吻别 2021-02-04 16:42

I have a mongodb replicaset on ubuntu.. In replica set, hosts are defined as localhost. You can see ;

{
    \"_id\" : \"myrep\",
    \"version\" : 4,
    \"membe         


        
相关标签:
2条回答
  • 2021-02-04 17:11

    There is a cleaner way to do this:

    use local
    cfg = db.system.replset.findOne({_id:"replicaSetName"})
    cfg.members[0].host="newHost:27017"
    db.system.replset.update({_id:"replicaSetName"},cfg)
    

    then restart mongo

    0 讨论(0)
  • 2021-02-04 17:31

    The only way I found to change host names is recreating replica set.. To make it right db directories need to be cleaned.. Then starting all servers with replication mode after that creating new repset with new host names fixed it.

    0 讨论(0)
提交回复
热议问题