如何在 elasticsearch 中的一个集群中配置两个节点?

How can a configure two nodes in one cluster in elasticsearch?

我有这样一种情况,我在远程服务器 1 (node1) 和远程服务器 2 (node2) 中安装了两个 Elasticsearch 设置实例,我想将这两个节点连接到一个集群中,但是我还安装了kibana 在一台服务器上,当我 运行 GET _cluster/health 我得到

{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 1,
"active_shards" : 1,
"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
}

能否请您帮忙提供 node1 和 node2 的配置示例,以及如何确认两个节点都添加到一个集群中。

下面是我在服务器 1elasticsearch.yml 中的文件

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: true
node.max_local_storage_nodes: 2
node.name: Server1
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server1

服务器 2:elasticsearch.yml 文件 -

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: false
node.max_local_storage_nodes: 1
node.name: Server2
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server2

谢谢 高拉夫·辛格

您配置了 minimum_master_nodes (discovery.zen.minimum_master_nodes) of 2,但是第二个节点有

node.master: false

将第二个节点更改为 master:true 或将 minimum_master_nodes 减少为 1

有最小主节点的公式

(total number of master-eligible nodes / 2 + 1)

所以一个集群中的2个节点是一个主节点,一个是从节点

As of formula (2 / 2+1) = 0.6666 ~ 1

discovery.zen.minimum_master_nodes: 1

为了帮助别人让我把两个节点的配置都放上去

主节点配置:

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: true
node.max_local_storage_nodes: 2
node.name: Server1
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server1

从节点配置:

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: false
node.max_local_storage_nodes: 1
node.name: Server2
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server2

执行此操作后,您将得到如下响应:

{
  "cluster_name": "elasticsearch",
  "status": "green",
  "timed_out": false,
  "number_of_nodes": 2,
  "number_of_data_nodes": 2,
  "active_primary_shards": 1,
  "active_shards": 2,
  "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
}

谢谢
高拉夫·辛格