Elasticsearch don't run elasticsearch as root

hello, i confused how to how to make don't run elasticsearch as root ?

How are you starting Elasticsearch right now?

[root@ELK-5 admin-elk]# systemctl restart elasticsearch
[root@ELK-5 admin-elk]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-02-01 05:28:40 UTC; 10s ago
Docs: http://www.elastic.co
Process: 20880 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE)
Process: 20879 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
Main PID: 20880 (code=exited, status=1/FAILURE)

Feb 01 05:28:35 ELK-5 systemd[1]: Starting Elasticsearch...
Feb 01 05:28:35 ELK-5 systemd[1]: Started Elasticsearch.
Feb 01 05:28:40 ELK-5 systemd[1]: elasticsearch.service: main process exite...RE
Feb 01 05:28:40 ELK-5 systemd[1]: Unit elasticsearch.service entered failed...e.
Feb 01 05:28:40 ELK-5 systemd[1]: elasticsearch.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ELK-5 admin-elk]#

Please show the error message you get in the Elasticsearch log. What's the value of the ES_USER setting in /etc/default/elasticsearch?

[2017-02-02T15:20:55,412][WARN ][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:125) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.2.jar:5.1.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.2.jar:5.1.2]
... 6 more

there isn't /etc/default/elasticsearch

Which Linux distribution?

i used centos 7.2

Oh. Then it's /etc/sysconfig/elasticsearch, not /etc/default/elasticsearch.

https://www.elastic.co/guide/en/elasticsearch/reference/master/rpm.html#rpm-configuring

#ES_USER=elasticsearch
#ES_GROUP=elasticsearch

Weird. Then I don't know what's up.

Wait. Does /etc/sysconfig/elasticsearch actually say this:

# ES_USER=elasticsearch
# ES_GROUP=elasticsearch

If yes, try uncommenting those lines.

yes, I have tried. but elasticsearch still can't run.
it was because I installed x-pack

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.