2016-12-23 81 views
3

(跨發佈https://github.com/Automattic/mongoose/issues/4834MongoError:無原發於replicaset發現

這是mongodb - 3.4.0最新版本(蒙戈:從泊塢窗最新)(貓鼬與內部地址gcloud替換外部IP地址)和我已經安裝了Google計算引擎上的mongo羣集。每個mongo服務器有一個external和一個internalIP address

我可以使用相同的nodejs代碼連接到單個的mongo節點。但是,當我同時使用IP地址(mongodb:// IP-ADDR1,IP-ADDR2)時,我得到'沒有發現主要錯誤'。

從它看起來像日誌,MongoDB的連接到每個服務器的URL和如下獲取拓撲相關的數據結構(ismaster),

ismaster [{"hosts":["10.60.4.5:27017","10. 60.4.6:27017"],"setName":"rs0","setVersion":4,"ismaster":false,"secondary":true,"primary":"10.60.4.5:27017","me":"10. 60.4.6:27017","lastWrite":{"opTime":{"ts":"6367309576328445953","t":1},"lastWriteDate":"2016-12-23T14:53:07.000Z"},"m axBsonObjectSize":16777216,"maxMessageSizeBytes":48000000,"maxWriteBatchSize":1000,"localTime":"2016-12-23T14:53:13.7 21Z","maxWireVersion":5,"minWireVersion":0,"readOnly":false,"ok":1}]

這裏它看到ismaster.me不一樣的IP-ADDR用於調用connect命令(ismaster.me是內部IP地址)。下面哪個,蒙戈從種子列表中的原始IP地址,如下圖所示:

[WARN-ReplSet:9532] 1482504793904 the seedlist server was removed due to its address 104.197.115.7:27017 not matching its ismaster.me address 10.60.4.6:27017 { type: 'warn'

最後這會導致「no primary found in replicaset

再登錄細節都貼有鏈接 - https://github.com/Automattic/mongoose/issues/4834

TIA。

請讓我知道我的分析是否正確,以及我們是否知道解決問題的方法。

回答

2

從Mongodb nodejs本地驅動程序團隊(通過Christian Amor Kvalheim)收到響應。

這是預期的行爲,複製組配置是複製組的標準來源,並且是驅動程序用來連接,監控和發現新成員的組件。如果您不能解決這些問題,您需要修改主機文件以包含它們以進行本地dns解析。

http://mongodb.github.io/node-mongodb-native/2.2/reference/faq/