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集群已经成功启动

华丽的分割线

posted @ 2021-09-05 21:50  夜色微光  阅读(7070)  评论(0)    收藏  举报