Elasticsearch master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster


Photo by Sindre Strøm from Pexels

之前學習ElasticSearch集群操作的時候都是啟動多個虛擬機,不過那樣內存消耗高,也比較麻煩,所以現在在Windows上直接啟動多節點。當希望在單機器上啟動多個ElasticSearch節點組成集群時,例如有如下配置:

node1: 192.168.31.162:9200
node2: 192.168.31.162:9201
node3: 192.168.31.162:9202

默認配置會出現這種問題:node1作為指定的master節點可以正常啟動,

但是node2、3等更多從節點無法發現master節點,一直在警告 master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster。。

這是因為上面的9200 - 9202端口只是設置的ElasticSearch的Http端口,默認的集群選舉端口是9300 - 9305,也需要手動設置,所以解決這個問題在節點各自的配置文件里加上類似下面配置就可以了:

#node1 elasticsearch.yml
transport.profiles.default.port: 9300

#node2 elasticsearch.yml
transport.profiles.default.port: 9301

#node3 elasticsearch.yml
transport.profiles.default.port: 9302

詳細解釋見ElasticSearch文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-hosts-providers.html#built-in-hosts-providers

基礎參考配置:


cluster.name: elastic-cluster1
node.name: node-1
network.host: 192.168.31.162
http.port: 9200
transport.profiles.default.port: 9300
discovery.seed_hosts: ["192.168.31.162:9300", "192.168.31.162:9301", "192.168.31.162:9302"]
cluster.initial_master_nodes: ["node-1"]

現在,我們可以通過http請求來查看ElasticSearch集群已經成功啟動

華麗的分割線


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM