elasticsearch 5.5.3与搬运工人Java客户端API NoNodeAvailable

2019-09-28 19:00发布

我从网上下载图像与泊坞窗安装Elasticsearch并运行以下命令来启动:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.5.3

使用传送客户来访问它。

Settings settings = Settings.builder()
        .put("cluster.name", "docker-cluster").build();
TransportClient client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(my-elastic, 9300)));

我什么也不做,但我得到了一个错误NoNodeAvailableException:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{9VJdNJv9S7O3Pchx2z2wEg}{my-elastic}{192.168.99.100:9300}]]

我应该怎么做才能解决这个问题?

启动日志:

my-elastic               | [2017-11-01T07:45:52,040][INFO ][o.e.n.Node               ] [] initializing ...
my-elastic               | [2017-11-01T07:45:52,178][INFO ][o.e.e.NodeEnvironment    ] [h-M1oJa] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda1)]], net usable_space [8.3gb], net total_space [17.8gb], spins? [possibly], types [ext4]
my-elastic               | [2017-11-01T07:45:52,179][INFO ][o.e.e.NodeEnvironment    ] [h-M1oJa] heap size [1.9gb], compressed ordinary object pointers [true]
my-elastic               | [2017-11-01T07:45:52,184][INFO ][o.e.n.Node               ] node name [h-M1oJa] derived from node ID [h-M1oJaUTY-G0ezl-89-cw]; set [node.name] to override
my-elastic               | [2017-11-01T07:45:52,185][INFO ][o.e.n.Node               ] version[5.5.2], pid[1], build[b2f0c09/2017-08-14T12:33:14.154Z], OS[Linux/4.4.52-boot2docker/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_141/25.141-b15]
my-elastic               | [2017-11-01T07:45:52,185][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/share/elasticsearch]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [aggs-matrix-stats]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [ingest-common]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [lang-expression]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [lang-groovy]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [lang-mustache]
my-elastic               | [2017-11-01T07:45:54,225][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [lang-painless]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [parent-join]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [percolator]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [reindex]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [transport-netty3]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] loaded module [transport-netty4]
my-elastic               | [2017-11-01T07:45:54,226][INFO ][o.e.p.PluginsService     ] [h-M1oJa] no plugins loaded
my-elastic               | [2017-11-01T07:45:57,851][INFO ][o.e.d.DiscoveryModule    ] [h-M1oJa] using discovery type [zen]
my-elastic               | [2017-11-01T07:45:59,062][INFO ][o.e.n.Node               ] initialized
my-elastic               | [2017-11-01T07:45:59,062][INFO ][o.e.n.Node               ] [h-M1oJa] starting ...
my-elastic               | [2017-11-01T07:45:59,376][INFO ][o.e.t.TransportService   ] [h-M1oJa] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
my-elastic               | [2017-11-01T07:46:02,520][INFO ][o.e.c.s.ClusterService   ] [h-M1oJa] new_master {h-M1oJa}{h-M1oJaUTY-G0ezl-89-cw}{dYFfXS4vToOMMfAEWy57ig}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
my-elastic               | [2017-11-01T07:46:02,588][INFO ][o.e.h.n.Netty4HttpServerTransport] [h-M1oJa] publish_address {172.18.0.8:9200}, bound_addresses {[::]:9200}
my-elastic               | [2017-11-01T07:46:02,591][INFO ][o.e.n.Node               ] [h-M1oJa] started

我可以访问http://192.168.99.100:9200与邮差。

{
    "name": "-v9MHhY",
    "cluster_name": "docker-cluster",
    "cluster_uuid": "Ig6tY10oSc6hAbpLqo9fcg",
    "version": {
        "number": "5.5.3",
        "build_hash": "9305a5e",
        "build_date": "2017-09-07T15:56:59.599Z",
        "build_snapshot": false,
        "lucene_version": "6.6.0"
    },
    "tagline": "You Know, for Search"
}

远程登录192.168.99.100:9200是OK。
远程登录192.168.99.100:9300是OK。
远程登录才能访问这两个端口。

而我使用的弹簧boot2.0.0M5。 elasticsearch的缺省版本为5.5.3。

Answer 1:

配置network.host: 0.0.0.0上elasticsearch.yml

常见错误:

  • 忘记定义network.host在机器上
  • cluster.name改变
  • 使用防火墙问题port 9300

参考文献:

network.host

所述network.host在常用网络设置设置解释是快捷方式设定所述结合主机和同时发布主机。 在先进的使用情况下,在代理服务器中运行时,例如,您可能需要设置这些设置为不同的值:

network.bind_host

这指定哪个网络接口(一个或多个)节点应绑定到以监听传入的请求。 节点可以绑定到多个接口,例如,两个网卡,或者站点本地地址和本地地址。 默认为network.host。

network.publish_host

发布主机是节点通告给其他节点的集群中,以使这些节点可以连接到它的单个接口。 目前的Elasticsearch节点可以被绑定到多个地址,但只有一个发布。 如果没有指定,默认为需从network.host“最好”的地址,通过支持IPv4 / IPv6双协议栈的偏好排序,然后通过可达性。 如果设置了network.host导致多种绑定地址又依赖于特定的地址进行节点对节点的通信,你应该明确地network.publish_host设置。

网络设置

network.host

该节点将绑定到该主机名或IP地址和发布(广告),这台主机到集群中的其他节点。 接受的IP地址,主机名,一个特殊的值,或者这些的任何组合的阵列。

默认为本地

HTTP-设置

http.bind_host

主机地址绑定的HTTP服务。 默认为http.host(如果设置)或network.bind_host。

http.publish_host

主机地址发布的HTTP客户端连接到。 默认为http.host(如果设置)或network.publish_host。

http.host

用于设置http.bind_host和http.publish_host默认为http.host或network.host。



文章来源: elasticsearch 5.5.3 Java client API NoNodeAvailableException with docker