【发布时间】:2017-11-01 09:16:27
【问题描述】:
我正在运行这样的弹性搜索图像: docker-compose.yml
version: '2'
services:
elasticsearch:
image: elasticsearch:5.4
ports:
- "9200:9200"
- "9300:9300"
我可以用 curl 检查它是否正在运行。
curl http://127.0.0.1:9200/_cluster/health
回复:
{"cluster_name":"elasticsearch","status":"green","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}
在应用程序中,我像这样配置 TransportClient:
@Bean(destroyMethod = "close")
public TransportClient transportClient() throws UnknownHostException {
return new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName("localhost"), 9300));
}
然后我想检查一下:
@Autowired
private TransportClient client;
@GetMapping(value = "test")
public Object test(){
return client.admin().cluster().health(Requests
.clusterHealthRequest())
.actionGet();
}
但异常失败:
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{_atMOwK5R5mgOXqAPJWvWg}{localhost}{127.0.0.1:9300}]
顺便说一句,我正在使用此依赖项:compile('org.elasticsearch.client:transport:5.4.0')
【问题讨论】:
-
有同样的情况/错误(grails 客户端,docker-compose + es 5.3)。这段时间你解决了吗?
标签: java elasticsearch spring-boot docker-compose