【问题标题】:About an error running a docker-compose file with kafka, zookeeper and elastic search关于使用 kafka、zookeeper 和 elastic search 运行 docker-compose 文件时出错
【发布时间】:2018-10-24 10:22:19
【问题描述】:

下午好,我正在尝试调试一个 docker-compose 文件的执行,该文件使用了我开发的几个微服务,一个 kafka 节点,另一个 zookeeper 节点,一个用于 elasticsearch,最后是 kibana-sense。

当我运行 docker-compose up 命令时,出现异常:

demo-kafka-elastic_1  | Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{elastic}{172.21.0.5:9300}]
...
web - 2018-05-14 16:47:12,750 [elasticsearch[Neurotap][generic][T#1]] WARN  org.elasticsearch.client.transport - [Neurotap] node {#transport#-1}{elastic}{172.21.0.5:9300} not part of the cluster Cluster [elasticsearch_aironman], ignoring...

这是完整输出的link,很大...

这是我实际的 docker-compose.yml 文件:

version: '3.6'
services:
demo-kafka-elastic:
image: aironman/demo-kafka-elastic:0.0.1-SNAPSHOT
deploy:
  replicas: 5
  resources:
    limits:
      cpus: "0.5"
      memory: 512M
  restart_policy:
      condition: on-failure

 demo-quartz:
 image: aironman/demo-quartz:0.0.1-SNAPSHOT
 deploy:
  replicas: 5
  resources:
    limits:
      cpus: "0.5"
      memory: 512M
  restart_policy:
      condition: on-failure

 zookeeper:
 image: wurstmeister/zookeeper
 ports:
  - "2181:2181"

 kafka:
 image: wurstmeister/kafka
 ports:
  - "9092:9092"
 environment:
  KAFKA_BROKER_ID: 1
  KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
  KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
  KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
 volumes:
  - /var/run/docker.sock:/var/run/docker.sock

 elastic:
  image: elasticsearch:2.4.0
  container_name: elastic
  environment:
    - cluster.name=elastic-cluster
    - http.host=0.0.0.0
    - network.publish_host=127.0.0.1
    - transport.tcp.port=9700
    - discovery.type=single-node
    - xpack.security.enabled=false
    - client.transport.sniff=false
  volumes: 
    - ./esdata/:/usr/share/elasticsearch/data/
  ports:
    - "9600:9200"
    - "9700:9700"

 kibana:
 image: seeruk/docker-kibana-sense:4.5
 ports:
  - "5601:5601"
 environment:
  - ELASTICSEARCH_URL=http://elastic:9200      

我确定我正在推进 kafka 主题,我可以从该 kafka 主题中收听,但我无法将恢复的 json 插入 elasticsearch-2.4.0,我的问题是为什么不使用 docker-compose 运行?因为当我在本地模式下运行相同的进程时,我可以做到这一点,而 kafka、zookeeper 和弹性在本地运行。为了工作,我必须在 docker-compose.yml 文件中进行哪些更改?

我在堆栈溢出中看到了这个link,但它不起作用。

这是 demo-kafka-elastic 的 linkthis 一个是 demo-quartz

更新!

我从官方论坛阅读了this 可能的解决方案,使用elastic-head 插件我可以看到docker 容器默认分配的集群名称,并且我尝试与docker-compose 中的cluster.name 环境变量匹配文件,但它不起作用。

【问题讨论】:

  • 太啰嗦了!!!请让您的问题更具可读性。
  • 对不起@Phani Kumar Yadavilli。我试图具体解决问题,但我会听取您的建议。

标签: docker spring-boot elasticsearch apache-kafka docker-compose


【解决方案1】:

好的,知道了!问题是在我的 application.properties 文件中有一个名为

的字段
spring.data.elasticsearch.cluster-name=elasticsearch_aironman

干扰环境变量

集群名称

我在 docker-compose.yml 中使用。

从 application.properties 文件中删除该行就可以了。

【讨论】:

    猜你喜欢
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 2018-01-11
    • 1970-01-01
    • 2019-03-23
    • 2021-06-13
    • 2023-03-09
    相关资源
    最近更新 更多