问题
I have setup a SSH tunnel on port 9300 to my remote elasticsearch server.
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();
回答1:
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
has fixed it
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
来源:https://stackoverflow.com/questions/38433615/elasticsearch-basic-client-connection