mongodb - can't initiate replica set with default configuration

时光总嘲笑我的痴心妄想 提交于 2019-12-25 05:22:52

问题


I am following this tutorial to deploy a replica set. When I execute rs.initiate() I get the error "all members and seeds must be reachable to initiate set" which is strange given that the only member is localhost.


回答1:


I had the same error. In my case the helped me:

cfg=rs.conf()
rs.reconfig(cfg,{force:true})



回答2:


You cannot initiate a replica set with just one member (where do you replicate data ?!). The tutorial tells you that three active mongod instances are needed.

Requirements: Three distinct systems, so that each system can run its own instance of mongod.




回答3:


For testing purposes, you can have the three members of a given replica set on the same physical machine (The tutorial mentions: "For ephemeral tests and the purposes of this guide, you may run the mongod instances in separate windows of GNU Screen.") You just need three different mongod instances running on three different ports on your machine. From the error you are getting, it seems one or the other port is unreachable. Just check your ports if they are already in use by some other application. If so, the respective mongod wouldn't start successfully in the first place. And therefore, rs.initiate() would fail.



来源:https://stackoverflow.com/questions/12462167/mongodb-cant-initiate-replica-set-with-default-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!