java.lang.RuntimeException: can not run elasticsearch as root

忘写了一个错误:

[o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.2.jar:5.6.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.2.jar:5.6.2]
        ... 6 more

 这个错误,是因为使用root用户启动elasticsearch,elasticsearch是不允许使用root用户启动的,所以我们需要添加用户。

adduser ***   //添加用户

passwd ***  //给用户赋值

添加完用户之后:

用root用户执行 : chown -R 文件夹名 用户名

将这几个压缩包所在的文件夹及解压完的文件夹权限给你新建的用户。之后再使用新用户启动就OK了。

 

参考链接:http://www.cnblogs.com/xd502djj/archive/2011/11/23/2260094.html

posted @ 2017-10-26 15:22  每天进步一丶  阅读(14688)  评论(1编辑  收藏  举报