Hello,
So I want to check the Percona Backup for MongoDB, and just for the test purpose, I did create 3 Docker containers for the MongoDB cluster (with replica sets configured), and then I added the Percona Backup for MongoDB:Latest Image. but I am stuck in the connection string part PBM_MONGODB_URI what should I put because when I mentioned the 3 container in the connection string I get this error
Exit: connect to the node: connect: create mongo client: a direct connection cannot be made if multiple hosts are specified
and when I just configure only with the primary conatainer I get
dbrs:
- dbrs/mongo1:27017: pbm-agent v1.8.1 OK
- dbrs/mongo2:27017: pbm-agent NOT FOUND FAILED status:
- dbrs/mongo3:27017: pbm-agent NOT FOUND FAILED status:
this is my docker-compose file:
version: '3.8'
services:
mongo1:
container_name: mongo1
image: mongo:4.4
volumes:
- ./scripts/rs-init.sh:/scripts/rs-init.sh
- ./scripts/init.js:/scripts/init.js
networks:
- mongo-network
ports:
- 27017:27017
depends_on:
- mongo2
- mongo3
links:
- mongo2
- mongo3
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "dbrs" ]
mongo2:
container_name: mongo2
image: mongo:4.4
networks:
- mongo-network
ports:
- 27018:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "dbrs" ]
mongo3:
container_name: mongo3
image: mongo:4.4
networks:
- mongo-network
ports:
- 27019:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "dbrs" ]
percona:
image: percona/percona-backup-mongodb:latest
container_name: percona
environment:
PBM_MONGODB_URI: "mongodb://pbmuser:secretpwd@mongo1:27017/?authSource=admin&replSetName=dbrs"
networks:
- mongo-network
volumes:
- ./pbm_config.yaml:/tmp/pbm_config.yaml
- /app
#- ./pbm-set.sh:/tmp/pbm-set.sh
depends_on:
- mongo1
- mongo2
- mongo3
networks:
mongo-network:
driver: bridge
and this is the script for replicaset configuration:
#!/bin/bash
DELAY=25
mongo <<EOF
var config = {
"_id": "dbrs",
"version": 1,
"members": [
{
"_id": 1,
"host": "mongo1:27017",
"priority": 2
},
{
"_id": 2,
"host": "mongo2:27017",
"priority": 1
},
{
"_id": 3,
"host": "mongo3:27017",
"priority": 1
}
]
};
rs.initiate(config, { force: true });
EOF
echo "****** Waiting for ${DELAY} seconds for replicaset configuration to be applied ******"
sleep $DELAY
mongo < /scripts/init.js
any solutions ?