Elasticsearch启动报错:java.lang.RuntimeException: can not run elasticsearch as root

Elasticsearch启动报错:java.lang.RuntimeException: can not run elasticsearch as root,第1张

Elasticsearch启动报错:java.lang.RuntimeException: can not run elasticsearch as root 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创建新用户并将为其赋予权限

adduser es

passwd es

chown -R es:es elasticsearch-6.8.9/

chmod 770 elasticsearch-6.8.9/

这个意思是ES不能使用root用户启动,只能通过建立其它用户来启动,可以建立一个es用户来启动:

useradd es
 
su es
  切换回来后再启动es即可

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5701939.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存