一、环境
笔者所用环境为自用所搭建的3台虚拟机,配置为1C4G/台
二、安装步骤
1.下载es安装包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.1-linux-x86_64.tar.gz.sha512
#校验下载安装包,没问题输出为:elasticsearch-{version}-linux-x86_64.tar.gz: OK
shasum -a 512 -c elasticsearch-7.2.1-linux-x86_64.tar.gz.sha512
也可以预先下载:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-2-1
2.解压
tar -zxvf elasticsearch-7.2.1-linux-x86_64.tar.gz -C /指定目录下
3.配置修改
在es安装包目录下找到config目录下的elasticsearch.yml文件
vim .../elasticsearch-7.2.1/config/elasticsearch.yml
master配置:
cluster.name: my-application #同一集群下的节点配置文件集群名需一致
node.master: true #此节点是否为master节点
node.data: true #此节点是否存储数据
node.name: node-102 #此节点名
path.data: .../elasticsearch-7.2.1/data #在es安装目录下创建一个data文件夹
path.logs: .../elasticsearch-7.2.1/logs #指定存储在es安装目录下logs文件夹
bootstrap.memory_lock: false
bootstrap.system_call_filter: falsenetwork.host: 192.168.1.102 #见/etc/hosts
http.port: 9200
#允许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"#配置master节点
cluster.initial_master_nodes: ["192.168.1.102"]
剩余worker节点配置,下面列出修改部分:
node.master: false
node.name: node-103 #同一集群中各节点不同名即可network.host: 192.168.1.103 #改成对应worker节点,见/etc/hosts
4.在集群各节点启动es
.../elasticsearch-7.2.1/bin/elasticsearch
5.通过命令测试一下
curl http://192.168.1.102:9200
返回结果类似如下即可: