简体   繁体   English

NoNodeAvailableException [没有已配置的节点可用]在Elasticsearch 5.1.2中

[英]NoNodeAvailableException[None of the configured nodes are available] in Elasticsearch 5.1.2

On Google Compute Engine, I created 3 VMs and installed Elasticsearch 5.1.2 on them. 在Google Compute Engine上,我创建了3个VM,并在其上安装了Elasticsearch 5.1.2 I installed GCE Discovery Plugin for unicast discovery. 我安装了用于单播发现的GCE Discovery Plugin

From my local web browser(Win7), I could access these Elasticsearch nodes successfully. 从本地Web浏览器(Win7),我可以成功访问这些Elasticsearch节点。 On Google Cloud Platform, I have added the firewall rule accepting tcp:9300, tcp:9200. 在Google Cloud Platform上,我添加了接受tcp:9300,tcp:9200的防火墙规则。

Now I'd like to use Java transport client to talk to remote Elasticsearch nodes from my local java application. 现在,我想使用Java传输客户端与本地Java应用程序中的远程Elasticsearch节点通信。 I'm sure cluster.name is correct. 我确定cluster.name是正确的。

Code and Error are as follows: 代码和错误如下:

public class NativeClient {

    @SuppressWarnings({ "resource", "unchecked" })
    public static Client createTransportClient() throws UnknownHostException {

        Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", true)
                .build();

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

        return client;
    }

    private final Node node = null;
    private final Client client = null;
}


public class IndicesOperations {
    private final Client client;

    public IndicesOperations(Client client) {
        this.client = client;
    }

    public boolean checkIndexExists(String name){
        IndicesExistsResponse response=client.admin().indices().prepareExists(name).execute().actionGet();
        return response.isExists();
    }

    public static void main( String[] args ) throws InterruptedException, UnknownHostException {
        Client client =NativeClient.createTransportClient();
        IndicesOperations io=new IndicesOperations(client);
        String myIndex = "test";
        if(io.checkIndexExists(myIndex))
            io.deleteIndex(myIndex);
        io.createIndex(myIndex);
        Thread.sleep(1000);
        io.closeIndex(myIndex);
        io.openIndex(myIndex);
        io.deleteIndex(myIndex);
    }
}


Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{lu8DzekbSWOrNEgFgXxpgQ}{104.100.100.96}{104.100.100.96:9300}]]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:328)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:226)
    at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
    at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:345)
    at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403)
    at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
    at com.packtpub.IndicesOperations.checkIndexExists(IndicesOperations.java:16)
    at com.packtpub.IndicesOperations.main(IndicesOperations.java:49)

elasticsearch.yml elasticsearch.yml

network.host: _gce_

cloud:
  gce:
      project_id: es-cloud
      zone: asia-east1-b
discovery:
      type: gce

Edit : 编辑

After deploying my java application on google compute engine, it can access the elasticsearch instance running on google compute engine. 在Google计算引擎上部署我的Java应用程序后,它可以访问在Google计算引擎上运行的elasticsearch实例。 In this application, I just modified InetAddress.getByName("10.140.0.2") . 在此应用程序中,我刚刚修改了InetAddress.getByName("10.140.0.2") When deploying on my local machine, I used the external ip of that VM. 在本地计算机上进行部署时,我使用了该VM的external ip

What else do I have to modify to run it on my local machine? 要在本地计算机上运行它,我还需要修改什么?

I appended the external ip of my VM to network.publish_host property in elasticsearch.yml, then I could access the elasticsearch running on remote VM: 我将虚拟机的external ip附加到network.publish_host属性,然后可以访问在远程虚拟机上运行的elasticsearch:

network.host: _gce_
network.publish_host: 104.100.100.96

cloud:
  gce:
      project_id: es-cloud
      zone: asia-east1-b
discovery:
      type: gce

I don't understand exactly, but fortunately it works. 我不太清楚,但是幸运的是它能正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch NoNodeAvailableException没有配置的节点可用 - Elasticsearch NoNodeAvailableException None of the configured nodes are available NoNodeAvailableException : 没有配置的节点可用 - NoNodeAvailableException : None of the configured nodes are available org.elasticsearch.client.transport.NoNodeAvailableException:没有配置的节点可用:[] - org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [] 无法在TransportClient中创建InetSocketTransportAddress:NoNodeAvailableException [没有配置的节点 - 可用:[]] - Can't create InetSocketTransportAddress in TransportClient: NoNodeAvailableException[None of the configured nodes -are available: []] NoNodeAvailableException [没有配置的节点可用:[{#transport#-1} {...} {127.0.0.1} {127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{…}{127.0.0.1}{127.0.0.1:9300}]] Java ElasticSearch 没有配置的节点可用 - Java ElasticSearch None of the configured nodes are available NoNodeAvailableException[没有配置的节点可用:[{#transport#-1}{XY6cYmf7Sn-DRZgzeq3PBA}{localhost}{127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{XY6cYmf7Sn-DRZgzeq3PBA}{localhost}{127.0.0.1:9300}]] NoNodeAvailableException[没有配置的节点可用:[{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]] 无法连接到Elasticsearch 6.1.0 [没有已配置的节点可用] - Unable to Connect to Elasticsearch 6.1.0[None of the configured nodes are available] Java Elasticsearch-Hadoop没有配置的节点可用 - Java Elasticsearch-Hadoop None of the configured nodes are available
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM