Elasticsearch NoNodeAvailableException

时间:2015-10-13 12:46:29

标签: elasticsearch elasticsearch-java-api

我从Elasticsearch收到以下错误。

`<html><head><title>Apache Tomcat/7.0.64 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Request processing failed; nested exception is org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Request processing failed; nested exception is org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
myapp.filter.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:22)
</pre></p><p><b>root cause</b> <pre>org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:305)
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:200)
org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.execute(InternalTransportIndicesAdminClient.java:86)
org.elasticsearch.client.support.AbstractIndicesAdminClient.exists(AbstractIndicesAdminClient.java:178)
org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder.doExecute(IndicesExistsRequestBuilder.java:53)
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
myapp.dao.CommonDao.ValidateTenant(CommonDao.java:7)
myapp.dao.CliffDomainDao.viewCliffDomains(CliffDomainDao.java:55)
myapp.service.CliffDomainService.getall(CliffDomainService.java:53)
myapp.controller.CliffDomainController.getall(CliffDomainController.java:79)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
myapp.filter.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:22)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.64 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.64</h3></body></html>`

我在Ubuntu上运行Elasticsearch 1.7.2。

我在elasticsearch.yml中所做的更改

################################### Cluster ###################################

# Cluster name identifies your cluster for auto-discovery. If you're running
# multiple clusters on the same network, make sure you're using unique names.
#
cluster.name: cliffservice




# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
#network.publish_host: 192.168.0.1
network.publish_host: 10.100.10.231
# Set both 'bind_host' and 'publish_host':
#
#network.host: 192.168.0.1

连接代码

public TransportClient getClient() {
    Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "cliffservice").build();
    TransportClient client = new TransportClient(settings);
    client = client.addTransportAddress(new InetSocketTransportAddress(this.host, this.port));

    this.esclient = client;

    return client;
}

从弹性客户端获取数据

SearchResponse response = Connection.getEsclient().prepareSearch("testindex").setTypes("testtype").execute()
                .actionGet();

        if (response.getHits().getHits().length > 0) {
            for (SearchHit hit : response.getHits().getHits()) {
                CliffDomain cliffDomain = new CliffDomain();

                assetDomain.setCliffDomainId(hit.getId());
                assetDomain.setCliffDomainName((String) hit.sourceAsMap().get("clifftDomainName"));

                searchResponse.add(cliffDomain);

            }
        }

我做错了什么?

2 个答案:

答案 0 :(得分:1)

您的客户端和服务位于不同的群集中。客户端位于assetservice,服务器位于cliffservice。此外,请确保客户端可以连接到10.100.10.231的端口9300。

答案 1 :(得分:0)

最后我发现了问题。我在我的Java应用程序中使用elasticsearch-1.7.1。在我的本地计算机上安装了Elasticsearch-1.7.1,但在服务器中,elasticsearch的版本是1.7.2。那就是问题所在。我将服务器的弹性搜索降级到1.7.1,现在它运行正常。