使用root启动elasticmate的时候会出现:
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
这时你可以创建一个新的用户来启动:
$ adduser test
$ passwd 123456
Changing password for user test.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
在root用户下为test用户增加权限:chown -R test /opt/app/elasticsearch-2.3.3/
切换到test用户:su test
启动elasticmate: ./bin/elasticsearch
抛了一个异常:
Exception in thread "main" java.lang.IllegalStateException: Failed to created node environment
Likely root cause: java.nio.file.AccessDeniedException: /data/elasticsearch/gzrs/nodes/1
原因是,在elasticsearch.yml配置文件中path.data是配置在/data/elasticsearch目录下的,没有给test用户分配这个目录的权限。
退出test用户:exit
在root用户下为/data/elasticsearch目录授权:chown -R test /data/elasticsearch
再使用test用户启动即可。