我正在尝试使用 YCSB 将一些数据加载到 Elastic Search 中,但我经常遇到错误NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{gdVShcjUToSDe3eJkHJNxw}{192.168.3.87}{192.168.3.87:9300}]]
这是我对弹性搜索节点的配置。
cluster.name: my-application
node.name: reconf-6
network.host: 192.168.3.87
http.port: 9200
transport.tcp.port: 9300
transport.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["elasticsearch-1"]
path.data: data_mount/es
path.logs: data_mount/es
我首先像这样启动了 10 个节点,curl -XGET 'http://elasticsearch-1:9200/_cluster/state?pretty'
我可以看到集群中有 10 个节点。
然后我尝试在远程模式下运行 YCSB。然后它报告异常:
Exception in thread "Thread-3" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{gdVShcjUToSDe3eJkHJNxw}{192.168.3.87}{192.168.3.87:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:344)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:242)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:356)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:392)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1220)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.exists(AbstractClient.java:1242)
at com.yahoo.ycsb.db.elasticsearch5.ElasticsearchClient.init(ElasticsearchClient.java:142)
at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:85)
at com.yahoo.ycsb.ClientThread.run(Client.java:415)
at java.lang.Thread.run(Thread.java:748)
YCSB中启动Client的部分代码如下:
if (remoteMode) {
settings.put("client.transport.sniff", true)
.put("client.transport.ignore_cluster_name", false)
.put("client.transport.ping_timeout", "30s")
.put("client.transport.nodes_sampler_interval", "30s");
// Default it to localhost:9300
String[] nodeList = props.getProperty("es.hosts.list", DEFAULT_REMOTE_HOST).split(",");
System.out.println("Elasticsearch Remote Hosts = " + props.getProperty("es.hosts.list", DEFAULT_REMOTE_HOST));
TransportClient tClient = new PreBuiltTransportClient(settings.build());
for (String h : nodeList) {
String[] nodes = h.split(":");
try {
tClient.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName(nodes[0]),
Integer.parseInt(nodes[1])
));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Unable to parse port number.", e);
} catch (UnknownHostException e) {
throw new IllegalArgumentException("Unable to Identify host.", e);
}
}
client = tClient;
}