2012-10-15 27 views
6

我想使用這個文件在我的macbook pro上部署開發/測試複製集。如何在我的Mac上部署測試replset時修復「EMPTYUNREACHABLE」?

http://docs.mongodb.org/manual/tutorial/deploy-replica-set/

我開始的mongod的3個實例中,每個端口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 

然後我連接到它使用蒙戈:蒙戈本地主機: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檢查()

> rs.status() 
{ 
"startupStatus" : 4, 
"errmsg" : "can't currently get local.system.replset config from self or any seed (EMPTYUNREACHABLE)", 
"ok" : 0 
} 

和日誌顯示這是一個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) 

回答

8

嘗試將bind_ip設置爲127.0.0.1,或者將'bogon'條目添加到/ etc/hosts?

mongodb似乎獲取本地系統的hostname(),但它不可解析。

+1

哦,非常感謝你,我試了/ etc/hosts的方式,問題解決了。再次感謝你。 –

2

我今天遇到了確切的問題。我能夠啓動mongodb,但不能複製副本。我不得不從mongod.conf文件中刪除以下行

「bind_ip:‘127.0.0.1’」

我也想通了,MongoDB的和副本集的mongod.conf文件是不同的,並儲存在不同的地點,也許是因爲我安裝了最新版本的mongodb?我在「/usr/local/etc/mongod.conf」找到了我的副本集配置文件。

0

僅供參考,我相信你在2.2.0打這個錯誤:

https://jira.mongodb.org/browse/SERVER-7367

這是現在固定,並預定於發行在2.2.1 - 爲2.2.0的修復主要涉及確保你爲你的集合使用可解析和可達的地址,因爲2.2.0試圖通過網絡訪問本地實例。