-1

my cluster it's not in the same network, and there is a tunnel between my pc and the server.

i have got this error :

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available

nounou
  • 11
  • 4

3 Answers3

0

If you are using elasticsearch default multicast mechanism to discover nodes in the cluster you must have all cluster nodes located on the same subnet (this is true till version 2.0).
In order to have your node discovering the other nodes in the cluster you may configure [elasticsearch home]/config/elasticsearch.yaml field name: discovery.zen.ping.unicast.hosts as described [here] (https://www.elastic.co/guide/en/elasticsearch/reference/2.x/modules-network.html):

discovery.zen.ping.unicast.hosts

In order to join a cluster, a node needs to know the hostname or IP address of at least some of the other nodes in the cluster. This >settting provides the initial list of other nodes that this node will try to contact. Accepts IP addresses or hostnames.

Defaults to ["127.0.0.1", "[::1]"].

Hope it helps.

Eyal.Dahari
  • 760
  • 6
  • 13
  • thank you for your answer, but in my case I use as a TransportClient, this is the code that i use : Settings settings = ImmutableSettings.settingsBuilder() .put("cluster.name", "fast_elastic").build(); this.client = new TransportClient(settings) .addTransportAddress(new InetSocketTransportAddress("localhost, port)); – nounou Jan 28 '16 at 14:40
  • `InetSocketTransportAddress` should use the address/hostname of a node in your cluster (not `localhost`). The port number (if you are working with defaults) should be 9300 as follows: `settings = ImmutableSettings.settingsBuilder() .put("cluster.name", "fast_elastic").build(); this.client = new TransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("tunneled server name"), 9300));` More info can be found [here](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html) – Eyal.Dahari Jan 28 '16 at 21:40
  • but in my port forwarding (putty) i have: L9300 localhost:9300 – nounou Jan 29 '16 at 11:34
0

I have tried to recreate your configuration on my environment and managed to work with Elasticsearch (created an index). Here is how it goes:

  • Configure Putty tunneling for Elasticsearch 9300 and 9200 ports
  • After configuring you'll need to open the SSH connection and make sure it is connected
  • You may look at the SSH event log here is a link on how to do it

enter image description here The code looks like this

public class App 
{
    public static void main( String[] args ) throws Exception
    {
        Settings settings = ImmutableSettings.settingsBuilder().
                                              put("cluster.name", "my-cluster").build();
        TransportClient client = new TransportClient(settings)
                                    .addTransportAddress(
                                            new InetSocketTransportAddress(
                                                    "localhost", 9093));
        CreateIndexResponse rs = client.admin().indices().create(new CreateIndexRequest("tunnelingindex")).actionGet();
        System.out.println(rs.isAcknowledged());
        client.close();
    }
}

The code creates an index named tunnelingindex If it still do not work for you, I think that you may have an issue which is not related to tunneling or Elasticsearch.

Hope I have managed to help.

Eyal.Dahari
  • 760
  • 6
  • 13
  • thank you for your reply, I think that the tunnel and firewell not allow me to do that, I'll copy the jar to the server and I will execute in the server – nounou Feb 01 '16 at 09:07
0

you must set:

transport.publish_host: localhost

details here: Elasticsearch basic client connection

davey
  • 1,666
  • 17
  • 24