如何在弹性搜索中创建culster 6.2

时间:2018-06-05 19:29:31

标签: elasticsearch elasticsearch-5

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

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

  //  ClusterAdminClient clusterAdminClient = client.admin().cluster();


    ClusterHealthResponse healths = client.admin().cluster().prepareHealth().get();
    String clusterName = healths.getClusterName();
    System.out.println(clusterName);

我在纠错这个错误 线程“main”中的异常NoNodeAvailableException [没有配置的节点可用:[{#transport#-1} {zJ52yLDcR82UUQ7j-oxm6w} {127.0.0.1} {127.0.0.1:9300}]]

1 个答案:

答案 0 :(得分:0)

您想通过Java连接到elasticsearch,对吧?

  1. 我建议使用HTTP传输(端口9200)而不是9300
  2. 您启用了“嗅探”,这意味着Java客户端将尝试直接连接到每个节点,确保可以进行通信
  3. 确保您可以从运行Java客户端的位置curl select TO_CHAR(Table1), Column1, column2 from a where Table1 between to_date(:beg_awd_date,'DD-MON-YYYY') AND to_date(:end_awd_date,'DD-MON-YYYY') order by column1