前言
参考文档:
- Elasticsearch 7.1.1 集群 + 配置身份验证(linux):https://www.cnblogs.com/wmht/p/11045025.html
- windows ElasticSearch 7.6.0集群搭建:https://blog.csdn.net/csdn565973850/article/details/104772551/
- ElasticSearch7.1.1集群搭建:https://blog.csdn.net/qq_27512271/article/details/98740135
状况描述
本地的3台es都启动了,但是head通过ip+端口
连接的时候,链接哪台,下面就显示哪台。
通过cerebro
连接也是一样的。
下面是我的配置(错误配置示例)
#集群名称,三台集群,要配置相同的集群名称!!!
cluster.name: my-application
#节点名称
node.name: node-3 #是不是有资格主节点
node.master: true
#是否存储数据
node.data: true
#最⼤集群节点数
node.max_local_storage_nodes: 3 #⽹关地址
# 监听地址,用于访问该es
network.host: localhost
#端⼝
http.port: 9202
#内部节点之间沟通端⼝
transport.tcp.port: 9302
#es7.x 之后新增的配置,写⼊候选主节点的设备地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["localhost:9300", "localhost:9301", "localhost:9302"]
#es7.x 之后新增的配置,初始化⼀个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-1", "node-2","node-3"] #数据和存储路径
path.data: D:\\Elasticsearch\\es-cluster\\elasticsearch-7.8.1_node3\\data
path.logs: D:\\Elasticsearch\\es-cluster\\elasticsearch-7.8.1_node3\\logs
# 是否支持跨域,是:true,在使用head插件时需要此配置
http.cors.enabled: true
# “*” 表示支持所有域名
http.cors.allow-origin: "*"
action.destructive_requires_name: true
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
xpack.security.enabled: false
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
xpack.ml.enabled: false
配置里面,ip这块改了又改,始终没有成功。
解决思路
因为在搞es集群前,在window本地做了zookeeper集群,所以data和logs文件地址的路径,还是参照那个来写的。
今天上午又查了几篇文章,看到里面的地址都是/opt/xxxxxx 。注意:关键点,右斜杠…
实在没办法,就尝试把地址也改成这个。改后的配置:
#集群名称,三台集群,要配置相同的集群名称!!!
cluster.name: my-application
#节点名称
node.name: node-3 #是不是有资格主节点
node.master: true
#是否存储数据
node.data: true
#最⼤集群节点数
node.max_local_storage_nodes: 3 #⽹关地址
# 监听地址,用于访问该es
network.host: localhost
#端⼝
http.port: 9202
#内部节点之间沟通端⼝
transport.tcp.port: 9302
#es7.x 之后新增的配置,写⼊候选主节点的设备地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["localhost:9300", "localhost:9301", "localhost:9302"]
#es7.x 之后新增的配置,初始化⼀个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-1", "node-2","node-3"] #数据和存储路径
path.data: /opt/elasticsearch/data
path.logs: /opt/elasticsearch/logs
# 是否支持跨域,是:true,在使用head插件时需要此配置
http.cors.enabled: true
# “*” 表示支持所有域名
http.cors.allow-origin: "*"
action.destructive_requires_name: true
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
xpack.security.enabled: false
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
xpack.ml.enabled: false
启动成功页面
刷新了下cerebro
,下面直接显示了三台:
刷新head
总结
除了常规配置,关键点:data和logs的路径配置。这个如果配置错了,启动的时候是没有错误提示的