我有一个服务器,它有一个公共 ip 和一个私有 ip,在该服务器上运行弹性搜索服务,私有 ip 是10.x.x.x
,公共 ip 是159.x.x.x
但这里抛出java.net.NoRouteToHostException: No route to host
的异常是代码
val setting=ImmutableSettings.settingsBuilder();
//setting.put("network.host",host)
setting.put("path.home", ".")
setting.put("discovery.zen.ping.unicast.hosts",host);
setting.put("http.port",http_port)
setting.put("transport.tcp.port",tcp_port)
val node= nodeBuilder().clusterName(clusterName).client(true).settings(setting).node();
val client=node.client()
es.http.port="9200-9300"
es.tcp.port="9300-9400"
es.host="10.x.x.x" //giving the private ip
这是堆栈跟踪
expire [null], clean_interval [1m]
03:00:04.753 9024 [main] cache DEBUG - [Maynard Tiboldt] using size [-1] [-1b], expire [null]
03:00:04.772 9043 [main] meta DEBUG - [Maynard Tiboldt] using gateway.local.auto_import_dangled [YES], gateway.local.delete_timeout
[30s], with gateway.local.dangling_timeout [2h]
03:00:04.778 9049 [main] udp DEBUG - [Maynard Tiboldt] using enabled [false], host [null], port [9700-9800], bulk_actions [1000], b
ulk_size [5mb], flush_interval [5s], concurrent_requests [4]
03:00:04.784 9055 [main] node INFO - [Maynard Tiboldt] initialized
03:00:04.784 9055 [main] node INFO - [Maynard Tiboldt] starting ...
03:00:04.809 9080 [main] SelectorUtil DEBUG - Using select timeout of 500
03:00:04.810 9081 [main] SelectorUtil DEBUG - Epoll-bug workaround enabled = false
03:00:04.834 9105 [main] netty DEBUG - [Maynard Tiboldt] using profile[default], worker_count[4], port[9300-9400], bind_host[null], publish_host[null], compress[false], connect_timeout[30s], connections_per_node[2/3/6/1/1], receive_predictor[512kb->512kb]
03:00:04.879 9150 [main] netty DEBUG - [Maynard Tiboldt] Bound profile [default] to address [/0:0:0:0:0:0:0:0:9300]
03:00:04.886 9157 [main] transport INFO - [Maynard Tiboldt] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/10.17.0.8:9300]}
03:00:04.922 9193 [main] discovery INFO - [Maynard Tiboldt] myCluster/pYsg3lDZTcyxvDl671T04A
03:00:04.923 9194 [elasticsearch[Maynard Tiboldt][clusterService#updateTask][T#1]] service DEBUG - [Maynard Tiboldt] processing [initial_join]: execute
03:00:04.930 9201 [elasticsearch[Maynard Tiboldt][clusterService#updateTask][T#1]] service DEBUG - [Maynard Tiboldt] processing [initial_join]: took 6ms no change in cluster_state
03:00:05.141 9412 [elasticsearch[Maynard Tiboldt][[unicast_connect]][T#1]] netty DEBUG - [Maynard Tiboldt] connected to node [[#zen_unicast_1#][elasticsearch1.myserver.com][inet[/159.x.x.x:9300]]]
03:00:06.486 10757 [elasticsearch[Maynard Tiboldt][[unicast_connect]][T#2]] netty DEBUG - [Maynard Tiboldt] connected to node [[Maynard Tiboldt][pYsg3lDZTcyxvDl671T04A][elasticsearch1.myserver.com][inet[/10.17.0.8:9300]]{data=false, client=true}]
03:00:09.461 13732 [elasticsearch[Maynard Tiboldt][transport_client_boss][T#1]{New I/O boss #5}] netty WARN - [Maynard Tiboldt] exception caught on transport layer [[id: 0x4dfc0f6a]], closing connection
java.net.NoRouteToHostException: No route to host
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_66]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_66]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [hazelserver-assembly-1.0.jar:1.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
03:00:09.463 13734 [elasticsearch[Maynard Tiboldt][transport_client_boss][T#1]{New I/O boss #5}] netty WARN - [Maynard Tiboldt] exception caught on transport layer [[id: 0x470656c3]], closing connection
java.net.NoRouteToHostException: No route to host
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_66]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_66]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [hazelserver-assembly-1.0.jar:1.0]
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [hazelserver-assembly-1.0.jar:1.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
03:00:09.466 13737 [elasticsearch[Maynard Tiboldt][generic][T#2]] netty DEBUG - [Maynard Tiboldt] disconnecting from [[#zen_unicast_1#][elasticsearch1.myserver.com][inet[/159.x.x.x:9300]]] due to explicit disconnect call
03:00:09.467 13738 [elasticsearch[Maynard Tiboldt][generic][T#1]] zen DEBUG - [Maynard Tiboldt] filtered ping responses: (filter_client[true], filter_data[false]) {none}
03:00:09.476 13747 [elasticsearch[Maynard Tiboldt][[unicast_connect]][T#1]] netty DEBUG - [Maynard Tiboldt] connected to node [[#zen_unicast_1#][elasticsearch1.myserver.com][inet[/159.203.107.230:9300]]]
03:00:12.459 16730 [elasticsearch[Maynard Tiboldt][transport_client_boss][T#1]{New I/O boss #5}] netty WARN - [Maynard Tiboldt] exception caught on transport layer [[id: 0x665f3000]], closing connection
java.net.NoRouteToHostException: No route to host
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_66]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_66]
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152) [hazelserver-assembly-1.0.jar:1.0]
在这里,我无法在日志中看到私有 IP,其中 10.xxx 我只能看到这个 10.17.0.8:9300,而且我不知道这个 IP 地址,elasticsearch 客户端代码和 elasticsarch 服务也在同一台服务器上运行,有人可以请指出我正在做的错误