一尘不染

客户端和主服务器之间的Elasticsearch MasterNotDiscoveredException

elasticsearch

简而言之,我有一个独立的ES主实例和一个在我的Java应用程序中创建的客户端节点。如果在客户端节点之前启动了独立ES实例,则客户端节点会正确发现独立ES实例。

我面临的问题是-如果由于某种原因,客户端节点在独立ES实例之前启动,我会看到“
MasterNotDiscoveredException”,这也是可预期的。但是,即使启动独立的ES实例后,我仍然会看到相同的异常。我应该更改一些配置以解决此问题吗?

我将ES 1.7.1与单播发现一起使用。

编辑

群集信息: 独立的ES实例和客户端节点共同组成一个群集。

客户端节点堆栈跟踪:

11:29:35,634 INFO  http [496648366, id=7BCBFQLCTWOO2, ide=tcp://172.17.78.80:61616] [Squidboy] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/172.17.78.80:9200]}
11:29:35,635 INFO  node [496648366, id=7BCBFQLCTWOO2, ide=tcp://172.17.78.80:61616] [Squidboy] started
11:30:10,279 ERROR ApplicationLifeCycle [299961584] System startup not complete after 120 seconds ...
11:30:14,706 WARN  ElasticSearchStatus [278792216] An Exception occurred during cluster health status update - java.util.concurrent.ExecutionException: org.elasticsearch.discovery.MasterNotDiscoveredException: waited for [30s]
        at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:292)
        at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:279)
        at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:117)
        at com.harry.elastic.node.ElasticSearchStatus.updateClusterHealth(ElasticSearchStatus.java:90)
        at com.harry.elastic.node.ElasticSearchStatus.access$000(ElasticSearchStatus.java:37)
        at com.harry.elastic.node.ElasticSearchStatus$1.run(ElasticSearchStatus.java:62)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.discovery.MasterNotDiscoveredException: waited for [30s]
        at org.elasticsearch.action.support.master.TransportMasterNodeOperationAction$4.onTimeout(TransportMasterNodeOperationAction.java:164)
        at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:231)
        at org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:560)
        ... 3 more

客户端创建代码

private Node createEmbeddedClientNode() {
        ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder()
                .put("discovery.zen.ping.multicast.enabled", false)
                .put("discovery.zen.ping.unicast.hosts", "localhost[9300-9400]");
        return nodeBuilder().settings(settingsBuilder).clusterName("harryService")
                .client(true).data(false).node();
    }

主发现配置

"discovery": {
    "zen": {
      "ping": {
        "multicast": {
          "enabled": false
        }
      }
    }

阅读 995

收藏
2020-06-22

共1个答案

一尘不染

我通过在主节点中显式添加单播配置解决了该问题。

"discovery": {
    "zen": {
      "ping": {
        "multicast": {
          "enabled": false
        },
        "unicast": {
            "hosts": "localhost[9300-9400]"
        }
      }
    }
}
2020-06-22