Невозможно подключиться к удаленной эластичной настройке через транспортный клиент - PullRequest
0 голосов
/ 14 февраля 2019

Я работаю над ElasticSearch версии 6.6.0, Single Node Cluster, работающей на удаленной виртуальной машине.Я хотел подключить Java Transport Client к удаленному ES, используя порт tcp 9300. Мне удалось открыть порт tcp, чтобы он был доступен с моей машины (протестировано с использованием telnet для портов 9200 и 9300).Также могу получить Elastic Details для http://:9200/.

Я не могу разгадать эту загадку того, почему транспортный клиент не может подключиться к кластеру для индексации / запросов.

asticsearch.yml выглядит следующим образом:

cluster.name: test-elastic-surabhi
node.name: ${HOSTNAME}

network.host: ${HOSTNAME}

action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*

http://public_ip:9200 приводит к:

{
  "name" : "test-elastic-surabhi-1",
  "cluster_name" : "test-elastic-surabhi",
  "cluster_uuid" : "c-w5p531Szqsv_up3OS_Uw",
  "version" : {
    "number" : "6.6.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a9861f4",
    "build_date" : "2019-01-24T11:27:09.439740Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

telnet на 9300 и 9200 с моей локальной машины также работает.

pom.xml указывает на правильную версию ES:

     <dependency>
    <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.6.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>6.6.0</version>
        </dependency>

Вот код для подключения к TCP из транспортного клиента:

Settings settings = Settings.builder().put("cluster.name", DataStoreSettings.ES_CLUSTER_NAME)
        .put("client.transport.sniff", true).build();
esTransportClient = new PreBuiltTransportClient(settings);
for (String eachHostPort : DataStoreSettings.ES_HOST) {
        LOGGER.info("adding [{}] to TransportClient ... ", eachHostPort);
        String[] hostPortTokens = eachHostPort.split(":");
        if (hostPortTokens.length < 2)
          throw new Exception(
              "ERROR: bad ElasticSearch host:port configuration - wrong format: " + eachHostPort);
        int port = 9300; // default ES port
        try {
          port = Integer.parseInt(hostPortTokens[1].trim());
        } catch (Exception e) {
          LOGGER.error("ERROR parsing port from the ES config [{}]- using default port 9300",
              eachHostPort);
        }
        esTransportClient.addTransportAddress(
            new TransportAddress(InetAddress.getByName(hostPortTokens[0].trim()), port));
      }

Но из используемого транспортного клиентав моем коде Java я вижу исключения

2019-02-14 22:31:23,599 TRACE [TransportLogger]: an exception occurred formatting a WRITE trace message
java.io.EOFException: tried to read: 105 bytes but only 27 remaining
        at org.elasticsearch.common.bytes.BytesReferenceStreamInput.ensureCanReadBytes(BytesReferenceStreamInput.java:121) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper.ensureCanReadBytes(BytesReference.java:283) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.common.io.stream.StreamInput.readArraySize(StreamInput.java:1026) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.common.io.stream.StreamInput.readString(StreamInput.java:374) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.common.io.stream.StreamInput.readStringArray(StreamInput.java:469) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TransportLogger.format(TransportLogger.java:101) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TransportLogger.logOutboundMessage(TransportLogger.java:55) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport.internalSendMessage(TcpTransport.java:758) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:744) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport.lambda$new$0(TcpTransport.java:174) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TransportHandshaker.sendHandshake(TransportHandshaker.java:74) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport.executeHandshake(TcpTransport.java:1312) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onResponse(TcpTransport.java:1533) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onResponse(TcpTransport.java:1510) ~[elasticsearch-6.6.0.jar:6.6.0]

Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: <private_ip>/<private_ip>:9300

2019-02-14 22:31:54,590 DEBUG [TransportClientNodesService]: failed to connect to discovered node [{test-elastic-surabhi-1}{F_we0jg4Q7uoQ3uOaDvv-w}{kfqF3aRcQ7mWAxhXv9R_uQ}{<private_ip>}{<private_ip>:9300}{ml.machine_memory=7673036800, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}]
org.elasticsearch.transport.ConnectTransportException: [test-elastic-surabhi-1][<private_ip>:9300] connect_timeout[30s]
        at org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onTimeout(TcpTransport.java:1576) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:660) ~[elasticsearch-6.6.0.jar:6.6.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_191]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_191]
        at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_191]
2019-02-14 22:57:38,609 ERROR [Processor]: postBulkToEs: NoNodeAvailableException. ex: {}
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{Cn4_xs_OQdeo3-2l5UgAGQ}{test-elastic-surabhi-1}{<public_ip>:9300}]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:351) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:249) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:388) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:391) ~[elasticsearch-6.6.0.jar:6.6.0]
        at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46) ~[elasticsearch-6.6.0.jar:6.6.0]
        at com.shieldsquare.nozzle.Processor.postBulkToEs(Processor.java:152) [classes/:?]

Также журналы распечаток удаленного эластичного кластера с одним узлом:

publish_address {<private_ip>:9300}, bound_addresses {<private_ip>:9300}

...