【发布时间】: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