简体   繁体   中英

mongodb - can't initiate replica set with default configuration

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.

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM