【问题标题】:Elasticsearch fails with NoNodeAvailableExceptionElasticsearch 失败并出现 NoNodeAvailableException
【发布时间】: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


【解决方案1】:

尝试使用 elasticsearch 而不是本地主机,因为这是您的容器名称,以防 Spring Boot 应用程序也在 docker 中运行

【讨论】:

  • 弹簧靴在码头外。 InetAddress.getByName("elasticsearch"), 9300) 导致 UnknownHostException: elasticsearch: Name or service not known
  • 从您的浏览器中您能否获得127.0.0.1:9200/_cluster/health的响应
  • 是的。和 curl 格式一样
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-18
  • 2016-05-28
  • 2018-07-10
  • 2017-06-27
  • 1970-01-01
  • 2018-02-24
相关资源
最近更新 更多