How to run Elasticsearch 2.1.1 as root user in Lin

2020-02-24 12:42发布

I am trying to run Elasticsearch 2.1.1 in my Linux machine which I am the root user of it.

When I tried to execute the Elasticsearch.I am getting the following error:

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

I referred some suggestion available in internet, they mentioned to run it as different user. My scenario is to run as root user only. How to overcome this problem without running as different user.

6条回答
趁早两清
2楼-- · 2020-02-24 12:45

we need to create a new user in Linux server say user = es and grant sudo chown -R es elasticsearch-6.1.0/ then you can switch 'es' user account and run ./elasticsearch-6.1.0/bin/elasticsearch

查看更多
Explosion°爆炸
3楼-- · 2020-02-24 12:47

You can also create alias

alias elasticsearch='elasticsearch -Des.insecure.allow.root=true'

Add above line in bashrc file, After that elasticsearch command will work.

查看更多
霸刀☆藐视天下
4楼-- · 2020-02-24 12:51

There are two workarounds to resolve this issue :

Solution 1: download zip file n unzip then start by following command

bin/elasticsearch -Des.insecure.allow.root=true -d

Solution 2:

vi bin/elasticsearch

Add property to allow root to run two instance:

ES_JAVA_OPTS="-Des.insecure.allow.root=true"

Save and close. You can start by root now.

查看更多
做个烂人
5楼-- · 2020-02-24 12:59
  1. Open script file:

    vi bin/elasticsearch

  2. Add property for allow root:

    ES_JAVA_OPTS="-Des.insecure.allow.root=true"

  3. Save and close.
  4. You can start by root now.

Good luck.

查看更多
够拽才男人
6楼-- · 2020-02-24 13:01

You should change the owner and group of the elasticsearch-X.X.X and run as that user. It works in elasticsearch-5.3.0

查看更多
叛逆
7楼-- · 2020-02-24 13:04

Based of the following code-snippet looks like you should be able to achieve this by enabling property es.insecure.allow.root

Example :

bin/elasticsearch -Des.insecure.allow.root=true
查看更多
登录 后发表回答