MongoDB add replica-set to external server by ip

115 views Asked by At

I have created 3 Digitalocean droplet. By default, I choose Ubuntu 18.06 and MongoDB 4. Here I have 3 droplets by default MongoDB config and all are up. I have access to "mongo" shell for all of them.

Now I want to run a replica-set setting by this code:

rs.initiate( 
    {_id : "rs0",
    members: [
        { _id: 0, host: "20.30.40.50:27017" },
        { _id: 1, host: "20.30.40.51:27017" },
        { _id: 2, host: "20.30.40.52:27017" }
    ]
})

In this config, I just told MongoDB that rune the replica set and it retrieves me the error

no replies config has been received

I did not add any bindIp yet also when I added bindIp, I could not start MongoDB again. I put in mongo.conf like this:

bindIp: 127.0.0.1,20.30.40.51,20.30.40.52

Also, There is a private network between these 3 droplets by IP example: 10.10.1.1 Can I take advantage of this private IP to make it easier and safer?

0

There are 0 answers