docker-compose: zipkin 无法连接到 elasticsearch
docker-compose: zipkin cannot connect to elasticsearch
我尝试使用 docker-compose.yml 设置 zipkin、elasticsearch、prometheus 和 grafana
当我运行 dockers时,在日志中看到:
dependencies_zipkin | 19/09/30 14:37:09 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
我在 MacOS X 上 docker 2.1.0.3
我的docker-compose.yml的内容是这个:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- "9200:9200"
environment:
- "xpack.security.enabled=false"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
restart: unless-stopped
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
restart: unless-stopped
zipkin:
image: openzipkin/zipkin
container_name: zipkin
depends_on:
- dependencies
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
ports:
- "9411:9411"
restart: unless-stopped
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
restart: unless-stopped
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies_zipkin
depends_on:
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
当我连接到 localhost:9200 时,我看到 elasticsearch 工作正常并且在端口 9411 上部署了 zipkin 但我有错误:
ERROR: cannot load service names: server error (Service Unavailable)(due to the network error
在日志中,我有以下信息:
105 ^[[35mdependencies_zipkin |^[[0m 19/09/30 14:45:20 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
还有这个
^[[31mzipkin |^[[0m java.lang.IllegalStateException: couldn't connect any of [Endpoint{storage:80, ipAddr=172.28.0.2, weight=1000}]
有什么想法吗?
更新
通过使用 mysql 它工作正常,所以问题出在弹性搜索级别。
我也尝试使用
"STORAGE_PORT_9200_TCP_ADDR=127.0.0.1"
但问题仍然存在。
更新
由于提到了 Brian 给出的解决方案,我必须使用:
ES_HOSTS=http://storage:9300
关键在端口上,我用的是9200端口
zipkin 和 es 之间错误消失,但 es 和 zipkin-dependencies 之间仍然出现错误。
问题在于您的 ES_HOSTS
变量,来自文档 here:
ES_HOSTS
: A comma separated list of elasticsearch base urls to connect to ex. http://host:9200.
Defaults to "http://localhost:9200".
所以你需要:ES_HOSTS=http://storage:9200
我终于有了这个文件:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- 9200:9200
zipkin:
image: openzipkin/zipkin
container_name: zipkin
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
ports:
- 9411:9411
depends_on:
- storage
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies
entrypoint: crond -f
depends_on:
- storage
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
- "ES_NODES_WAN_ONLY=true"
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
grafana:
image: grafana/grafana
container_name: grafana
depends_on:
- prometheus
ports:
- "3000:3000"
主要区别在于
的用法
"ES_HOSTS=elasticsearch:9300"
而不是
"ES_HOSTS=storage:9300"
在依赖项配置中,我在依赖项中添加了入口点:
entrypoint: crond -f
This one is really the key to not have the exception when I start docker-compose.
为了解决这个问题,我检查了这个项目:https://github.com/openzipkin/docker-zipkin
剩下的问题是:为什么我需要使用入口点:crond -f
我尝试使用 docker-compose.yml 设置 zipkin、elasticsearch、prometheus 和 grafana 当我运行 dockers时,在日志中看到:
dependencies_zipkin | 19/09/30 14:37:09 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
我在 MacOS X 上 docker 2.1.0.3
我的docker-compose.yml的内容是这个:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- "9200:9200"
environment:
- "xpack.security.enabled=false"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
restart: unless-stopped
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
restart: unless-stopped
zipkin:
image: openzipkin/zipkin
container_name: zipkin
depends_on:
- dependencies
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
ports:
- "9411:9411"
restart: unless-stopped
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
restart: unless-stopped
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies_zipkin
depends_on:
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
当我连接到 localhost:9200 时,我看到 elasticsearch 工作正常并且在端口 9411 上部署了 zipkin 但我有错误:
ERROR: cannot load service names: server error (Service Unavailable)(due to the network error
在日志中,我有以下信息:
105 ^[[35mdependencies_zipkin |^[[0m 19/09/30 14:45:20 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
还有这个
^[[31mzipkin |^[[0m java.lang.IllegalStateException: couldn't connect any of [Endpoint{storage:80, ipAddr=172.28.0.2, weight=1000}]
有什么想法吗?
更新 通过使用 mysql 它工作正常,所以问题出在弹性搜索级别。 我也尝试使用
"STORAGE_PORT_9200_TCP_ADDR=127.0.0.1"
但问题仍然存在。
更新 由于提到了 Brian 给出的解决方案,我必须使用:
ES_HOSTS=http://storage:9300
关键在端口上,我用的是9200端口
zipkin 和 es 之间错误消失,但 es 和 zipkin-dependencies 之间仍然出现错误。
问题在于您的 ES_HOSTS
变量,来自文档 here:
ES_HOSTS
: A comma separated list of elasticsearch base urls to connect to ex. http://host:9200. Defaults to "http://localhost:9200".
所以你需要:ES_HOSTS=http://storage:9200
我终于有了这个文件:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- 9200:9200
zipkin:
image: openzipkin/zipkin
container_name: zipkin
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
ports:
- 9411:9411
depends_on:
- storage
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies
entrypoint: crond -f
depends_on:
- storage
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
- "ES_NODES_WAN_ONLY=true"
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
grafana:
image: grafana/grafana
container_name: grafana
depends_on:
- prometheus
ports:
- "3000:3000"
主要区别在于
的用法"ES_HOSTS=elasticsearch:9300"
而不是
"ES_HOSTS=storage:9300"
在依赖项配置中,我在依赖项中添加了入口点:
entrypoint: crond -f This one is really the key to not have the exception when I start docker-compose.
为了解决这个问题,我检查了这个项目:https://github.com/openzipkin/docker-zipkin
剩下的问题是:为什么我需要使用入口点:crond -f