I'm trying to initialize a replica set with 3 nodes. While executing rs.initiate()
I got the following error: "No host described in new configuration 1 for replica set ##### maps to this node"
If I try to set the first member to "localhost:27017" then I get the following error: "Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2"
How am I supposed to use my public ip to initiate the replica set?
What you need to do is to prepare the configuration that you want to use for the replica set in a document (for example
config
), and then passing this document as a parameter to thers.initiate(config)
method, like this:More details in MongoDB - replSetInitiate command