Elasticsearch启动报错:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.9.jar:6.8.9]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.9.jar:6.8.9]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.9.jar:6.8.9]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.9.jar:6.8.9]
... 6 more
解决方法有两类:
1、修改elaticsearch配置,使其可以允许root用户启动(不建议)
#在执行elasticSearch时加上参数-Des.insecure.allow.root=true,完整命令如下
./elasticsearch -Des.insecure.allow.root=true
#或者 用vi打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加以下命令
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
2、为elaticsearch创建用户并赋予相应权限
命令如下 具体介绍参考我的另一篇博客linux创建新用户并将为其赋予权限文章来源:https://www.toymoban.com/news/detail-530176.html
adduser es
passwd es
chown -R es:es elasticsearch-6.8.9/
chmod 770 elasticsearch-6.8.9/
这个意思是ES不能使用root用户启动,只能通过建立其它用户来启动,可以建立一个es用户来启动:文章来源地址https://www.toymoban.com/news/detail-530176.html
useradd es
su es
切换回来后再启动es即可
到了这里,关于Elasticsearch启动报错:java.lang.RuntimeException: can not run elasticsearch as root的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!