我有一台Windows机器,它在VirtualBox上有一台Ubuntu机器,它运行Elasticsearch 2.4。我通过VirtualBox的端口映射映射了端口9200,9300和5601,并在我的Ubuntu实例中允许iptables上的端口。
但是,当Java尝试连接时,我收到此错误:
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) ~[elasticsearch-2.4.1.jar:2.4.1]
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64) ~[elasticsearch-2.4.1.jar:2.4.1]
at eu.adsdaq.elasticsearch.importer.sync.service.OrderHistoryService.sendBulkRequest(OrderHistoryService.java:133) [classes/:na]
at eu.adsdaq.elasticsearch.importer.sync.service.OrderHistoryService.syncOrderHistory(OrderHistoryService.java:69) [classes/:na]
at eu.adsdaq.elasticsearch.importer.sync.service.OrderHistoryService.sync(OrderHistoryService.java:45) [classes/:na]
at eu.adsdaq.elasticsearch.importer.sync.ElasticsearchSyncService.lambda$0(ElasticsearchSyncService.java:32) [classes/:na]
at eu.adsdaq.elasticsearch.importer.sync.ElasticsearchSyncService$$Lambda$3/910457645.accept(Unknown Source) [classes/:na]
at java.util.ArrayList.forEach(ArrayList.java:1249) [na:1.8.0_45] ...
在此错误之前,我也会看到类似的内容,
org.elasticsearch.plugins : [Chimera] modules [], plugins [], sites []
该日志发生在我最初创建Client对象的代码段的最后一行:
Settings settings = Settings.builder()
.put("cluster.name", properties.getClusterName())
.put("client.transport.sniff", properties.isSniffing())
.build();
TransportAddress address;
try {
address = new InetSocketTransportAddress(InetAddress.getByName(properties.getHost()), properties.getPort());
} catch (UnknownHostException exception) {
logger.error("Error : unknown elasticsearch host " + properties.getHost() + ":"
+ properties.getPort(), exception);
throw new RuntimeException(exception);
}
client = TransportClient.builder().settings(settings).build().addTransportAddress(address);
所以奇怪的是:我最初没有收到错误,但是当我尝试使用同一个客户端插入数据时,我会在以后收到错误。
我在这里使用localhost作为我的主持人。当我尝试0.0.0.0时,我也得到了类似的错误。我可以从浏览器和控制台访问http://localhost:9200。所以我知道端口映射在某种程度上起作用。
有关如何解决此问题的任何帮助表示赞赏。