基于ES7.4.1编写,其实一开始用的最新的8.1,但是问题太多了!!!!不稳定,降到7.4
下载好的安装包上传到服务器或虚拟机,创建ES目录,命令mkdir -p /路径xxxx

复制安装包到指定路径并解压:
tar zxvf elasticsearch-8.1.0-linux-x86_64.tar.gz -C /usr/local/es/


进入bin目录安装,命令./elasticsearch即可

为防止出现安全隐患,不允许root用户直接操作,提示信息如下:

创建用户组,设置es操作用户:groupadd es,向ES用户组添加用户es:useradd es -g es

root权限变更为es权限 : chown -Rf es:es /home/local/es/

切换用户为es:su es,执行启动命令:./elasticsearch
出现错误
看这个错误意思是需要连接一个叫GeoLite2-ASN.mmdb的数据库,连接超时了。因为我本地并没有这个数据库,那么什么是GeoLite2-ASN.mmdb?
GeoLite2/GeoIP全球ASN-IP离线定位库,官网地址:https://dev.maxmind.com/geoip/geolocate-an-ip?lang=en
我们现在并不需要这个库,但是elasticsearch启动却需要连接这个库,所以我们需要将这个连接的配置关闭,让启动的时候不去连接这个库。

修改配置文件,
java
vim config/elasticsearch.yml
添加配置
java
ingest.geoip.downloader.enabled: false
再次启动,出现下面提示为完成:

通过curl命令查看:curl http://127.0.0.1:9200

现在只能本机访问,远程访问需要调整以下内容为0.0.0.0

再次启动报错:

问题1原因是虚拟内存数不足,修改这个文件

在最下面添加:
#增加es虚拟内存
vm.max_map_count = 262144

设置完成后刷新内存,不然不生效:sysctl -p

问题2,发现配置,回到config,修改elasticsearch.yml
java
discovery.seed_hosts: ["你的ip"]
cluster.initial_master_nodes: ["你的ip"]
注意:流程应该用root用户修改内容,然后chown命令重新给予es用户权限,我这里用es用户修改的配置文件,如果出现问题,直接用root用户再次赋予权限即可
返回重新启动,启动成功

还是再开一个窗口,有那个curl命令查看服务运行情况

这个时候就可以浏览器其他IP访问了,地址栏输入地址+ip

注意7.4或者说大版本7有一个警告

默认启动内存一个G,如果配置不够,可以调整内存,调整后弊端就是启动慢一点,其他没啥影响,这个警告也可以忽略,修改方式:
关闭es,去config里面找到jvm.options,修改图中位置调整即可,我这够,就不修改了

上一个警告,出现GC过时可以按照下图改为G1GC,也可以不改
