Home:ALL Converter>Bitnami MongoDB Replica Set on Google Compute Engine

Bitnami MongoDB Replica Set on Google Compute Engine

Ask Time:2020-07-15T04:38:30         Author:Tobi V.

Json Formatter

I have three container optimised VMs running on Google Compute Engine (GCE) with each a Bitnami MongoDB Docker Container, one should be the primary Mongo DB Instance and two should be secondary.

When creating the VMs, I specified the Container Image as "bitnami/mongodb:latest" and set the environment variables according to the bitnami documentation using gce-container-declaration (also possible via the UI under "Advanced Container Options")

I can connect to the primary mongodb with the via MONGODB_ROOT_PASSWORD defined password and also the other VMs are up and are listening on their 27017 ports. The VMs can also reach each other, so the VPC and Firewall Rules are ok with Port 27017, 22 and 80 INGRESS / EGRESS.

But, when I want to get the replica set status rs.status() on the primary, I always get an "errmsg" : "no replset config has been received" error. So the nodes don't create a Replica Set... With Docker-Compose this works out of the box and the Bitnami Image also should init the Replica Set automatically, shouldn't it?

I tried a lot of things including using MONGODB_ADVERTISED_HOSTNAME with custome GCE VM Hostnames, but nothing works and I don't have any Idea how to find the issue.

enter image description here

Primary Node - Container Env. Vars:

MONGODB_ROOT_PASSWORD = 'password123'
MONGODB_REPLICA_SET_NAME = 'rep'
MONGODB_REPLICA_SET_MODE = 'primary'
MONGODB_REPLICA_SET_KEY = '321abc123'

Secondary1 Node - Container Env. Vars:

MONGODB_PRIMARY_ROOT_PASSWORD = 'password123'
MONGODB_REPLICA_SET_NAME = 'rep'
MONGODB_PRIMARY_HOST = '${VPC_LOCAL_IP_PRIMARY_NODE}'
MONGODB_PRIMARY_PORT_NUMBER = '27017'
MONGODB_REPLICA_SET_MODE = 'secondary'
MONGODB_REPLICA_SET_KEY = '321abc123'

Secondary2 Node - Container Env. Vars:

MONGODB_PRIMARY_ROOT_PASSWORD = 'password123'
MONGODB_REPLICA_SET_NAME = 'rep'
MONGODB_PRIMARY_HOST = '${VPC_LOCAL_IP_PRIMARY_NODE}'
MONGODB_PRIMARY_PORT_NUMBER = '27017'
MONGODB_REPLICA_SET_MODE = 'secondary'
MONGODB_REPLICA_SET_KEY = '321abc123'

Author:Tobi V.,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62903649/bitnami-mongodb-replica-set-on-google-compute-engine
yy