Elasticsearch基本客户端连接 [英] Elasticsearch basic client connection
问题描述
我已经在端口9300上建立了到我的远程Elasticsearch服务器的SSH隧道.
I have setup a SSH tunnel on port 9300 to my remote elasticsearch server.
在运行此基本示例时,获取示例数据从elasticsearch实例中,我得到一个" org.elasticsearch.client.transport.NoNodeAvailableException:无可用节点"
When running this basic example to get the example data from the elasticsearch instance I get a "org.elasticsearch.client.transport.NoNodeAvailableException: No node available"
Settings settings = ImmutableSettings.settingsBuilder()
.build();
Client client = new TransportClient(settings).addTransportAddress(
new InetSocketTransportAddress(InetAddress.getLocalHost().getHostName(), 9300));
GetResponse getResponse = client.prepareGet("bank", "account", "25").execute().actionGet();
推荐答案
我的设置是我从本地主机连接到在docker-container中运行elasticsearch的远程计算机,并且使用transportclient在9300端口上遇到了相同的问题与netty4.连接到隧道端口9200没问题
my setup is that i connect from my localhost to a remote machine where elasticsearch is running in a docker-container and i got the same problem on port 9300 using transportclient with netty4. connecting to the tunneled port 9200 was no problem
transport.publish_host: localhost
已修复
所以我的es.yml现在有:
so my es.yml has now:
http.host: 0.0.0.0
transport.host: 172.18.0.33
transport.publish_host: localhost
我通过以下方法来建立隧道:
and i do the tunnel via:
ssh -N -L 9300:172.18.0.33:9300 user@server.com
这篇关于Elasticsearch基本客户端连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!