您好我正在尝试运行 mongodb 以使用 docker 映像(bitnami mongodb:4.0. 和 mongo-express)备份一些文件。这些是由这个 docker-compose 文件指定的:
version: '3.5'
services:
mongodb-primary:
image: 'bitnami/mongodb:4.0'
restart: always
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-primary
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_ROOT_PASSWORD=root
- MONGODB_REPLICA_SET_NAME=rs0
- MONGODB_REPLICA_SET_KEY=replicatorkey
- MONGODB_USERNAME=project
- MONGODB_PASSWORD=pass
- MONGODB_DATABASE=project
ports:
- 27017:27017
volumes:
- ./mongo_primary:/bitnami
mongodb-secondary:
image: 'bitnami/mongodb:4.0'
restart: always
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=root
- MONGODB_REPLICA_SET_NAME=rs0
- MONGODB_REPLICA_SET_KEY=replicatorkey
- MONGODB_USERNAME=project
- MONGODB_PASSWORD=pass
- MONGODB_DATABASE=project
depends_on:
- mongodb-primary
volumes:
- ./mongo_secondary:/bitnami
mongodb-arbiter:
image: 'bitnami/mongodb:4.0'
restart: always
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-arbiter
- MONGODB_REPLICA_SET_MODE=arbiter
- MONGODB_PRIMARY_HOST=mongodb-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=root
- MONGODB_REPLICA_SET_NAME=rs0
- MONGODB_REPLICA_SET_KEY=replicatorkey
depends_on:
- mongodb-primary
mongo-express:
image: mongo-express
restart: always
environment:
- ME_CONFIG_MONGODB_SERVER="mongodb-primary,mongodb-secondary,mongodb-arbiter"
- ME_CONFIG_MONGODB_AUTH_DATABASE=project
- ME_CONFIG_REQUEST_SIZE=1024kb
- ME_CONFIG_MONGODB_ENABLE_ADMIN=true
- ME_CONFIG_MONGODB_ADMINUSERNAME=root
- ME_CONFIG_MONGODB_ADMINPASSWORD=root
- ME_CONFIG_MONGODB_AUTH_USERNAME=project
- ME_CONFIG_MONGODB_AUTH_PASSWORD=pass
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=admin
- ME_CONFIG_SITE_GRIDFS_ENABLED=true
depends_on:
- mongodb-primary
ports:
- 8888:8081
这个 docker-compose 文件和图像在同事工作站(内核:4.15 和 Ubuntu 18.04)上工作,但在我的(内核:5.3.0 Ubuntu 18.04)上我收到以下错误消息:
Admin database is not accessible
TypeError: Cannot read property 'listDatabases' of undefined
at Object.connectionData.updateDatabases (/node_modules/mongo-express/lib/db.js:41:11)
at /node_modules/mongo-express/lib/router.js:94:11
at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
at next (/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
at /node_modules/express/lib/router/index.js:281:22
at param (/node_modules/express/lib/router/index.js:354:14)
at param (/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/node_modules/express/lib/router/index.js:410:3)
进入 mongo_primary 图像,它似乎工作正常,可以连接到 mongo 管理数据库,但似乎 mongo-express 不能。我们都看过并不确定为什么会发生这种情况。有没有其他人遇到过这个/修复它?