Mongodb “我怎样才能解决问题?”;“清空无法到达”;在我的mac上部署测试应答集?

Mongodb “我怎样才能解决问题?”;“清空无法到达”;在我的mac上部署测试应答集?,mongodb,localhost,replication,Mongodb,Localhost,Replication,我正试图使用此文档在macbook pro上部署一个开发/测试复制集 我启动了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: dbpat

我正试图使用此文档在macbook pro上部署一个开发/测试复制集

我启动了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
并使用以下命令启动:

mongod -f config/rs0.conf
mongod -f config/rs1.conf
mongod -f config/rs2.conf
然后我使用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
}
并由rs.status()检查

日志显示这是一个无法访问的错误。怎么解决呢

***** 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)

尝试将bind_ip设置为127.0.0.1,或在/etc/hosts中添加“bogon”条目


mongodb似乎正在获取本地系统的主机名(),但它无法解决。

我今天遇到了确切的问题。我能够启动mongodb,但无法启动副本集。我不得不从mongod.conf文件中删除以下行

'绑定ip:“127.0.0.1”'


我还发现mongodb和副本集的mongod.conf文件不同,存储在不同的位置,可能是因为我安装了最新版本的mongodb?。我在“/usr/local/etc/mongod.conf”找到了我的副本集配置文件。

仅供参考,我相信您在2.2.0中遇到了这个错误:


它现在已修复,并计划在2.2.1中发布-2.2.0的修复基本上涉及确保为您的集合使用可解析和可访问的地址,因为2.2.0尝试通过网络访问本地实例。

哦,非常感谢,我尝试了/etc/hosts方法,问题已经解决。再次感谢你。
***** 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)