作为新手,安装完Elasticsearch,迫不及待地会执行:

./bin/elasticsearch

但往往会出现如下的异常导致Elasticsearch无法运行:

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

Cannot log to named pipe /tmp/elasticsearch-762759604916516991/controller_log_1781 as it could not be opened for writing

令人匪夷所思,Elasticsearch竟然无法使用root账户来启动,查询了网上相关的资料,原来最新版本的Elasticsearch安全级别提高了,不允许采用root帐号启动,所以我们只能换个身份,添加一个新用户来启动Elasticsearch,如下操作:

(1)新建用户组:groupadd esgroup

(2)新增用户:useradd esroot -g esgroup -p esroot

(3)修改文件的拥有者:chown -R esroot:esgroup /usr/local/elasticsearch-7.10.0
注:chown将指定文件的拥有者改为指定的用户或组

(4)切换账户:su esroot

(5)运行Elasticsearch:/usr/local/elasticsearch-7.10.0/bin/elasticsearch

至此,Elasticsearch 才得以正常启动。

标签: none

添加新评论