Hi Mongodb Community,
FIrst let me tell the issue - so what i have done is deployed a mongodb on a on-premise amazon linux server with two replicaset. What is happening is that I deployed it through docker-compose and the replicated all db with the private ip and we are also able to access out database through the mongodb compass or shell, but not able to connect through the remote ip and i want to know why, i have tried doing bindip as 0.0.0.0.
this is my docker-compose.yaml file -
version: "3.0"
volumes:
abc-mongo-keys2:
abc-mongo-data-4:
abc-mongo-data-5:
abc-mongo-data-6:
networks:
abc-cluster2:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.10.22.0/24
services:
abc-mongo-keys2:
image: depop/openssl-bats
volumes:
- abc-mongo-keys2:/mongo-conf
command: 'bash -c "openssl rand -base64 741 > /mongo-conf/mongodb-keyfile; chmod 600 /mongo-conf/mongodb-keyfile; chown 999 /mongo-conf/mongodb-keyfile"'
# Node1
abc-mongo-pp-1:
container_name: abc-mongo-pp-1
image: mongo:5.0.24
volumes:
- abc-mongo-keys2:/opt/keyfile
- abc-mongo-data-4:/data/db
env_file:
./mongod.env
ports:
- 40001:27017
command: 'mongod --auth --keyFile /opt/keyfile/mongodb-keyfile --replSet abc-pp'
depends_on:
- abc-mongo-keys2
networks:
abc-cluster2:
# Node2
abc-mongo-pp-2:
container_name: abc-mongo-pp-2
image: mongo:5.0.24
volumes:
- abc-mongo-keys2:/opt/keyfile
- abc-mongo-data-5:/data/db
env_file:
./mongod.env
ports:
- 40002:27017
command: 'mongod --auth --keyFile /opt/keyfile/mongodb-keyfile --replSet abc-pp'
depends_on:
- abc-mongo-keys2
networks:
abc-cluster2:
# Node3
abc-mongo-pp-3:
container_name: abc-mongo-pp-3
image: mongo:5.0.24
volumes:
- abc-mongo-keys2:/opt/keyfile
- abc-mongo-data-6:/data/db
env_file:
./mongod.env
ports:
- 40003:27017
command: 'mongod --auth --keyFile /opt/keyfile/mongodb-keyfile --replSet abc-pp'
depends_on:
- abc-mongo-keys2
networks:
abc-cluster2:
This is my replication -
# for replication
rs.initiate({
_id: "abc-pp",
members: [
{_id: 0, host: "192.168.1.110:40001"},
{_id: 1, host: "192.168.1.110:40002"},
{_id: 2, host: "192.168.1.110:40003"}
]
})
And I am able to access through this 192.168.1.119 but this is our remote ip 14.194.218.51 and which is not accessible outside our vpn or whatever you call it publically, so tell me what to do if you want to access it through the public ip or remote ip.
Any help will be very much appreciated.