mongodb 如何在我的 mac 上部署测试 replset 时修复“EMPTYUNREACHABLE”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12897521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I fix "EMPTYUNREACHABLE" on deploying a test replset on my mac?
提问by Wu Yupu
I'm trying to deploy a development/test replication set on my macbook pro using this document.
我正在尝试使用此文档在我的 macbook pro 上部署开发/测试复制集。
http://docs.mongodb.org/manual/tutorial/deploy-replica-set/
http://docs.mongodb.org/manual/tutorial/deploy-replica-set/
I started 3 instances of mongod, each on port 10001, 10002, 10003 I used the configuration file to start mongod. The configuration file below:
我启动了 3 个 mongod 实例,每个实例都在端口 10001、10002、10003 上,我使用配置文件启动了 mongod。配置文件如下:
rs0:
dbpath = /Users/Thomas/mongodb/data/rs0/
port = 10000
logpath = /Users/Thomas/mongodb/log/rs0.log
logappend = true
replSet = rs0
rs1:
dbpath = /Users/Thomas/mongodb/data/rs1/
port = 10001
logpath = /Users/Thomas/mongodb/log/rs1.log
logappend = true
replSet = rs0
rs2:
dbpath = /Users/Thomas/mongodb/data/rs2/
port = 10002
logpath = /Users/Thomas/mongodb/log/rs2.log
logappend = true
replSet = rs0
And using the following command to start:
并使用以下命令启动:
mongod -f config/rs0.conf
mongod -f config/rs1.conf
mongod -f config/rs2.conf
then I connect to it using mongo: mongo localhost:10001, but when I use rs.initiate() command to initialize the repl set, it failed.
然后我使用 mongo 连接到它:mongo localhost:10001,但是当我使用 rs.initiate() 命令初始化 repl 集时,它失败了。
> rs.initiate()
{
"startupStatus" : 4,
"info" : "rs0",
"errmsg" : "all members and seeds must be reachable to initiate set",
"ok" : 0
}
and check by rs.status()
并通过 rs.status() 检查
> rs.status()
{
"startupStatus" : 4,
"errmsg" : "can't currently get local.system.replset config from self or any seed (EMPTYUNREACHABLE)",
"ok" : 0
}
And the log shows it's a EMPTYUNREACHABLE error. how could solve it?
并且日志显示这是一个 EMPTYUNREACHABLE 错误。怎么解决呢?
***** SERVER RESTARTED *****
Mon Oct 15 22:02:31 [initandlisten] MongoDB starting : pid=568 port=10000 dbpath=/Users/Thomas/mongodb/data/rs0/ 64-bit host=bogon
Mon Oct 15 22:02:31 [initandlisten]
Mon Oct 15 22:02:31 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Mon Oct 15 22:02:31 [initandlisten] db version v2.2.0, pdfile version 4.5
Mon Oct 15 22:02:31 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Mon Oct 15 22:02:31 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Mon Oct 15 22:02:31 [initandlisten] options: { config: "config/rs0.conf", dbpath: "/Users/Thomas/mongodb/data/rs0/", logappend: "true", logpath: "/Users/Thomas/mongodb/log/rs0.log", port: 10000, replSet: "rs0", rest: "true" }
Mon Oct 15 22:02:31 [initandlisten] journal dir=/Users/Thomas/mongodb/data/rs0/journal
Mon Oct 15 22:02:31 [initandlisten] recover : no journal files present, no recovery needed
Mon Oct 15 22:02:31 [websvr] admin web console waiting for connections on port 11000
Mon Oct 15 22:02:31 [initandlisten] waiting for connections on port 10000
Mon Oct 15 22:02:37 [rsStart] trying to contact bogon:10000
Mon Oct 15 22:02:43 [rsStart] couldn't connect to bogon:10000: couldn't connect to server bogon:10000
Mon Oct 15 22:02:49 [rsStart] replSet can't get local.system.replset config from self or any seed (yet)
Mon Oct 15 22:03:05 [rsStart] trying to contact bogon:10000
Mon Oct 15 22:03:11 [rsStart] couldn't connect to bogon:10000: couldn't connect to server bogon:10000
Mon Oct 15 22:03:17 [rsStart] replSet can't get local.system.replset config from self or any seed (yet)
Mon Oct 15 22:03:33 [rsStart] trying to contact bogon:10000
Mon Oct 15 22:03:39 [rsStart] couldn't connect to bogon:10000: couldn't connect to server bogon:10000
Mon Oct 15 22:03:45 [rsStart] replSet can't get local.system.replset config from self or any seed (yet)
Mon Oct 15 22:04:01 [rsStart] trying to contact bogon:10000
Mon Oct 15 22:04:07 [rsStart] couldn't connect to bogon:10000: couldn't connect to server bogon:10000
Mon Oct 15 22:04:13 [rsStart] replSet can't get local.system.replset config from self or any seed (yet)
回答by epc
Try setting bind_ip to 127.0.0.1 or add an entry for `bogon' to your /etc/hosts?
尝试将 bind_ip 设置为 127.0.0.1 或将“bogon”的条目添加到您的 /etc/hosts?
mongodb appears to be getting the hostname() for the local system but it's not resolvable.
mongodb 似乎正在获取本地系统的主机名(),但无法解析。
回答by nids
I faced the exact issue today. I was able to start mongodb but not the replica sets. I had to delete the following line from the mongod.conf file
我今天遇到了确切的问题。我能够启动 mongodb 但不能启动副本集。我不得不从 mongod.conf 文件中删除以下行
'bind_ip: "127.0.0.1"'
'bind_ip: "127.0.0.1"'
I also figured out that the mongod.conf files for mongodb and replica sets were different and stored at different locations, maybe because I brew installed the latest version of mongodb?. I found my replica set config file at "/usr/local/etc/mongod.conf".
我还发现 mongodb 和副本集的 mongod.conf 文件不同并且存储在不同的位置,可能是因为我 brew 安装了最新版本的 mongodb?我在“/usr/local/etc/mongod.conf”中找到了我的副本集配置文件。
回答by Adam Comerford
FYI, I believe you hit this bug in 2.2.0:
仅供参考,我相信您在 2.2.0 中遇到了这个错误:
https://jira.mongodb.org/browse/SERVER-7367
https://jira.mongodb.org/browse/SERVER-7367
It is now fixed and scheduled for release in 2.2.1 - the fixes for 2.2.0 basically involve making sure that you use resolvable and reachable addresses for your sets because 2.2.0 tries to reach even local instances over the network.
它现在已修复并计划在 2.2.1 中发布 - 2.2.0 的修复主要涉及确保您为您的集合使用可解析和可访问的地址,因为 2.2.0 试图通过网络访问甚至本地实例。

