ElasticSearch 2.0传输客户机 - 无节点可用异常 [英] ElasticSearch 2.0 Transport Client - No Node Available exception
问题描述
[使用ElasticSearch 2.0版]
在etc / hosts文件中,esnode映射到IP地址(ES运行的其他一些机器) p>
192.168.2.219 esnode
运输客户端代码是::
public Client getClient(){
if((this.client == null)){
try {
设置设置=设置。 settingsBuilder()
.put(cluster.name,myclustername)。build();
TransportClient tClient = TransportClient.builder()。settings(settings).build();
String [] nodes =esnode:9300.split(COMMA);
(String node:nodes){
String [] hostPort = node.split(COLON);
tClient.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName(hostPort [0]),Integer.parseInt(hostPort [1])));
}
this.client = tClient;
} catch(Exception e){
e.printStackTrace();
}
}
return this.client;
}
此客户端代码运行,但执行以下代码时:
此.getClient()。prepareGet(indexName,typeName,String.valueOf(id))。get();
抛出异常:
NoNodeAvailableException [没有配置节点可用:[]]
在org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)
在org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java :197)
在org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
在org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272 )
在org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
在org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
在org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
在org.elasticsearch.action.ActionRequestBuilder.g et(ActionRequestBuilder.java:67)
我也尝试使用IPAddress而不是主机名。如果
esnode映射到127.0.0.1
可以有人帮助...
设置弹性搜索主机ip地址到elastic.arch.yml中的network.host值
network.host:es_host_ip
这是解决TransportClient NoNodeAvailableException问题。
[Using ElasticSearch version 2.0]
In etc/hosts file "esnode" is mapped to IP address(some other machine where ES is running) as shown
192.168.2.219 esnode
The Transport Client code is ::
public Client getClient() {
if ((this.client == null)) {
try {
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "myclustername").build();
TransportClient tClient = TransportClient.builder().settings(settings).build();
String[] nodes = "esnode:9300".split(COMMA);
for (String node : nodes) {
String[] hostPort = node.split(COLON);
tClient.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName(hostPort[0]), Integer.parseInt(hostPort[1])));
}
this.client = tClient;
} catch (Exception e) {
e.printStackTrace();
}
}
return this.client;
}
This client code runs but when executing the below code : this.getClient().prepareGet(indexName, typeName, String.valueOf(id)).get();
The exception is thrown:
NoNodeAvailableException[None of the configured nodes are available: []]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:67)
I have also tried using IPAddress instead of host name. The above code runs properly if
esnode is mapped to 127.0.0.1
Can somebody help...
Setup elasticsearch host ip address to network.host value in elasticsearch.yml
network.host: es_host_ip
This is solve TransportClient NoNodeAvailableException issue.
这篇关于ElasticSearch 2.0传输客户机 - 无节点可用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!