Hi I’m using Percona MonogoDB with replica sets via docker-compose, here’s how my setup looks like:
I have a Ubuntu VM on GCE, with docker engine installed. Here’s the docker-compose file that I use:
rs101:
image: percona/percona-server-mongodb
container_name: rs101
hostname: rs101
networks:
- backend
command: "--port=27017 --replSet rs --auditDestination=file --auditFormat=JSON --auditPath=/tmp/audit-logs/audit_101.json"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongo_db_101:/data/db
- ./mongo-audit-logs:/tmp/audit-logs/
ports:
- "27017:27017"
rs102:
image: percona/percona-server-mongodb
container_name: rs102
hostname: rs102
networks:
- backend
command: "--port=28017 --replSet rs --auditDestination=file --auditFormat=JSON --auditPath=/tmp/audit-logs/audit_102.json"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongo_db_102:/data/db
- ./mongo-audit-logs:/tmp/audit-logs
ports:
- "28017:28017"
rs103:
image: percona/percona-server-mongodb
container_name: rs103
hostname: rs103
networks:
- backend
command: "--port=29017 --replSet rs --auditDestination=file --auditFormat=JSON --auditPath=/tmp/audit-logs/audit_103.json"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongo_db_103:/data/db
- ./mongo-audit-logs:/tmp/audit-logs
ports:
- "29017:29017"
rs-init:
image: percona/percona-server-mongodb
container_name: rs-init
restart: "no"
networks:
- backend
depends_on:
- rs101
- rs102
- rs103
command: >
mongo --host rs101:27017 --eval
'
config = {
"_id" : "rs",
"members" : [
{
"_id" : 0,
"host" : "rs101:27017"
},
{
"_id" : 1,
"host" : "rs102:28017"
},
{
"_id" : 2,
"host" : "rs103:29017"
}
]
};
rs.initiate(config);
'
volumes:
pmm-client-data:
pmm-data:
mongo_db_101:
mongo_db_102:
mongo_db_103:
mongo-audit-logs:
But now when i try to run docker-compose percona-mongodb contianers fail with the following log:
{"t":
{"$date":"2023-08-28T04:51:30.197+00:00"},
"s":"F", "c":"CONTROL", "id":20574, "ctx":"-","msg":"Error during global initialization",
"attr":{"error":
{"code":2,"codeName":"BadValue",
"errmsg":"Could not open a file for writing at the given auditPath: /tmp/audit-logs/audit_101.json"}}}
ERROR: child process failed, exited with 1
How to solve this issue? I’ve tried multiple solutions. Inlcuding providing the relevant permission using chown command but nothing works.