有最小主节点的公式
(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 }
谢谢 高拉夫辛格
你配置了minimum_master_nodes(discovery.zen.minimum_master_nodes)为2,但第二个节点有
node.master:false
要么将第二个节点更改为master:true,要么将minimum_master_nodes减少为1