自从使用ES以后,每天都能遇到新的报错,今天又是处理异常的一天

Kibana无法启动,报错:找不到主节点:

1
master_not_discovered_exception

并且使用ElasticSearch查询索引时也报错,找不到主节点:

1
{"error":{"root_cause":[{"type":"master_not_discovered_exception","reason":null}],"type":"master_not_discovered_exception","reason":null},"status":503}

图片
并且elasticsearch-head显示: 集群健康值:未连接

elasticsearch-head显示: 集群健康值:未连接时,还有可能是未配置ElasticSearch可视化需要的一些配置:

1
2
3
4
5
# es可视化
http.cors.allow-origin: '*'
http.cors.enabled: true
http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true

图片

原因:创建多集群时,未配置主节点,
在ElasticSearch配置文件中,指定主节点信息即可,
配置信息如下:

1
2
3
4
5
6
7
8
9
10
11
cluster.name: elasticsearch # 集群名称,需保持一致
node.name: ahzoo-1 # 节点名称(自定义)
# 指定了该节点可能成为 master 节点,还可以是数据节点
node.master: true
node.data: true
network.host: 192.168.6.125 # 当前节点的IP地址
http.port: 9200 # 对外提供服务的端口
transport.tcp.port: 9300 #9300为集群服务的端口
discovery.zen.ping.unicast.hosts: ["192.168.6.125","192.168.6.155"] # 集群个节点IP地址,也可以使用域名,需要各节点能够解析

cluster.initial_master_nodes: ahzoo-1 # 指定主节点

然后重启所有服务:
图片
图片
图片
全部运行成功