docker-compose上的Elasticsearch healthcheck会停止任何依赖的服务,因为容器总是不健康的。我在运行docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"时看到了这一点
NAMES IMAGE STATUS
elasticsearch elasticsearch:7.12.1 Up 26 seconds (unhealthy)我正在尝试启动metricbeat,以便启动elasticsearch、kibana和logstash:
metricbeat:
image: elastic/metricbeat:7.12.1
user: root
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
logstash:
condition: service_healthy
redis:
condition: service_healthy我如何确保elasticsearch (和其他容器是健康的),并允许metricbeat启动所有可用的资源?
除非绝对必要,否则我会避免为其中任何一个创建Docker镜像。
我的docker-compose配置如下所示:
version: '3.7'
services:
elasticsearch:
# specifying discovery.type='single-node' bypasses bootstrapping checks.
image: elasticsearch:7.12.1
container_name: elasticsearch
healthcheck:
test: [ "CMD", "curl", "--fail" , "http://elasticsearch:9200/_cluster/health?wait_for_status=green&timeout=1s", "||", "exit", "1" ]
interval: 5s
timeout: 3s
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
networks:
- elastic
ports:
- 9200:9200
- 9300:9300
labels:
co.elastic.metrics/module: "elasticsearch"
co.elastic.metrics/hosts: "http://elasticsearch:9200"
co.elastic.metrics/metricsets: "node_stats,node"
co.elastic.metrics/xpack.enabled: "true"
environment:
- node.name=elasticsearch
- cluster.name=cluster-7
- discovery.type=single-node
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- xpack.monitoring.enabled=true
- xpack.monitoring.elasticsearch.collection.enabled=true
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK发布于 2021-08-11 10:38:53
用于d-c文件版本。3.7我使用这个结构:
healthcheck:
test: curl -u elastic:elastic -s -f elasticsearch:9200/_cat/health >/dev/null || exit 1
interval: 30s
timeout: 10s
retries: 5发布于 2021-09-18 22:12:09
根据弹性版本的不同,方法可能会有所不同。此外,如果您使用OpenSearch,您还需要使用其他工具,它们的健康输出略有不同(但仅供参考)
我正在添加我在docker-compose中使用的内容
healthcheck:
interval: 10s
retries: 80
test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:8200/或
healthcheck:
test: curl -s http://elasticsearch01:9200 >/dev/null || exit 1
interval: 30s
timeout: 10s
retries: 50https://stackoverflow.com/questions/68202592
复制相似问题