无法使用Docker中的其他端口将Kibana连接到Elasticsearch

时间:2020-11-10 13:41:09

标签: docker elasticsearch kibana kibana-7

我无法将Kibana连接到在docker的另一个端口中运行的Elasticsearch。这是我的docker文件:

version: '3.2'
services:
  elasticsearch_new_1:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch_new_1
    environment:
      - node.name=kw-new
      - cluster.name=kw-new
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - elasticsearch_new_1:/usr/share/elasticsearch/data
    ports:
      - 9299:9200
      - 9399:9300
    networks:
      - elastic

  kibana_2:
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana_2
    environment:
      - SERVER_NAME=KW_Kibana
      - ELASTICSEARCH_HOSTS=http://elasticsearch_new_1:9299
    ports:
      - 5601:5601
    links:
      - elasticsearch_new_1
    networks:
      - elastic
    depends_on:
      - elasticsearch_new_1

volumes:
  es:
    driver: local
  db:
    driver: local
  elasticsearch_new_1:
    driver: local

networks:
  elastic:
    driver: bridge

当Elasticsearch在端口9200中运行时,效果很好。我尝试创建kibana.yml,但它没有任何改变。在elasticsearch中,以下错误消息:

["java.lang.IllegalStateException: Received message from unsupported version: [1.0.0] minimal compatible version is: [6.8.0]",
        elasticsearch_new_1    | "at org.elasticsearch.transport.InboundMessage.ensureVersionCompatibility(InboundMessage.java:152) ~[elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.InboundMessage.access$000(InboundMessage.java:37) ~[elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.InboundMessage$Reader.deserialize(InboundMessage.java:70) ~[elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:114) ~[elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:103) ~[elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:667) [elasticsearch-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:62) [transport-netty4-client-7.6.2.jar:7.6.2]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:326) [netty-codec-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:300) [netty-codec-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241) [netty-handler-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:600) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:554) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [netty-transport-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) [netty-common-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.43.Final.jar:4.1.43.Final]",
    elasticsearch_new_1    | "at java.lang.Thread.run(Thread.java:830) [?:?]"] }

根据此消息:当Elasticsearch在9200端口中运行时,Kibana使用的是客户端1.0.0

["java.lang.IllegalStateException: Received message from unsupported version: [1.0.0] minimal compatible version is: [6.8.0]",

Elasticsearch在localhost:9299上运行良好

有人知道吗?

谢谢

1 个答案:

答案 0 :(得分:0)

我通过在环境中更改Elasticsearch的端口来使其工作,我的意思是我已经更改了Elasticsearch容器的端口号。以下是最重要的更改:

  1. http.port=9201-9301在环境中
  2. 9201:92019301:9301在端口中。

完整的docker-compose.yml:

version: '3.2'
services:
  elasticsearch_new_1:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch_new_1
    environment:
      - node.name=kw-new
      - cluster.name=kw-new
      - discovery.type=single-node
      - http.port=9201-9301
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - elasticsearch_new_1:/usr/share/elasticsearch/data
    ports:
      - 9201:9201
      - 9301:9301
    networks:
      - elastic

  kibana_2:
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana_2
    environment:
      - SERVER_NAME=KW_Kibana
      - ELASTICSEARCH_HOSTS=http://elasticsearch_new_1:9201
    ports:
      - 5601:5601
    links:
      - elasticsearch_new_1
    networks:
      - elastic
    depends_on:
      - elasticsearch_new_1

volumes:
  es:
    driver: local
  db:
    driver: local
  elasticsearch_new_1:
    driver: local

networks:
  elastic:
    driver: bridge