B i M A P

Elasticsearch|ES Cluster require at least 2 nodes

elasticsearch logo


ES Cluster at least 2 nodes

通常 es cluster 為奇數節點,有時後可能做 rolling upgrade,導致變為偶數節點,這兩種狀況都屬合理,但今日在客戶端遇到 es 出現這個錯誤,原因是客戶將 es node 關機剩至一台。

master not discovered or elected yet, an election requires at least 2 nodes


Disable master voting policy

有時後可能遇到某些狀況,需要臨時停機,如果希望 ES 持續運作,則至少需要保持 1 台。

在關機前,將兩台要關機的 node 移除投票權。

POST /_cluster/voting_config_exclusions?node_names="node1,node2"
or
curl -X POST "localhost:9200/_cluster/voting_config_exclusions?node_names=node1,node2&pretty"


Enable voting policy

在關機後,將剛剛 disable 的設定移除,待之後開機後,可以正常讓三台 node 進行投票。

DELETE /_cluster/voting_config_exclusions
or
curl -X DELETE "localhost:9200/_cluster/voting_config_exclusions?pretty"


Unexpectedly server shutdown

如果有時後真的遇到多台 Server 無預期的關機,如果短時間無法復原的話,假如運氣好,至少還有一台 ES 是活著可用的狀況,可暫時將其改為 single 模式。

$ vim /etc/elasticsearch/elasticsearch.yml 
discovery.type: single-node
systemctl restart elasticsearch



聯絡我們快速上手



延伸閱讀
winstonlu的大頭照
ELK 達人

我們致力於 ELK 的各種應用,協助企業建置相關服務。我們也提供基於 ELK 的各種解決方案,有任何問題,歡迎加入我們的官方 Line,或來信詢問,期待與您面對面的機會。