标签:uri MLOG fork cat 2.0 配置命令 bpa mongodb tor
问题描述:在给客户搭建环境的时候,在初始化一个MongoDB副本集的过程中,出现了初始化失败,报"No host described in new configuration 1 for replica set mongotest maps to this node"。具体报错信息如下(为保护客户隐私,IP均经过处理):
2018-06-20T11:51:45.695+0800 I CONTROL [initandlisten]
> config = { _id:"mongotest", members:[ {_id:0,host:"10.0.0.217:27017"}] };
{
"_id" : "mongotest",
"members" : [
{
"_id" : 0,
"host" : "10.0.0.217:27017"
}
]
}
> rs.initiate(config);
{
"ok" : 0,
"errmsg" : "No host described in new configuration 1 for replica set mongotest maps to this node",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
>
在执行 config = { _id:"mongotest", members:[ {_id:0,host:"10.0.0.217:27017"}] };的时候成功了,但是执行 rs.initiate(config);的时候一直在报这个错误。
看到"No host described in new configuration 1 for replica set mongotest maps to this node"的提示,怀疑是命令行和mongo.conf文件里面的配置不一致,但是查看配置文件,确实配置的是mongotest:
[root@10-0-0-217 ~]# cat /etc/mongodb/mongo.conf
systemLog:
destination: file
path: "/opt/mongodb/mongod.log"
logAppend: true
storage:
journal:
enabled: true
dbPath: /opt/mongodb
setParameter:
enableLocalhostAuthBypass: true
replication:
replSetName: mongotest #和执行的命令行是一致的,没有问题
processManagement:
fork: true
pidFilePath: "/opt/mongodb/mongod.pid"
security:
authorization: enabled
keyFile: "/etc/mongodb/mongodb-keyfile"
[root@10-0-0-217 ~]#
于是想到会不会是IP的问题。
因为进入这台机器是用的堡垒机进去,机器的hostname和命令行窗口显示的机器IP都是10.0.0.217。但是实际上本机的IP并不是这个,ifconfig查看真实的IP地址实际为172.0.2.12,而不是hostname显示的10.0.0.217.在配置命令行的时候,直接用了hostname的IP,因此出现了这个报错。
将命令中的IP替换为正确的IP,然后再在MongoDB命令行里面重新执行命令,就OK了:
2018-06-20T11:51:45.695+0800 I CONTROL [initandlisten]
> config = { _id:"mongotest", members:[ {_id:0,host:"172.0.2.12:27017"}] };
{
"_id" : "mongotest",
"members" : [
{
"_id" : 0,
"host" : "172.0.2.12:27017"
}
]
}
> rs.initiate(config); #这次就不再报错了
{ "ok" : 1 }
mongotest:OTHER>
mongotest:SECONDARY>
mongotest:PRIMARY>
mongotest:PRIMARY>
mongotest:PRIMARY>
mongotest:PRIMARY>
单点的副本集就好了。
标签:uri MLOG fork cat 2.0 配置命令 bpa mongodb tor
原文地址:http://blog.51cto.com/10950710/2130904