mongodb副本集主机名更改错误 [英] mongodb replicaset host name change error

查看:261
本文介绍了mongodb副本集主机名更改错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubuntu上有一个mongodb副本集.在副本集中,主机定义为localhost.您可以看到;

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

{
    "_id" : "myrep",
    "version" : 4,
    "members" : [
            {
                    "_id" : 0,
                    "host" : "localhost:27017"
            },
            {
                    "_id" : 2,
                    "host" : "localhost:27018"
            },
            {
                    "_id" : 1,
                    "host" : "localhost:27019",
                    "priority" : 0
            }
    ]

}

我想用服务器的真实IP更改主机地址.但是当我运行rs.reconfig时,出现错误:

I want to change host adresses with real ip of server. But when i run rs.reconfig, I get error :

{
    "assertion" : "hosts cannot switch between localhost and hostname",
    "assertionCode" : 13645,
    "errmsg" : "db assertion failure",
    "ok" : 0

}

我该如何解决? 谢谢.

How can i solve it ? Thank you.

推荐答案

我发现更改主机名的唯一方法是重新创建副本集.为了使其正确,需要清理db目录.然后使用复制启动所有服务器之后,使用新的主机名创建新的repset会对其进行修复.

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.

这篇关于mongodb副本集主机名更改错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆