【问题标题】:Elasticsearch won't run with DockerElasticsearch 不能与 Docker 一起运行
【发布时间】:2017-05-23 12:03:42
【问题描述】:

我写了一些与 Elasticsearch 集成的代码,当 ES 在我的电脑上运行时,它运行流畅。但是,当我尝试通过 Docker 运行 ES 时,我不断收到此错误:

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{hrmyFR97S_qMsPEsOOEFjw}{localhost}{127.0.0.1:9300}]

这是我初始化客户端的方式:

Settings settings = Settings.builder()
                .put("cluster.name", "elasticsearch123")
                .build();

 Client client = new PreBuiltTransportClient(settings)
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

这就是我的 docker-compose 文件的样子:

version: '2'

services:
      elastic3:
        image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0
        environment:
          - cluster.name=elasticsearch123
          - bootstrap.memory_lock=true
          - transport.host=127.0.0.1
          - xpack.security.enabled=false
          - http.host=0.0.0.0
          - network.host=127.0.0.1

        ports:
          - "9200:9200"
          - "9300:9300"
        volumes:
         - /usr/share/elasticsearch/data

这是我的依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>5.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>5.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.7</version>
    </dependency>

</dependencies>`

有什么想法吗?我真的没有想法了!

【问题讨论】:

  • 抱歉,您的问题与您的问题有关,但我正在尝试使用 java 与弹性搜索进行交互,但我无法做到这一点,您能帮我解决这个问题吗?任何 git hub 存储库以及我无法获取和更新的所有内容

标签: java elasticsearch docker docker-compose elasticsearch-5


【解决方案1】:

我敢打赌,这完全是因为网络配置错误。检查网络操作模式并调整使用host 而不是默认bridge。此外,您不需要“暴露” prots,因为所有端口都将开箱即用。这是因为 docker 容器将直接绑定你的热点接口而不是虚拟接口。

检查Network settings 部分

https://docs.docker.com/engine/reference/run/#container-identification

当您在这里使用compose 时,您有正确的配置选项

https://docs.docker.com/compose/compose-file/#networkmode

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-28
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    相关资源
    最近更新 更多