問題背景:
將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了?暫時沒有搞清楚,希望有知道的朋友,留個言,幫我解一下惑。