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,完整命令如下
bin/elasticsearch -Des.insecure.allow.root=true
#或者 用vi打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加以下命令
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
2、为elaticsearch 创建用户并赋予相应权限;
为 elasticsearch 创建专用的数据存储目录
$ mkdir -p /home/elastic/data
$ mkdir -p /home/elastic/logs
由于 elasticsearch 部署必须得非root用户,则需要先创建 elastic:elastic 用户组和用户,并进行授权:
#创建用户和分组
$ groupadd elastic
$ useradd -g elastic -M -s /bin/bash elastic
$ chown -R elastic. /usr/local/elasticsearch/
$ chown -R elastic. /home/elastic/data
$ chown -R elastic. /home/elastic/logs
#赋予root权限
$ echo 'elastic ALL=(ALL) ALL"' >>/etc/sudoers

然后用下面命令再次启动:

$ su elastic
$ bin/elasticsearch

java.lang.IllegalArgumentException: unknown setting [bootstrap.system_call_filter] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
        at org.elasticsearch.server@8.6.1/org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:561)
        at org.elasticsearch.server@8.6.1/org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:507)
        at org.elasticsearch.server@8.6.1/org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:477)
        at org.elasticsearch.server@8.6.1/org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:447)
        at org.elasticsearch.server@8.6.1/org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:151)

See logs for more details.

ERROR: Elasticsearch did not exit normally - check the logs at /home/elastic/logs/elasticsearch.log

ERROR: Elasticsearch exited unexpectedly

忘记密码

启动后,如果密码忘记了,可以采用指令重置密码

# 使用 es 用户,执行指令,重置 elastic 用户密码
bin/elasticsearch-reset-password -u elastic
作者:Jeebiz  创建时间:2023-02-03 09:30
最后编辑:Jeebiz  更新时间:2024-06-22 23:54