当前位置:  开发笔记 > 编程语言 > 正文

关于localhost Java客户端错误的Elasticsearch 2.1.1:MasterNotDiscoveredException [等待[30s]]

如何解决《关于localhostJava客户端错误的Elasticsearch2.1.1:MasterNotDiscoveredException[等待[30s]]》经验,为你挑选了1个好方法。

因此,在我的localmachine上使用最新版本的elasticsearch,java客户端节点,不会收到任何关于masternode的信息.并断开连接.

即使使用默认配置,我也尝试了以下代码.它仍然不起作用.

如果我使用TransportClient一切正常.

谁知道发生了什么?

Java客户端代码

Node node = nodeBuilder()
                .clusterName("Scrapper")
                .client(true)
                .data(false)
                .local(false)
                .settings(
                    Settings.builder()
                        .put("path.home", ".")
                        .put("name", "JG")
                        .put("http.enabled", false)
                        .put("node.master", false)
                        .put("discovery.zen.ping.multicast.enabled", false)
                        .put("discovery.zen.ping.unicast.hosts", "127.0.0.1:9300")
                        .put("network.host", "127.0.0.1")
                        .put("transport.tcp.port", "9301")
                )
                .node();
Client client = node.client();

System.out.println("Firing Requests.");

String INDEX = "test_index";
boolean indexExists = client.admin().indices().prepareExists(INDEX).execute().actionGet().isExists();
if (!indexExists) {
  client.admin().indices().prepareCreate(INDEX).execute().actionGet();
}

SearchResponse allHits = client.prepareSearch(INDEX)
                             .addFields("title", "category")
                             .setQuery(QueryBuilders.matchAllQuery())
                             .execute().actionGet();

System.out.println("allHits = " + allHits);

Java客户端日志:

Jan 13, 2016 12:28:50 PM org.elasticsearch.node.Node 
INFO: [JG] version[2.1.1], pid[33792], build[40e2c53/2015-12-15T13:05:55Z]
Jan 13, 2016 12:28:50 PM org.elasticsearch.node.Node 
INFO: [JG] initializing ...
Jan 13, 2016 12:28:50 PM org.elasticsearch.plugins.PluginsService 
INFO: [JG] loaded [], sites []
Jan 13, 2016 12:28:52 PM org.elasticsearch.node.Node 
INFO: [JG] initialized
Jan 13, 2016 12:28:52 PM org.elasticsearch.node.Node start
INFO: [JG] starting ...
Jan 13, 2016 12:28:52 PM org.elasticsearch.transport.TransportService doStart
INFO: [JG] publish_address {127.0.0.1:9301}, bound_addresses {127.0.0.1:9301}
Jan 13, 2016 12:28:52 PM org.elasticsearch.discovery.DiscoveryService doStart
INFO: [JG] Scrapper/5OJu376pS7Gz4HSsZV-yFA
Firing Requests.
Jan 13, 2016 12:29:22 PM org.elasticsearch.discovery.DiscoveryService waitForInitialState
WARNING: [JG] waited for 30s and no initial state was set by the discovery
Jan 13, 2016 12:29:22 PM org.elasticsearch.node.Node start
INFO: [JG] started
Exception in thread "main" MasterNotDiscoveredException[waited for [30s]]
    at org.elasticsearch.action.support.master.TransportMasterNodeAction$4.onTimeout(TransportMasterNodeAction.java:154)
    at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:239)
    at org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:574)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Elasticsearch日志:

[2016-01-13 12:28:44,579][INFO ][node                     ] [MasterScrapper] version[2.1.1], pid[33773], build[40e2c53/2015-12-15T13:05:55Z]
[2016-01-13 12:28:44,579][INFO ][node                     ] [MasterScrapper] initializing ...
[2016-01-13 12:28:44,747][INFO ][plugins                  ] [MasterScrapper] loaded [license, marvel-agent], sites []
[2016-01-13 12:28:44,762][INFO ][env                      ] [MasterScrapper] using [1] data paths, mounts [[/ (/dev/disk0s2)]], net usable_space [302.5gb], net total_space [465.1gb], spins? [unknown], types [hfs]
[2016-01-13 12:28:46,023][INFO ][node                     ] [MasterScrapper] initialized
[2016-01-13 12:28:46,024][INFO ][node                     ] [MasterScrapper] starting ...
[2016-01-13 12:28:46,093][INFO ][transport                ] [MasterScrapper] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2016-01-13 12:28:46,099][INFO ][discovery                ] [MasterScrapper] Scrapper/NfXHsmWlTJ23bPz5CJ5D9w
[2016-01-13 12:28:49,115][INFO ][cluster.service          ] [MasterScrapper] new_master {MasterScrapper}{NfXHsmWlTJ23bPz5CJ5D9w}{127.0.0.1}{127.0.0.1:9300}{master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-01-13 12:28:49,125][INFO ][http                     ] [MasterScrapper] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
[2016-01-13 12:28:49,125][INFO ][node                     ] [MasterScrapper] started
[2016-01-13 12:28:49,316][INFO ][license.plugin.core      ] [MasterScrapper] license [414cb515-23b0-4a78-8af8-fcf060a1071f] - valid
[2016-01-13 12:28:49,317][ERROR][license.plugin.core      ] [MasterScrapper] 
#
# License will expire on [Sunday, February 07, 2016]. If you have a new license, please update it.
# Otherwise, please reach out to your support contact.
# 
# Commercial plugins operate with reduced functionality on license expiration:
# - marvel
#  - The agent will stop collecting cluster and indices metrics
[2016-01-13 12:28:49,351][INFO ][gateway                  ] [MasterScrapper] recovered [11] indices into cluster_state
[2016-01-13 12:28:55,106][INFO ][cluster.service          ] [MasterScrapper] added {{JG}{5OJu376pS7Gz4HSsZV-yFA}{127.0.0.1}{127.0.0.1:9301}{client=true, data=false, local=false, master=false},}, reason: zen-disco-join(join from node[{JG}{5OJu376pS7Gz4HSsZV-yFA}{127.0.0.1}{127.0.0.1:9301}{client=true, data=false, local=false, master=false}])
[2016-01-13 12:29:52,463][INFO ][cluster.service          ] [MasterScrapper] removed {{JG}{5OJu376pS7Gz4HSsZV-yFA}{127.0.0.1}{127.0.0.1:9301}{client=true, data=false, local=false, master=false},}, reason: zen-disco-node_failed({JG}{5OJu376pS7Gz4HSsZV-yFA}{127.0.0.1}{127.0.0.1:9301}{client=true, data=false, local=false, master=false}), reason transport disconnected

群集健康(GET _cluster/health)

{
  "cluster_name": "Scrapper",
  "status": "yellow",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "active_primary_shards": 24,
  "active_shards": 24,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 24,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 50
}

主办:

localhost (running everything on my local machine.)

Elasticsearch version 2.1.1 (downloaded ran from the official website)
Java Clientlib version org.elasticsearch - elasticsearch - 2.1.1

Installed plugins in /Users/myusername/libs/elasticsearch-2.1.1/plugins:
    - license
    - marvel-agent

config/elasticsearch.yml(精确配置)

cluster.name: "Scrapper"
node.name: "MasterScrapper"
node.master: true
node.data: true
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
network.host: "127.0.0.1"
transport.tcp.port: 9300

OS

OsX El Captain 10.11.2

java的

$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Jigar.. 5

有许多与许可插件和ES 2.0相关的问题

我通过从ES主节点删除许可插件使其工作.并且java客户端能够连接.叶!

有关详细信息,请访问:https://discuss.elastic.co/t/elasticsearch-2-1-1-on-localhost-java-client-error-masternotdiscoveredexception-waited-for-30s/39294



1> Jigar..:

有许多与许可插件和ES 2.0相关的问题

我通过从ES主节点删除许可插件使其工作.并且java客户端能够连接.叶!

有关详细信息,请访问:https://discuss.elastic.co/t/elasticsearch-2-1-1-on-localhost-java-client-error-masternotdiscoveredexception-waited-for-30s/39294

推荐阅读
郑小蒜9299_941611_G
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有