问题背景:
将es部署到内网中两台服务器,其Ip地址分别为:192.111.222.5,192.111.222.1(部署方式完全一样,是将192.111.222.1服务器上es整个部署包,拷贝到了192.111.222.5,包括索引文件)。
在开发本机(IP:192.111.222.36)通过idea编译直接运行代码,从而连接对应es的服务器,连接192.111.222.1就没有任何问题,但连接192.111.222.5,就会报出异常,具体异常信息如下:
1
2
3
4
5
6
7
8
9
10
|
NoNodeAvailableException[None of the configured nodes are available: [{#transport#- 1 }{ 192.111 . 222.5 }{ 192.111 . 222.5 : 9300 }]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java: 290 )
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java: 207 )
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java: 55 )
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java: 286 )
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java: 351 )
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java: 1187 )
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java: 85 )
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java: 59 )
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java: 67 )
|
解决办法:将192.111.222.5服务器上配置文件elasticsearch.yml,具体位置如下
修改配置文件中的network.host项,将network.host: 0.0.0.0修改为本机ipnetwork.host: 192.111.222.5,搞定。
具体如下:
但有个问题就是192.111.222.1配置文件中的network.host项一直为network.host: 0.0.0.0,但可以正常访问啊,为什么192.111.222.5就需要修改为本机ip了?暂时没有搞清楚,希望有知道的朋友,留个言,帮我解一下惑。