簡體   English   中英

線程“主”中的異常org.elasticsearch.client.transport.NoNodeAvailableException:無可用節點

[英]Exception in thread “main” org.elasticsearch.client.transport.NoNodeAvailableException: No node available

我正在嘗試使用下面的Java代碼在彈性搜索中進行索引。我在代碼中給了我的機器Ip。它無法連接到節點。 它給出如下錯誤:

線程“主”中的異常org.elasticsearch.client.transport.NoNodeAvailableException: org.elasticsearch.client.transport.support.InternalTransportClient上的org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)上沒有可用的節點 org上的org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:82)的.execute(InternalTransportClient.java:106)org的org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:330)的。 org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)上org.elasticsearch.action.Action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)上的elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:314)在test.test1.main(test1.java:30)

我正在使用的代碼:

public static void main(String[] args) {

    String json = "{" +         
                    "\"user\":\"AMaresh\"," +         
                    "\"postDate\":\"2014-04-23\"," + 
                    "\"message\":\"trying out Elasticsearch\"" +
                    "}";  


    Settings settings = ImmutableSettings.settingsBuilder().put("elasticsearch", "elasticsearch").build();
    TransportClient transportClient = new TransportClient(settings);

    Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("10.210.51.207",9300));

    IndexResponse response = client.prepareIndex("Cricket", "cric", "1").setSource(json).execute().actionGet();
    //List<String> matches = response.matches();
    System.out.println(response);
    System.out.println("finished");

我檢查了機器中的端口是否打開。

誰能幫助我理解問題。

提前致謝

我認為在提及集群名稱時出現問題。

    Settings settings =               ImmutableSettings.settingsBuilder()
   .put("cluster.name", "elasticsearch").build();

希望能幫助到你..!

這個答案https://stackoverflow.com/a/25053586/3827220針對類似的問題,適用於您所看到的錯誤消息。

檢查以確保您在客戶端和群集側使用的是相同的主版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM