一、root用户运行报错
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
解决方法:
#添加es用户
useradd es
#给es用户授权目录权限
chown es:es -R /usr/es/
# 切换到es用户运行接口
su es
# 执行即可
./elasticsearch -d
二、线程可操作的文件数错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方法
切换到root用户,编辑limits.conf配置文件, 添加类似如下内容
# 切换到root用户
su root
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
#备注:* 代表Linux所有用户名称(比如 hadoop)
#保存、退出、重新登录才可生效
三、最大虚拟内存错误
原因:最大虚拟内存太小
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法
切换到root用户下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
#添加下面配置:
vm.max_map_count=655360
#并执行命令
sysctl -p
#然后重新启动elasticsearch,即可启动成功