我正在研究MongoDBUniversity的M101P: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: stringThe 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.
此外,这清楚地显示在课程材料视频演示中正确运行,正如我试图使用它的方式。
我在我的智慧结束,并非常感谢帮助。
杰克