0

Can I configure MongoDB DB replica sets using IP addresses alone instead of host names?

Usually an IP address can be used almost everywhere a host name is expected. But our main Mongo DB expert led me to believe that we must use hostnames sharing a common domain such as: db1.domain.com, db2.domain.com...

Documentation for replica set rs.initiate() does not say anything about this.

Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217

1 Answers1

2

You can use IP addresses in replica set config however domain names are preferable:

The host field specifies the master mongod instance, and holds a resolvable hostname, i.e. IP address, or a name from a host file, or preferably a fully qualified domain name.

Host is defined here

mickl
  • 48,568
  • 9
  • 60
  • 89