Im trying to initialize my replica set sp that the primary node has a specific domain:port pairing. what I want is:
"vagrant-ubuntu-trusty-64:27022"
but what I get is:
"localhost:27022"
This is the command I use to start the mongo instance:
sudo mongod –port 27022 –dbpath /db/config/data –configsvr –replSet config
This is what I use to access the mongo instance:
mongo –port 27022
I tried to modify my host file to add the domain name to the default domain of 127.0.0.1, but that didn't work.
127.0.0.1 localhost
127.0.0.1 vagrant-ubuntu-trusty-64
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
How do I get the specific "vagrant-ubuntu-trusty-64:27022" pairing when I initialize the mongo instance?
Best Answer
To add replica set members with hostname, pass the host name when initializing the replica set.
Or if you want to edit the existing configuration follow the below steps