将节点添加到运行中的集群Elasticsearch中导致主节点未发现异常

问题

我有一个正在运行的集群,我想在其中添加一个数据节点。正在运行的群集是

    <div class="navbar navbar-default navbar-static-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>  
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="./index.html">Expandable  Menu</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
          <li>item 1</li>
          <li>item 2</li>
          <li>item 3</li>
          </ul>
        </div>
      </div>
    </div>

  </div>
</div>

,数据节点为

x.x.x.246

每个服务器都可以通过ping互相查看。 机器操作系统:CentOS7 Elasticsearch:7.61

配置:

这是x.x.x.246的elasticsearch.yml:

x.x.x.99

这是x.x.x.99的elasticsearch.yml

cluster.name: elasticsearch
node.master: true
node.name: Node_master
node.data: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: x.x.x.246
http.port: 9200
discovery.seed_hosts: ["x.x.x.99:9300"]
cluster.initial_master_nodes: ["x.x.x.246:9300"]

在计算机上测试运行的Elasticsearch

当我在每台计算机上运行cluster.name: elasticsearch node.name: Node_master node.data: true path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: x.x.x.99 http.port: 9200 discovery.seed_hosts: ["x.x.x.245:9300"] cluster.initial_master_nodes: ["x.x.x.246:9300"] 时,它运行良好。

在x.x.x.246上运行测试

systemctl start elasticsearch

show:节点数不变

curl -X GET "X.X.X.246:9200/_cluster/health?pretty"

显示:

curl -X GET "X.X.X.99:9200/_cluster/health?pretty

编辑

这是x.x.x.246的elasticsearch.yml:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "master_not_discovered_exception","reason" : null
      }
    ],"type" : "master_not_discovered_exception","reason" : null
  },"status" : 503
}

这是x.x.x.99的elasticsearch.yml

cluster.name: elasticsearch
node.name: master
node.master: true
node.data: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["x.x.x.99","x.x.x.246]
cluster.initial_master_nodes: ["x.x.x.246"]
logger.org.elasticsearch.discovery: TRACE

登录x.x.x.99:

cluster.name: elasticsearch
node.name: node
node.data: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["x.x.x.246","x.x.x.99"]
cluster.initial_master_nodes: ["x.x.x.246"]
logger.org.elasticsearch.discovery: TRACE

whyzywj 回答:将节点添加到运行中的集群Elasticsearch中导致主节点未发现异常

对于节点x.x.x.99,种子主机的输入错误。它应该如下所示:

discovery.seed_hosts: ["x.x.x.246:9300"]

discovery.seed_hosts列表用于检测主节点,因为此列表包含作为符合主条件的节点的节点的地址,并且还保存当前主节点的信息,因为它指向{节点x.x.x.245无法检测到主节点。在x.x.x.246的配置中,{1}}而不是x.x.x.99

发表评论的评论正确的配置应为:

主节点:

x.x.x.99

请注意,如果您希望上述节点仅是主节点,而不保存数据,则进行设置

cluster.name: elasticsearch
node.name: master
node.master: true
node.data: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["x.x.x.246]
cluster.initial_master_nodes: ["master"]

数据节点:

node.data: false

此外,由于节点cluster.name: elasticsearch node.name: data-node-1 node.data: true node.master: false path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: 0.0.0.0 http.port: 9200 discovery.seed_hosts: ["x.x.x.246"] 无法加入群集,因此它具有陈旧的群集状态。因此,删除x.x.x.99上的data文件夹,然后重新启动该节点。

,

之所以无法选择主节点,是因为提到了discovery.seed_hosts: ["x.x.x.245:9300"],它既不是当前主节点配置的一部分,也不是主节点配置的一部分。如this官方ES文档中所述,它用于选举主节点。

您应该详细阅读与主机选择有关的2个重要配置:

discovery.seed_hosts

initial_master_nodes

您可以通过在Discovery的行下方添加来打开elasticsearch.yml模块的DEBUG日志以更好地理解它。

logger.org.elasticsearch.discovery: DEBUG

您可以在elasticsearch.yml中进行一些修改。

  1. node.name在两个节点elasticsearch.yml中具有相同的名称。
  2. 最好只提到不带端口9200的ip。
  3. 最好提供network.host: 0.0.0.0的值,而不是两个elasticsearch.yml中的节点ip。
  4. node.data: true是默认设置,因此无需提及。

更好更简洁的版本如下所示:

主节点elasticsearch.yml

cluster.name: elasticsearch
node.name: master
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.seed_hosts: ["x.x.x.99","x.x.x.246"] -->note this
cluster.initial_master_nodes: ["x.x.x.246"] :- note this

另一个数据节点elasticsearch.yml

cluster.name: elasticsearch
node.name: data
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["x.x.x.99","x.x.x.246"] --> you need to change this and include both nodes
cluster.initial_master_nodes: ["x.x.x.246"]

验证主节点

您可以点击<your-any-node-ip>:9200/_cat/master,应返回这将是与你的名字节点的情况下当选的主节点master。有关this的更多信息。

,

我也遇到了同样的问题,当我尝试从 AWS Windows 服务器外部访问弹性搜索时,我无法访问它,之后我添加了

network.host : aws_private_ip

之后我们需要重新启动弹性服务,但它在重新启动时抛出错误,最后当添加到下面一行时,它对我有用,

cluster.initial_master_nodes: node-1
本文链接:https://www.f2er.com/2626886.html

大家都在问