gpt4 book ai didi

linux - 以 root 用户身份运行 ElasticSearch

转载 作者:IT王子 更新时间:2023-10-29 00:20:35 29 4
gpt4 key购买 nike

当我尝试使用 ./elasticsearch 启动 ElasticSearch 5.0 时出现以下错误:

[2016-11-23T13:44:09,507][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:116) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73) ~[elasticsearch-5.0.1.jar:5.0.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:96) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:155) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286) ~[elasticsearch-5.0.1.jar:5.0.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112) ~[elasticsearch-5.0.1.jar:5.0.1]
... 6 more

我切换到另一个用户并尝试了 sudo ./elasticsearch 并得到了同样的错误。

如何以根用户身份启动 ElasticSearch?

最佳答案

Elasticsearch 不能以 root 用户运行。 Elasticsearch 本身对此进行了限制。当我们安装 elasticsearch 时,会自动创建一个名为 elasticsearch 的新用户和名为 elasticsearch 的组。可以使用以下命令检查条目

$ sudo less /etc/passwd | grep "elasticsearch"
$ sudo less /etc/group | grep "elasticsearch"

我们需要更改所有 elasticsearch related files 的所有权.请按照以下步骤操作。

步骤:

1.使用下面的示例 cmd 将所有 ES 相关文件的所有权从 root 更改为 elasticsearch。

$ sudo chown elasticsearch:elasticsearch -R /usr/share/elasticsearch
$ sudo chown elasticsearch:elasticsearch -R /var/log/elasticsearch
$ sudo chown elasticsearch:elasticsearch -R /var/lib/elasticsearch
$ sudo chown elasticsearch:elasticsearch -R /etc/default/elasticsearch
$ sudo chown elasticsearch:elasticsearch -R /etc/elasticsearch

2.打开/etc/default/elasticsearch文件并做以下事情

  a)JAVA_HOME=your/java/home/path
b)add the following entries at the end
i) START_DAEMON=true
ii) ES_USER=elasticsearch
iii) ES_GROUP=elasticsearch

3.现在启用elasticsearch服务并启动

  $ sudo systemctl enable elasticsearch
$ sudo systemctl start elasticsearch
$ sudo systemctl status elasticsearch

4.使用curl测试elasticsearch。假设你的主机 ip 是 192.168.5.194 并且 ES 运行在端口 9200

$ curl -X GET ‘192.168.5.194:9200’

完成!!

引用。 : https://stackoverflow.com/a/48390311/1445978

关于linux - 以 root 用户身份运行 ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40766301/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com