ES集羣的主節點發現機制採用單播形式,主要配置有三行,以下:node
discovery.zen.minimum_master_nodes: 2 discovery.zen.ping.multicast.enabled: false discovery.zen.ping.unicast.hosts: ["localhost:9001","localhost:9101","localhost:9701"]
第一行的配置說明以下:ide
# Discovery infrastructure ensures nodes can be found within a cluster # and master node is elected. Multicast discovery is the default. # Set to ensure a node sees N other master eligible nodes to be considered # operational within the cluster. This should be set to a quorum/majority of # the master-eligible nodes in the cluster. # discovery.zen.minimum_master_nodes: 2
瞭解Zookeeper的話,這個配置就比較容易理解了; 數值取值爲 (有資格當選爲Master的節點個數/2+1), 這樣作是爲了防止腦裂現象, 防止某些主節點自成一個集羣. 考慮到Zookeeper的一些配置, 主節點的個數最好是奇數個,而且很多於3個;可是會帶來一個問題,如必須至少一半以上的主節點是可用的,若是不能知足這個要求,則系統就會崩潰.spa
第二行和第三行的配置說明以下:rest
# Unicast discovery allows to explicitly control which nodes will be used # to discover the cluster. It can be used when multicast is not present, # or to restrict the cluster communication-wise. # # 1. Disable multicast discovery (enabled by default): # discovery.zen.ping.multicast.enabled: false # # 2. Configure an initial list of master nodes in the cluster # to perform discovery when new nodes (master or data) are started: # discovery.zen.ping.unicast.hosts: ["localhost:9001","localhost:9101","localhost:9701"]
1是關閉多播,採用單播;置爲falsecode
2是給出全部的Master節點的IP和Port.端口用數據交換接口便可;orm
集羣的節點打算分三種角色, master節點,僅充當master做用,不存儲數據; data節點, 僅存儲數據,不能當選爲master節點; observer節點, 既不充當master,也不存儲數據;server