当前位置: 首页 > 面试题库 >

Elasticsearch服务器发现配置

蒯坚白
2023-03-14
问题内容

我已经安装了运行的ElasticSearch服务器:

$ ./elasticsearch -f
 {0.18.2}[11698]: initializing ...
 loaded [], sites []
 {0.18.2}[11698]: initialized
 {0.18.2}[11698]: starting ...
 bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.1.106:9300]}
 new_master [Stingray][ocw4qPdmSfWuD9pUxHoN1Q][inet[/192.168.1.106:9300]], reason: zen-disco-join (elected_as_master)
 elasticsearch/ocw4qPdmSfWuD9pUxHoN1Q
 recovered [0] indices into cluster_state
 bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.1.106:9200]}
 {0.18.2}[11698]: started

如何配置Java客户端以连接到该服务器?我刚刚:

node.client=true

但是,尝试连接后,我收到了:

org.elasticsearch.discovery.MasterNotDiscoveredException: 
    at org.elasticsearch.action.support.master.TransportMasterNodeOperationAction$3.onTimeout(TransportMasterNodeOperationAction.java:162)

如果我将Java客户端配置为:

node.data=false

我收到以下日志:

INFO main node:internalInfo:93 - [Stark, Tony] {0.18.2}[13008]: starting ...
INFO main transport:internalInfo:93 - [Stark, Tony] bound_address {inet[/0:0:0:0:0:0:0:0:9301]}, publish_address {inet[/192.168.1.106:9301]}
INFO elasticsearch[Stark, Tony]clusterService#updateTask-pool-13-thread-1 service:internalInfo:93 - [Stark, Tony] new_master [Stark, Tony][WkNn96hgTkWXRnsR0EOZjA][inet[/192.168.1.106:9301]]{data=false}, reason: zen-disco-join (elected_as_master)

据我了解,这意味着这个新节点(应该是客户端节点)使自己成为新的主节点。而且我不会从日志中找到它并连接到任何其他节点。

服务器和客户端都在同一台计算机上启动。192.168.1.106:9200可从浏览器访问。

而且我找不到关于发现配置的任何好的文档。在哪里可以阅读有关ElasticSearch配置的更多信息?以及如何配置Java客户端?


问题答案:

面对相同的问题,即节点无法在节点重新启动时选举主节点。

问题在于节点之间的通信。

请确保在elasticsearch日志中,节点重启是否显示

  publish_address {127.0.0.1:9200}
  or
  publish_address {0.0.0.1:9200}

这意味着当前节点未将其IP地址发布给其他节点,因此即使该节点IP可能存在于 Discovery.zen.ping.unicast.hosts中,*
这些节点也无法识别该节点。
*

解决方案 在elasticsearch.yml中进行以下更改。加

 network.host: _non_loopback:ipv4_
 and restart the node.
 Ensure that the bound address now shows the <IP address>:<port no> and not the localhost.

这意味着现在您的节点是可发现的。使它在群集中可发现的第二步是将节点的ip地址添加到所有主节点的单播主机列表中,以便每当我们有一个新的主节点时,新的主节点就可以发现该节点。

   Add the node IP to the discovery.zen.ping.unicast.hosts 
   list of hosts of all the masters to make it disoverable. A masterpings all the 
   nodes present in the unicast list.


 类似资料:
  • 如何包含Eureka服务器 要在项目中包含Eureka服务器,请使用组org.springframework.cloud和工件id spring-cloud-starter-eureka-server的启动器。有关 使用当前的Spring Cloud发布列表设置构建系统的详细信息,请参阅Spring Cloud项目页面。 如何运行Eureka服务器 示例eureka服务器; @SpringBoot

  • 本文向大家介绍PHP开发Apache服务器配置,包括了PHP开发Apache服务器配置的使用技巧和注意事项,需要的朋友参考一下 照此配置流程,绝对一路畅通,可保无虞。 昨天弄了个PHP小程序,想在本地跑一下测试,可是工作电脑没有安装环境,于是下载了一个wamp,一路畅通,Apache、Mysql、PHP就全有了。启动wamp服务,在浏览器里输入“http://localhost”,访问正常,跳出w

  • 我刚刚开始通过Spring Cloud了解微服务,首先我尝试从本文中重现基本示例https://spring.io/blog/2015/07/14/microservices-with-spring.这是我的代码: 尤里卡服务器 资源/registration-server.yml: 示例服务: 帐户-服务. yml: 你能打电话给我,请问我做错了什么吗? 编辑

  • 我们来看看如何配置服务器端的 SSH 访问。 本例中,我们将使用 authorized_keys 方法来对用户进行认证。 同时我们假设你使用的操作系统是标准的 Linux 发行版,比如 Ubuntu。 首先,创建一个操作系统用户 git,并为其建立一个 .ssh 目录。 $ sudo adduser git $ su git $ cd $ mkdir .ssh && chmod 700 .ssh

  • 服务器配置 当你需要一台服务器的时候,首先需要向你的leader 提出申请,你的 leader 会利用公司的阿里云账户购买服务器实例,并且会把服务器的公网IP以及账号密码发送给你。 以下章节就叙述了当拿到一台全新的阿里云服务器实例时,我们需要怎样的工具以及我们需要经历哪些步骤对服务器进行配置。

  • 服务发现服务[架构概述]。 { "cluster": "{...}", "refresh_delay_ms": "{...}" } cluster (required, object) 承载服务发现服务的上游群集的标准定义。该群集必须实现和运行SDS HTTP API的REST服务。 refresh_delay_ms (required, integer) 每次访问SDS群集的API延迟