I am using the Ubuntu 18.04 MongoDB one click installation droplet. I have setup three droplets, and want to set up a replica set. I was trying to follow some tutorials:
[and here] (https://www.digitalocean.com/community/tutorials/how-to-implement-replication-sets-in-mongodb-on-an-ubuntu-vps)
I am stuck at setting a bindIp, and whenever I add the IP of my other droplets to bindIp, mongod won’t start, failing with this error:
Mar 31 15:52:01 db3.muhive.com systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Mar 31 15:52:01 db3.muhive.com systemd[1]: mongod.service: Failed with result 'exit-code'.
To be clear, this works:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
but this doesn’t
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,db1.munhive.com,db2.munhive.com,db3.munhive.com
Pinging each of those individually does work though. How do I set this up? Do I need to configure a private network?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
We have documentation to configure remove access for mongodb, Please feel free to check it out:
https://www.digitalocean.com/community/tutorials/how-to-configure-remote-access-for-mongodb-on-ubuntu-20-04
In the /etc/mongod.conf file make changes to bindIP as below to three mongodb nodes when you are setting up replication.
In mongodb1 server
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,mongodb1
In mongodb2 server
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,mongodb2
In mongodb3 server
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,mongodb3
Once you made these changes, restart mongod service on all 3 nodes.
Always when you are binding to a non-localhost, please make sure to secure the database by enabling authentication.
https://www.digitalocean.com/community/tutorials/how-to-secure-mongodb-on-ubuntu-20-04
Hope this helps!
Regards, Rajkishore
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
