注:ES有执行脚本的能力,因安全因素,不能在root用户下运行,强行运行会报如下错误:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
解决办法:
新建非root用户,并切换到非root用户启动ES。
举例:
groupadd es #增加es组
useradd es -g es #增加es用户并附加到es组
passwd es #为es用户设置密码
chown -R es:es /home/es #修改目录/home/es的所有者为es,组为es。
chown -R es:es /path/to/data #修改目录/path/to/data的所有者为es,组为es。
chown -R es:es /path/to/logs #修改目录/path/to/logs的所有者为es,组为es。
su es #切换当前登录用户为es
#启动 elasticsearch(启动日志打印到控制台)
/home/es/elasticsearch-5.6.3/bin/elasticsearch
#后台启动 elasticsearch(启动日志不打印到控制台)
/home/es/elasticsearch-5.6.3/bin/elasticsearch -d
参考:
linux chown 与 chmod
http://huangqiqing123.iteye.com/blog/2254859
linux 用户和用户组
http://huangqiqing123.iteye.com/blog/2248388