gpt4 book ai didi

docker - 带有Kibana的Docker Compose 2节点Elasticsearch集群

转载 作者:行者123 更新时间:2023-12-02 20:59:34 27 4
gpt4 key购买 nike

我在设置docker-compose.yml文件以使2个Elasticsearch节点与Kibana一起运行时遇到问题。

获取错误'Kibana server is not ready yet'
在容器日志中

{"type":"log","@timestamp":"2020-04-11T13:19:45Z","tags":["warning","elasticsearch","data"],"pid":7,"message":"No living connections"}
{"type":"log","@timestamp":"2020-04-11T13:19:45Z","tags":["warning","plugins","licensing"],"pid":7,"message":"License information could not be obtained from Elasticsearch due to Error: No Living connections error"}
{"type":"log","@timestamp":"2020-04-11T13:19:45Z","tags":["warning","elasticsearch","admin"],"pid":7,"message":"Unable to revive connection: http://elasticsearch:9200/"}

我的docker-compose.yml文件如下所示:
version: '3'
services:

#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: digitalocean.com/php
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
ports:
- "9000:9000"
networks:
- app-network

#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network

#MySQL Service
db:
image: mysql:5.7.29
container_name: db
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: pipeup
MYSQL_USER: pu_admin
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Redis
cache:
image: redis:rc-alpine3.11
container_name: cache
ports:
- "6382:6379"
networks:
- app-network

# Elasticsearch
elasticsearch01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch01
environment:
- cluster.name=docker-cluster
- discovery.seed_hosts=elasticsearch02
- cluster.initial_master_nodes=elasticsearch01,elasticsearch02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- node.name=elasticsearch01
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9200:9200"
volumes:
- esdata01:/usr/share/elasticsearch/data
networks:
- app-network

elasticsearch02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch02
environment:
- cluster.name=docker-cluster
- discovery.seed_hosts=elasticsearch01
- cluster.initial_master_nodes=elasticsearch01,elasticsearch02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- node.name=elasticsearch02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata02:/usr/share/elasticsearch/data
networks:
- app-network

kibana:
image: docker.elastic.co/kibana/kibana:7.6.2
container_name: kibana
environment:
- "elasticsearch.hosts=http://elasticsearch:9200"
ports:
- "5601:5601"
networks:
- app-network

#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
esdata01:
driver: local
esdata02:
driver: local

最佳答案

您需要像这样设置主机并指向其中一个容器。

将您的docker-compose.yml更改为:

kibana:
image: docker.elastic.co/kibana/kibana:7.6.2
container_name: kibana
environment:
- "ELASTICSEARCH_HOSTS=http://elasticsearch01:9200" # Change this
ports:
- "5601:5601"
networks:
- app-network

关于docker - 带有Kibana的Docker Compose 2节点Elasticsearch集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61157471/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com