一、官网下载
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-8-0
二、环境要求
jdk环境:至少jdk11
三、软件安装
1.软件上传
2.解压
tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz
3.创建用户
因为安全问题,Elasticsearch 不允许 root 用户直接运行,所以要创建新用户,在 root 用户中创建新用户
useradd es
passwd es
# 文件夹所有者
chown -R es:es /opt/elasticsearch/elasticsearch-7.8.0
4.修改配置文件
1)elasticsearch.yml
添加文件结尾添加以下内容
cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
2)limits.conf
vim /etc/security/limits.conf
# 在文件末尾中增加下面内容
# 每个进程可以打开的文件数的限制
es soft n ofile 65536
es hard nofile 65536
3)20-nproc.conf
vim /etc/security/limits.d/20-nproc.conf
# 在文件末尾中增加下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
4) sysctl.conf
vim /etc/sysctl.conf
# 在文件中增加下面内容
# 一个进程可以拥有的 VMA(虚拟内存区域)的数量 默认值为 65536
vm.max_map_count=655360
重新加载
sysctl -p
四、软件启动
1)用户切换
su es
2)启动
#启动
bin/elasticsearch
#后台启动
bin/elasticsearch d
可能会报以下错误,没有请忽略
报错含义:[1]:用户[es]的最大线程数[3818]太低,至少增加到[4096]
解决方案:
#root用户下运行
ulimit -u 4096