elasticsearch. tutorials

Running ElasticSearch as a non-root-user

By Clinton Gormley | 22 Feb 2011

To run ElasticSearch on as a non-root user (eg elasticsearch), you can follow the following steps.

First, make sure that you have the service wrapper installed (see Setting up ElasticSearch ).

We assume that $ES_HOME is set to the ElasticSearch install path, eg:

    export ES_HOME=/opt/elasticsearch
  • Create the user:
        useradd -d $ES_HOME elasticsearch
  • Open the service wrapper script in a text editor:
        vi $ES_HOME/bin/service/elasticsearch
    • uncomment the line starting RUN_AS_USER and change it to: RUN_AS_USER=elasticsearch
    • change the line starting LOCKDIR to: LOCKDIR=$ES_HOME/lock
  • Create the lock dir:
        mkdir $ES_HOME/lock
  • Change permissions on the ElasticSearch install dir: (Your gateway dir also needs to be writable by the elasticsearch user)
        chown -R elasticsearch $ES_HOME
  • Edit /etc/security/limits.conf and add this line (this increases the number of files that the elasticsearch user can open, see Raising nofile limits if you have any problem here):
        elasticsearch     soft    nofile    32000
  • Install the service wrapper to /etc/rc.d (or /etc/rc.d/init.d depending on your distribution):
       $ES_HOME/bin/service/elasticsearch -install
  • ElasticSearch is now set up to run as a service on startup, running under the user elasticsearch. You can start and stop ElasticSearch using:
    • /etc/rc.d/elasticsearch start
    • /etc/rc.d/elasticsearch stop
blog comments powered by Disqus
 
Fork me on GitHub