我已经使用Custom Application在Open Shift中配置了Elastic Search Server。弹性服务器版本为1.4.2。我关注了这个tutorial。我能够成功地启动服务器,也可以从我的java应用程序获得连接。但是当我尝试创建一个索引时,它显示了错误。
Java代码:
CreateIndexRequestBuilder prepareCreate = client.admin().indices().prepareCreate("index1");
prepareCreate.execute().actionGet();错误:
Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:278)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
at org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:98)
at org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:334)
at org.elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:313)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at com.lri.ecareagoradiscoovery.indexing.RemoteEs.createIndex(RemoteEs.java:51)
at com.lri.ecareagoradiscoovery.indexing.RemoteEs.main(RemoteEs.java:62)请帮我解决这个问题。提前感谢
发布于 2016-01-12 20:44:11
使用REST服务验证您是否可以连接,并确保您使用的端口是正确的。
默认情况下,Openshift不会开放很多端口,所以这可能就是您的问题所在。你可以很容易地用CURL,WGET或web浏览器进行检查。如果我想查看ES是否在本地工作,我只需转到http://localhost:9200/并查看:
{
"name" : "Tommy Lightning",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.1.0",
"build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
"build_timestamp" : "2015-11-18T22:40:03Z",
"build_snapshot" : false,
"lucene_version" : "5.3.1"
},
"tagline" : "You Know, for Search"
}在担心通过Java连接和创建索引之前,我要确保您可以做到这一点。REST接口使测试一切正常变得非常容易。
如果你得到了错误,就把你得到的东西发布出来。
发布于 2016-01-13 13:27:48
如果您使用的是TransportClient,请确保主机名与您可以从System.getenv().get("OPENSHIFT_DIY_IP")获得的$OPENSHIFT_DIY_IP,匹配。假设您在ES配置中指定了相同的配置:network.host。
更新:根据输入Java应用程序在另一台主机上
来自Install elasticsearch on OpenShift:仅将此解决方案用于非生产用途
在config/elasticsearch.yml
ctl_app stophttps://stackoverflow.com/questions/34743854
复制相似问题