Elasticsearch 7.6集群搭建(基于Centos7.4)

1、下载安装包elasticsearch-oss-7.6.2-linux-x86_64.tar.gz到hadoop1
elasticsearch-oss-7.6.2-linux-x86_64.tar.gz

2、远程传输到hadoop2、hadoop3节点

scp -r elasticsearch-oss-7.6.2-linux-x86_64.tar.gz :`pwd`
scp -r elasticsearch-oss-7.6.2-linux-x86_64.tar.gz :`pwd`

Elasticsearch 7.6集群搭建(基于Centos7.4)

3、解压

tar -zxvf elasticsearch-oss-7.6.2-linux-x86_64.tar.gz

2、编辑配置文件(/usr/local/softwareinstall/elasticsearch-7.6.2/config目录下的elasticsearch.yml、jvm.options配置文件)
(1)elasticsearch.yml

cluster.name: xuhongming
node.name: node-hadoop1
path.data: /data/es/data
path.logs: /data/es/logs
bootstrap.memory_lock: true
network.host: hadoop1
http.port: 9200
discovery.seed_hosts: ["hadoop1", "hadoop2","hadoop3"]
cluster.initial_master_nodes: ["node-hadoop1", "node-hadoop2","node-hadoop3"]

(2)jvm.options

-Xms512m
-Xmx512m

主要设定 -Xms、-Xmx,最大不超过物理内存的一半

(3)修改linux系统配置
1》修改linux系统内核参数

vim /etc/security/limits.conf
#锁定内存
* soft memlock unlimited
* hard memlock unlimited
#设定用户最大可创建文件数
* soft nofile 65536
* hard nofile 131072

Elasticsearch 7.6集群搭建(基于Centos7.4)

2》修改linux虚拟内存空间及swap使用率

vim /etc/sysctl.conf     #编辑sysctl.conf,添加如下配置
vm.max_map_count=655360
vm.swappiness=1

Elasticsearch 7.6集群搭建(基于Centos7.4)

3》修改本地线程数

vim /etc/security/limits.d/90-nproc.conf

Elasticsearch 7.6集群搭建(基于Centos7.4)

Elasticsearch 7.6集群搭建(基于Centos7.4)

4、创建一个普通用户,并赋予root权限(root用户不能启动es,否则出现异常)
(1)创建用户,并修改密码

adduser es     #创建普通用户
passwd es      #修改es用户密码(需连续输入2次)  此处未设置密码

(2)赋予es普通用户root权限
vim /etc/sudoers #编辑sudoers, 添加如下配置(es ALL=(ALL) NOPASSWD: ALL)
Elasticsearch 7.6集群搭建(基于Centos7.4)

5、赋予es用户es安装目录的文件权限

su - es      #由root用户切换到es用户
cd /usr/local/softwareinstall   #进入softwareinstall文件夹
sudo chown -R es:es elasticsearch-7.6.2   #赋予es用户安装文件elasticsearch-7.6.2的权限

5、启动es(必须切换到es用户,启动,否则出现异常)

cd /usr/local/softwareinstall/elasticsearch-7.6.2
bin/elasticsearch

6、ui界面查看验证
(1)单节点

hadoop1:9200

Elasticsearch 7.6集群搭建(基于Centos7.4)

(2)集群健康状态查看

http://hadoop1:9200/_cluster/health?pretty=true

Elasticsearch 7.6集群搭建(基于Centos7.4)

参考
(1)官网文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.htm
(2)【Elasticsearch7.0】之重要配置
http://www.chaiguanxin.com/articles/2019/06/04/1559609661710.html