【发布时间】:2021-09-07 09:04:06
【问题描述】:
我一直在尝试启动一个 mongoDB 和 cassandra 容器,并让它们通过两个简单的健康检查,但无论我进行什么健康检查,它们都会失败:
对于 mongoDB,这是我的 yml 文件:
version: '3.1'
services:
mongo:
image: mongo:3.6.3
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
healthcheck:
test: ["CMD", "mongo --quiet 127.0.0.1/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'"]
start_period: 5s
interval: 5s
timeout: 120s
retries: 24
对于卡桑德拉:
version: '2'
services:
cassandra:
image: 'docker.io/bitnami/cassandra:3-debian-10'
ports:
- '7000:7000'
- '9042:9042'
volumes:
- 'cassandra_data:/bitnami'
environment:
- CASSANDRA_SEEDS=cassandra
- CASSANDRA_PASSWORD_SEEDER=yes
- CASSANDRA_PASSWORD
- MAX_HEAP_SIZE=1G
- HEAP_NEWSIZE=800M
healthcheck:
test: [ "CMD-SHELL", "cqlsh --username cassandra --password ${CASSANDRA_PASSWORD} -e 'describe cluster'" ]
interval: 5s
timeout: 120s
retries: 24
我是不是错过了什么,
我也尝试运行它来进行健康检查:
echo 'db.runCommand({serverStatus:1}).ok' | mongo admin -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --quiet | g$$et | grep 1```
I went trough a lot of the discussions about the healthchecks for mongo and cassandra, but still not able to make it work
【问题讨论】:
标签: mongodb docker docker-compose cassandra