带有docker的elasticsearch 5.5.3 Java客户端API NoNodeAvailableException [英] elasticsearch 5.5.3 Java client API NoNodeAvailableException with docker

查看:36
本文介绍了带有docker的elasticsearch 5.5.3 Java客户端API NoNodeAvailableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从使用Docker安装Elasticsearch 下载了该镜像并运行以下命令以启动:

I downloaded the image from Install Elasticsearch with Docker and run the following command to start up:

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错误:

I did nothing else, but I got a NoNodeAvailableException error:

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

我该怎么做才能解决此问题?

What should I do to fix this issue?

启动日志:

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 .

I could access http://192.168.99.100:9200 with Postman.

{
    "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"
}

telnet 192.168.99.100:9200正常.
telnet 192.168.99.100:9300是可以的.
telnet可以访问这两个端口.

telnet 192.168.99.100:9200 is OK.
telnet 192.168.99.100:9300 is OK.
telnet can access these two ports.

我正在使用spring boot2.0.0M5.elasticsearch的默认版本是5.5.3.

And I'm using spring boot2.0.0M5. The default version of elasticsearch is 5.5.3.

推荐答案

在elasticsearch.yml上配置 network.host:0.0.0.0

Configure network.host: 0.0.0.0 on elasticsearch.yml

常见错误:

  • 忘记在计算机上定义 network.host
  • cluster.name 已更改
  • 端口9300的防火墙问题

参考:

network.host

常用网络设置中介绍的network.host设置是一种快捷方式,可同时设置绑定主机和发布主机.在高级使用情况下,例如在代理服务器上运行时,您可能需要将这些设置设置为不同的值:

The network.host setting explained in Commonly used network settings is a shortcut which sets the bind host and the publish host at the same time. In advanced used cases, such as when running behind a proxy server, you may need to set these settings to different values:

network.bind_host

network.bind_host

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

This specifies which network interface(s) a node should bind to in order to listen for incoming requests. A node can bind to multiple interfaces, e.g. two network cards, or a site-local address and a local address. Defaults to network.host.

network.publish_host

network.publish_host

发布主机是节点向集群中其他节点发布的单个接口,以便这些节点可以连接到该主机.当前,Elasticsearch节点可能绑定到多个地址,但仅发布一个.如果未指定,则默认为network.host的最佳"地址,按IPv4/IPv6堆栈首选项,然后按可达性排序.如果您设置的network.host导致多个绑定地址,但依赖于特定的地址进行节点到节点的通信,则应显式设置network.publish_host.

The publish host is the single interface that the node advertises to other nodes in the cluster, so that those nodes can connect to it. Currently an Elasticsearch node may be bound to multiple addresses, but only publishes one. If not specified, this defaults to the "best" address from network.host, sorted by IPv4/IPv6 stack preference, then by reachability. If you set a network.host that results in multiple bind addresses yet rely on a specific address for node-to-node communication, you should explicitly set network.publish_host.

网络设置

network.host

network.host

该节点将绑定到该主机名或IP地址,并将该主机发布(发布)到群集中的其他节点.接受IP地址,主机名,特殊值或它们的任意组合的数组.

The node will bind to this hostname or IP address and publish (advertise) this host to other nodes in the cluster. Accepts an IP address, hostname, a special value, or an array of any combination of these.

默认为本地.

HTTP设置

http.bind_host

http.bind_host

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

The host address to bind the HTTP service to. Defaults to http.host (if set) or network.bind_host.

http.publish_host

http.publish_host

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

The host address to publish for HTTP clients to connect to. Defaults to http.host (if set) or network.publish_host.

http.host

http.host

用于将http.bind_host和http.publish_host的默认值设置为http.host或network.host.

Used to set the http.bind_host and the http.publish_host Defaults to http.host or network.host.

这篇关于带有docker的elasticsearch 5.5.3 Java客户端API NoNodeAvailableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆