今天在本地搭建一个测试用的最新版ElasticSearch6.4.3 的环境时,遇到一个报:
[Cannot assign requested address: bind]
的错误。
错误日志内容如下:
H:ElasticSearch6.4.3elasticsearch-6.4.3-node1in>H:ElasticSearch6.4.3elasticsearch-6.4.3-node1inel
asticsearch.bat
[2018-11-12T15:15:40,305][INFO ][o.e.n.Node ] [node-1] initializing ...
[2018-11-12T15:15:40,382][INFO ][o.e.e.NodeEnvironment ] [node-1] using [1] data paths, mounts [[(H:)]],
net usable_space [122.3gb], net total_space [299.9gb], types [NTFS]
[2018-11-12T15:15:40,383][INFO ][o.e.e.NodeEnvironment ] [node-1] heap size [990.7mb], compressed ordinar
y object pointers [true]
[2018-11-12T15:15:40,386][INFO ][o.e.n.Node ] [node-1] node name [node-1], node ID [FLk6CxQlTP
6kJDwVKWX30Q]
[2018-11-12T15:15:40,388][INFO ][o.e.n.Node ] [node-1] version[6.4.3], pid[28436], build[defau
lt/zip/fe40335/2018-10-30T23:17:19.084789Z], OS[Windows 7/6.1/amd64], JVM[Oracle Corporation/Java HotSpot(TM
) 64-Bit Server VM/1.8.0_131/25.131-b11]
[2018-11-12T15:15:40,390][INFO ][o.e.n.Node ] [node-1] JVM arguments [-Xms1g, -Xmx1g, -XX:+Use
ConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTo
uch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThr
ow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread
=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=C:UsersADMINI~1AppData
LocalTempelasticsearch, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err
_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplica
tionStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSiz
e=64m, -Delasticsearch, -Des.path.home=H:ElasticSearch6.4.3elasticsearch-6.4.3-node1, -Des.path.conf=H:E
lasticSearch6.4.3elasticsearch-6.4.3-node1config, -Des.distribution.flavor=default, -Des.distribution.typ
e=zip]
[2018-11-12T15:15:42,051][INFO ][o.e.p.PluginsService ] [node-1] loaded module [aggs-matrix-stats]
[2018-11-12T15:15:42,052][INFO ][o.e.p.PluginsService ] [node-1] loaded module [analysis-common]
[2018-11-12T15:15:42,053][INFO ][o.e.p.PluginsService ] [node-1] loaded module [ingest-common]
[2018-11-12T15:15:42,055][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-expression]
[2018-11-12T15:15:42,056][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-mustache]
[2018-11-12T15:15:42,058][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-painless]
[2018-11-12T15:15:42,059][INFO ][o.e.p.PluginsService ] [node-1] loaded module [mapper-extras]
[2018-11-12T15:15:42,061][INFO ][o.e.p.PluginsService ] [node-1] loaded module [parent-join]
[2018-11-12T15:15:42,062][INFO ][o.e.p.PluginsService ] [node-1] loaded module [percolator]
[2018-11-12T15:15:42,066][INFO ][o.e.p.PluginsService ] [node-1] loaded module [rank-eval]
[2018-11-12T15:15:42,067][INFO ][o.e.p.PluginsService ] [node-1] loaded module [reindex]
[2018-11-12T15:15:42,069][INFO ][o.e.p.PluginsService ] [node-1] loaded module [repository-url]
[2018-11-12T15:15:42,070][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty4]
[2018-11-12T15:15:42,072][INFO ][o.e.p.PluginsService ] [node-1] loaded module [tribe]
[2018-11-12T15:15:42,073][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-core]
[2018-11-12T15:15:42,075][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-deprecation]
[2018-11-12T15:15:42,077][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-graph]
[2018-11-12T15:15:42,078][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-logstash]
[2018-11-12T15:15:42,080][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-ml]
[2018-11-12T15:15:42,082][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-monitoring]
[2018-11-12T15:15:42,083][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-rollup]
[2018-11-12T15:15:42,085][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-security]
[2018-11-12T15:15:42,086][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-sql]
[2018-11-12T15:15:42,087][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-upgrade]
[2018-11-12T15:15:42,089][INFO ][o.e.p.PluginsService ] [node-1] loaded module [x-pack-watcher]
[2018-11-12T15:15:42,091][INFO ][o.e.p.PluginsService ] [node-1] no plugins loaded
[2018-11-12T15:15:45,477][INFO ][o.e.x.s.a.s.FileRolesStore] [node-1] parsed [0] roles from file [H:Elastic
Search6.4.3elasticsearch-6.4.3-node1config
oles.yml]
[2018-11-12T15:15:45,975][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/26596] [Main.cc@109] contro
ller (64 bit): Version 6.4.3 (Build 7a0781676dd492) Copyright (c) 2018 Elasticsearch BV
[2018-11-12T15:15:46,329][DEBUG][o.e.a.ActionModule ] Using REST wrapper from plugin org.elasticsearch
.xpack.security.Security
[2018-11-12T15:15:46,529][INFO ][o.e.d.DiscoveryModule ] [node-1] using discovery type [zen]
[2018-11-12T15:15:47,232][INFO ][o.e.n.Node ] [node-1] initialized
[2018-11-12T15:15:47,233][INFO ][o.e.n.Node ] [node-1] starting ...
[2018-11-12T15:15:47,739][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in
thread [main]
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9310]]; nested: Bind
Exception[Cannot assign requested address: bind];
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.4.3.jar:
6.4.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.3.j
ar:6.4.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elastics
earch-6.4.3.jar:6.4.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.
3.jar:6.4.3]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.3.jar:6.4.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.3.jar:6
.4.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.3.jar:6
.4.3]
Caused by: org.elasticsearch.transport.BindTransportException: Failed to bind to [9310]
at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:821) ~[elasticsearch-6.4.3.
jar:6.4.3]
at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:786) ~[elasticsearch-6.4.3.
jar:6.4.3]
at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:134) ~[?:?]
at org.elasticsearch.xpack.core.security.transport.netty4.SecurityNetty4Transport.doStart(SecurityNe
tty4Transport.java:87) ~[?:?]
at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4ServerTransport.doStart(SecurityN
etty4ServerTransport.java:41) ~[?:?]
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.ja
va:66) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.transport.TransportService.doStart(TransportService.java:217) ~[elasticsearch-6
.4.3.jar:6.4.3]
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.ja
va:66) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.node.Node.start(Node.java:667) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:265) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:335) ~[elasticsearch-6.4.3.jar:6.4.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.3.jar:
6.4.3]
... 6 more
Caused by: java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
at sun.nio.ch.Net.bind(Net.java:433) ~[?:?]
at sun.nio.ch.Net.bind(Net.java:425) ~[?:?]
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[?:?]
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128) ~[?:?]
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558) ~[?:?]
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1283) ~[?:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
~[?:?]
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) ~[?:?
]
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:989) ~[?:?]
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254) ~[?:?]
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:365) ~[?:?]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[?:?]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403
) ~[?:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) ~[?:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) ~[?:
?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
[2018-11-12T15:15:48,268][INFO ][o.e.n.Node ] [node-1] stopping ...
[2018-11-12T15:15:48,270][INFO ][o.e.n.Node ] [node-1] stopped
[2018-11-12T15:15:48,271][INFO ][o.e.n.Node ] [node-1] closing ...
[2018-11-12T15:15:48,282][INFO ][o.e.n.Node ] [node-1] closed
H:ElasticSearch6.4.3elasticsearch-6.4.3-node1in>
第一反应是端口冲突了,于是根据elasticsearch.yml配置文件中的http端口以及transport.tcp 端口通过命令查了下,没发现有其它进程占用:
解决:再后来查了下配置中的集群配置
discovery.zen.ping.unicast.hosts
的ip跟当前本机的network.host
不一致,果断把自己给坑了(-_-)(当然这是为了模拟集群而在一台机器上部署多个节点,生产环境不推荐这么搞,为了数据安全以及性能提升,还是一机一节点的好
)