解压
[root@c202pc1 opt]# tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz
创建用户名
[root@c202pc1 bin]# groupadd es
[root@c202pc1 bin]# useradd es -g es
修改用户权限
[root@c202pc1 opt]# chown -R es:es elasticsearch-7.6.1
配置环境变量
[root@c202pc1 opt]# vim /etc/profile
添加:
export ES_HOME=/opt/elasticsearch-7.6.1/
export PATH=$PATH:$ES_HOME/bin
[root@c202pc1 opt]# source /etc/profile
修改配置文件
(1) 修改elasticsearch.yml文件
# vim /opt/elasticsearch-7.6.1/config/elasticsearch.yml
(2) 修改limits.conf
# vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
(3) 修改elasticsearch
修改elasticsearch引用自带的jdk,如果不修改,则会引用系统环境变量中的jdk可能会引起报错。
(4) 修改sysctl.conf
# vim /etc/sysctl.conf
添加:vm.max_map_count=262144
[root@c202pc1 opt]# sysctl -p
启动ES
切换到es用户:# su es
启动es:$ elasticsearch
报错解决
(1) 报错-详见配置修改文件3
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_192/jre] does not meet this requirement
(2) 报错-详见修改用户权限
Exception in thread "main" java.nio.file.AccessDeniedException: /opt/elasticsearch-7.6.1/config/jvm.options
(3) 报错-详见启动ES
java.lang.RuntimeException: can not run elasticsearch as root
(4) 报错-详见配置修改文件4
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
(5) 报错-详见修改用户权限
Elasticsearch did not exit normally - check the logs at /opt/elasticsearch-7.6.1/log/elasticsearch.log
(6) 报错-详见配置修改文件1
master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster