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 the rs.initiate(config) method, like this:
config = {
_id : "your_replica_set_name",
members : [
{_id : 0, host : "yourIpAddress:port1"},
{_id : 1, host : "yourIpAddress:port2"},
{_id : 2, host : "yourIpAddress:port3", arbiterOnly: true},
]
}
rs.initiate(config)
More details in MongoDB - replSetInitiate command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With