【问题标题】:Problem setup cluster elasticsearch, alway return 1 node, what's wrong config?问题设置集群elasticsearch,总是返回1个节点,配置有什么问题?
【发布时间】:2020-02-10 11:02:42
【问题描述】:

我有 3 台带 ips 的服务器:

server-1: xxx.xxx.xxx.102

serverr-2: xxx.xxx.xxx.251

server-3: xxx.xxx.xxx.34

Elasticsearch 已安装在所有服务器上。 并为所有人添加防火墙规则:

firewall-cmd --permanent --add-port=9200/tcp
firewall-cmd --permanent --add-port=9300/tcp
firewall-cmd --reload

服务器上的弹性配置:

服务器 1:

cluster.name: cluster-mode
node.name: node1
node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["xxx.xxx.xxx.34", "xxx.xxx.xxx.251", "xxx.xxx.xxx.102"]
discovery.zen.minimum_master_nodes: 2

服务器 2:

cluster.name: cluster-mode
node.name: node2
node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["xxx.xxx.xxx.34", "xxx.xxx.xxx.251", "xxx.xxx.xxx.102"]
discovery.zen.minimum_master_nodes: 2

服务器 3:

cluster.name: cluster-mode
node.name: node3
node.master: true
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["xxx.xxx.xxx.34", "xxx.xxx.xxx.251", "xxx.xxx.xxx.102"]
discovery.zen.minimum_master_nodes: 2

我已在所有服务器上重新启动弹性并检查集群运行状况

curl -XGET http://xxx.xxx.xxx.102:9200/_cluster/health?pretty

但总是返回 1 个节点

{
  "cluster_name" : "cluster-mode",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 0,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}

我在哪里配置错了? 需要帮忙。 谢谢!

【问题讨论】:

  • 您运行的是哪个版本的 Elasticsearch?
  • 节点无法发现彼此,因此无法构建集群。请检查并分享节点的相关日志,这些日志表明他们找不到对等节点的原因。
  • 你所有的服务器都在不同的网络中,机器可以互相通信吗?另外,您运行的是哪个版本?一些配置在上一个版本中发生了变化。
  • 感谢cmets,我用的是elasticsearch 7.5版(当前是最新版)

标签: elasticsearch


【解决方案1】:

Elasticsearch 现在使用一种名为cluster bootstrapping 的方法来形成集群。为了在第一次启动集群时发生这种情况,您必须提供一组初始主节点,这些节点将用于集群,并提供作为主合格节点的种子主机列表,它们的投票决定主选举。

因此替换以下内容:

discovery.zen.ping.unicast.hosts: ["xxx.xxx.xxx.34", "xxx.xxx.xxx.251", "xxx.xxx.xxx.102"]
discovery.zen.minimum_master_nodes: 2

通过以下属性:

cluster.initial_master_nodes: ["node1", "node2", "node3"]
discovery.seed_hosts: ["xxx.xxx.xxx.34", "xxx.xxx.xxx.251", "xxx.xxx.xxx.102"]

【讨论】:

  • 感谢@Opster ES Ninja Nishant,我已更改配置,但仍返回 1 个节点。 curl -XGET 127.0.0.1:9200/_cluster/health?pretty { “cluster_name”:“cluster-mode”,“status”:“green”,“timed_out”:false,“number_of_nodes”:1,“number_of_data_nodes”:1,“active_primary_shards”:0,“ active_shards”:0,“relocating_shards”:0,“initializing_shards”:0,“unassigned_shards”:0,“delayed_unassigned_shards”:0,“number_of_pending_tasks”:0,“number_of_in_flight_fetch”:0,
  • @quyet 如果没有生产数据索引,则从节点中删除 data 文件夹,然后重新启动节点。
  • 感谢@Opster ES Ninja Nishant,清除所有使用新配置集群引导的数据。
猜你喜欢
  • 1970-01-01
  • 2020-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-08
  • 1970-01-01
相关资源
最近更新 更多