2016-11-21 499 views
0

我正在研究MongoDBUniversityM101P:MongoDB for Developers当然。“此节点没有启动replSet选项”

我正在使用WiredTiger on MongoDB 3.2

我目前的主题是副本集

的课程要求我用下面的代码创建一个副本集:

mongod --replSet rs1 --logpath "1.log" --dbpath /data/rs1 --port 27017 --fork 

但我使用的是Windows,它不支持fork,因此使用this要点(所推荐的课程管理员)我在3个不同的控制台这些线路同时运行我已经创建的目录(与mongod的运行)后:

mongod --replSet rs1 --logpath "1.log" --dbpath rs1 --port 27018 --smallfiles --oplogSize64 
mongod --replSet rs1 --logpath "2.log" --dbpath rs2 --port 27019 --smallfiles --oplogSize64 
mongod --replSet rs1 --logpath "3.log" --dbpath rs3 --port 27020 --smallfiles --oplogSize64 

这一切似乎做工精细;我可以看到目录已经填满,日志文件都显示“正在等待连接”并显示相关的端口号。

最后,我运行下面的代码统一服务器作为副本集:

config = {_id: "rs1", members: [ 
      { _id: 0, host: "localhost:27018"}, 
      { _id: 1, host: "localhost:27019"}, 
      { _id: 2, host: "localhost:27020"} 
           ] 
     } 

rs.initiate(config) 
rs.status() 

这是抛出:

"errmsg" : "This node was not started with the replSet option", 
"code" : 76 

,我可以不在身边让我的头,如我已经明确使用每个服务器的--replSet选项,并且确实提供了与配置文件中使用的相同的replSet名称。

我已经看过关于这个主题的其他问题,但是很少有,并且我没有找到可以解决这个问题的地址。 This一个陈述了从错误看起来很明显:我的配置文件应包括--replSet=rs1,但是从阅读documentation我给大家的印象,我已经定义了配置的_id服务这一目的:

_id
Type: string

The name of the replica set. Once set, you cannot change the name of a replica set.

_id must be identical to the replication.replSetName or the value of –replSet specified to mongod on the command line.

此外,这清楚地显示在课程材料视频演示中正确运行,正如我试图使用它的方式。

我在我的智慧结束,并非常感谢帮助。
杰克

回答

3

所以当我写完这个问题,答案只是来找我就像一个灯泡,这似乎经常发生......但这次我想我会离开这里回答为别人谁一直在努力考虑到论坛上有关此主题的问题/答案有些缺乏。

这是运行我的配置文件时使用的默认端口的简单情况。
我正在使用mongo < init_replica.js来运行我的配置并统一服务器来创建副本集。

通过简单地增加通过有效的服务器之一使用的端口,它正确地跑:

mongo --port 27020 < init_replica.js 

祸是我要的那一个,但我希望这可以帮助那些还在研究谁发现自己的某个地方卡住课程类似。

杰克