web端連接es
通過安裝head插件,可以通過地址http://localhost:9200/_plugin/head/ 來訪問控制臺(tái)
java client 連接es遇到的2個(gè)問題
<b>沒有可用的節(jié)點(diǎn)</b>
javaclient連接未經(jīng)配置的es,會(huì)報(bào)出<code>None of the configured nodes are available</code>異常。解決辦法是配置2個(gè)參數(shù)。這兩個(gè)參數(shù)可以在<code>es_home/config/elasticsearch.yml</code>中配置。然后重啟es即可。
network.publish_host: 192.168.1.75
network.bind_host: 192.168.1.75##z注意,":"后面要加一個(gè)空格,否則會(huì)報(bào)錯(cuò)。
參數(shù)配置成功后,如果仍然報(bào)相同的錯(cuò)誤,請(qǐng)確保防火墻的策略正確,或者防火墻被關(guān)閉。
下面有詳細(xì)的異常信息和其他的一些相關(guān)信息。
異常信息:
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.168.1.75}{es/192.168.1.75: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:288)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)
at c11_se.es.EsDemo.main(EsDemo.java:20)
分析:
原因是默認(rèn)情況下(2.3.x)的transport模塊的2個(gè)配置發(fā)布地址、綁定地址的host是<code>127.0.0.1</code>
啟動(dòng)日志中會(huì)打印這兩個(gè)參數(shù)
<code>[xxxx][INFO ][transport ] [Zero] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}</code>
在_plugin/head界面中也可以查看到這些信息。
Paste_Image.png
。
只需要對(duì)這這2個(gè)配置進(jìn)行修改即可。