简体   繁体   English

与远程弹性搜索集群的连接失败

[英]Connection to remote elastic search cluster fails

I am trying to connect to a remote elastic search cluster using Transport client. 我正在尝试使用传输客户端连接到远程弹性搜索集群。

public class AuthenticationExample {

    public static void main(String[] args) throws Exception {
        if (args.length != 4) {
            System.out.println("Usage :\njava -jar jarFile.jar clusterName hostIP port index");
            System.exit(0);
        }
        String clusterName = args[0];
        String hostName = args[1];
        int port = Integer.parseInt(args[2]);
        String index = args[3];
        Settings settings = Settings.builder()
                .put("cluster.name", clusterName).build();
        TransportClient esClient = new PreBuiltTransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostName), port));
        esClient.threadPool().getThreadContext().putHeader("Authorization", "Basic " + Base64.encodeBase64("user:password".getBytes()));
        System.out.println("Initialized successfully.");
        boolean isIndexExists = false;
        isIndexExists = esClient.admin().indices().prepareExists(index).execute().actionGet().isExists();
        if (isIndexExists) {
            System.out.println("Is Index " + index + " Exists? " + isIndexExists);
        } else {
            System.out.println("Index " + index + " does not exist");
        }
    }
}

When I run the above code, as 当我运行上面的代码时,

java -jar jarFile.jar clusterName XXX.XXX.XXX.XXX 9300 indexName java -jar jarFile.jar clusterName XXX.XXX.XXX.XXX 9300 indexName

I am getting the following exception NoNodeAvailableException[None of the configured nodes are available: ... 我收到以下异常NoNodeAvailableException [没有已配置的节点可用:...

Also when I hit the endpoint using, 另外,当我使用

curl -XGET -u user:password http://XXX.XXX.XXX.XXX:9200 curl -XGET -u用户:密码http://XXX.XXX.XXX.XXX:9200

I am getting the response as follows, 我得到如下回应,

{
  "name" : "XfJq4ed",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "26yoM76iT8i-eo8k0E8y4g",
  "version" : {
    "number" : "5.4.0",
    "build_hash" : "780f8c4",
    "build_date" : "2017-04-28T17:43:27.229Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.0"
  },
  "tagline" : "You Know, for Search"
}

Kindly give me a solution. 请给我一个解决方案。 Thanks 谢谢

Did you allowed the HTTP module? 您是否允许HTTP模块?

You can see the avalaible options here: https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-http.html 您可以在此处查看可用的选项: https ://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-http.html

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

相关问题 elasticsearch集群如何连接多个master节点 - How to connect to multiple master nodes of elastic search cluster Jboss 7服务器的远程连接因代理异常而失败 - Remote connection of Jboss 7 server fails with Proxy exception 与远程MySQL DB的JDBC连接失败; - JDBC connection to remote MySQL DB fails; Spring Boot 弹性搜索在服务器启动时失败 - Spring boot elastic search fails on server start up 尝试连接到远程群集节点时,连接立即中止 - Connection immediately is aborted when trying to connect to remote cluster-node Springboot 弹性搜索健康管理:ConnectException:连接被拒绝 - Springboot elastic search health management : ConnectException: Connection refused 我们是否应该在 JestHttpClient 响应后关闭连接以进行弹性搜索 - Should we not be closing the connection after response in JestHttpClient for elastic search Spring 引导 + 弹性搜索:Java RestHighLevelClient 拒绝连接 - Spring Boot + Elastic Search : Connection Refused with Java RestHighLevelClient Ignite客户端无法建立与集群的连接,导致JVM立即停机 - Ignite Client Fails to Establish Connection to Cluster, Causes JVM to be Halted Immediately 如何在spring boot中使用弹性搜索模板id(存储在ES集群中)得到结果 - How to use elastic search template id(stored in ES cluster) in spring boot get result
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM