Hi All, I was trying to set a 3 member replica set with mongod running on 3 different servers on Azure with RHEL image. when I was trying add replica members getting error as below:
“Either all host names in a replica set configuration must
be localhost references, or none must be; found 1 out of 2”,“code” : 103,"
Tested by commenting # BindIP in configuration BindIP: 0.0.0.0 or BindIP : of the server but none helped.Could someone advise what should be the BindIP to be set on each of the server as am new to MongoDB.
You might need to look at what happened with the rs.initiate() the localhost may have been introduced there.
rs.conf() will dump out the current configuration. You can then use rs.reconfigure() with a new configuration document to change the member hostname if it is incorrect.
While this has the same outcome for a host with a single IP (and may be more convenient), I’d recommend explicitly binding to the IPs you want mongod to listen to. For a replica set member that would typically be 127.0.0.1 and a private IP.
If additional network interfaces are added in future for some reason (for example, a public IP), limiting IPs might avoid unexpectedly exposing a service that should be private (although there should also be appropriate firewall rules in place).