我尝试使用docker-compose.yml设置zipkin,elasticsearch,prometheus和grafana 当我运行dockers时,请参阅日志:
dependencies_zipkin | 19/09/30 14:37:09错误NetworkClient:节点[172.28.0.2:9200]失败(java.net.ConnectException:连接被拒绝(连接被拒绝));没有其他节点了-正在终止...
我在使用docker 2.1.0.3的MacOS X上
我的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,但出现错误:
错误:无法加载服务名称:服务器错误(服务不可用)(由于网络错误
在日志中,我有以下信息:
105 ^ [[35mdependencies_zipkin | ^ [[0m 19/09/30 14:45:20错误] NetworkClient:节点[172.28.0.2:9200]失败(java.net.ConnectException:连接被拒绝(连接被拒绝));没有其他节点了-正在终止...
和这个
^ [[31mzipkin | ^ [[0m java.lang.IllegalStateException:无法连接任何[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依赖关系之间发生。
答案 0 :(得分:0)
问题出在文档here中的ES_HOSTS
变量中:
ES_HOSTS
:连接到ex的Elasticsearch基本URL的逗号分隔列表。 http://host:9200。 默认为“ http://localhost:9200”。
因此,您将需要:ES_HOSTS=http://storage:9200
答案 1 :(得分:0)
最后我有了这个文件:
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 =存储量:9300”
在依赖项配置中,我在依赖项中添加了入口点:
入口点:crond -f 这真的是我启动docker-compose时没有例外的关键。
要解决此问题,请检查以下项目:https://github.com/openzipkin/docker-zipkin
剩下的问题是:为什么我需要使用入口点:crond -f