Elasticsearch集群环境搭建
晨曦 发布于 阅读:213 Elasticsearch
Es集群搭建核心思想
1.配置相同集群名称
2.配置不同的节点ID
3.修改X台服务器elasticsearch.yml配置
服务器环境->准备三台服务器集群
服务器集群配置:
修改elasticsearch.yml文件
[root@chenxi elasticsearch]# vim elasticsearch.yml
---------------------------------- Cluster -----------------------------------
#
Use a descriptive name for your cluster:
取消注释,修改节点集群名称,保证三台服务器节点集群名称相同
cluster.name: chenxi
------------------------------------ Node ------------------------------------
#
Use a descriptive name for the node:
取消注释,每个节点名称不一样,其他两台为node-2, node-3
node.name: node-1
---------------------------------- Network -----------------------------------
#
Set the bind address to a specific IP (IPv4 or IPv6):
取消注释,服务器IP地址
network.host: 192.168.0.1
--------------------------------- Discovery ----------------------------------
#
Pass an initial list of hosts to perform discovery when new node is started:
The default list of hosts is ["127.0.0.1", "[::1]"]
取消注释,多个服务器集群IP
discovery.zen.ping.unicast.hosts: ["192.168.0.1","192.168.0.2","192.168.0.3"]
#
Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
取消注释,设置最小主节点为1
discovery.zen.minimum_master_nodes: 1
关闭防火墙
注意克隆data文件会导致数据不同步
启动错误信息:
某台集群服务器报错 failed to send join request to master 时
解决办法:
清除每台服务器data文件
集群验证地址:
http://192.168.0.1:9200/_cat/nodes?pretty
如成功显示如下:
192.168.0.1 18 93 1 0.00 0.00 0.00 mdi * node-1
192.168.0.2 20 96 2 0.00 0.03 0.11 mdi - node-2
192.168.0.3 20 96 2 0.00 0.05 0.11 mdi - node-3