Elasticsearch Installation on CentOS 7

Elasticsearch is a popular search engine, especially among Magento users. There are some gotchas that might cause problems that this guide attempts to address.

Step-by-step guide

  1. Install the Java SDK

    Elasticsearch requires Java to run. This SDK can be installed directly from the epel repository.

    yum -y install java-1.8.0-openjdk
  2. Download and install the public signing key for elasticsearch:

    rpm --import http://artifacts.elastic.co/GPG-KEY-elasticsearch
  3. Create a repo:

    Elasticsearch requires a third party repo, set it up by running:

    vim /etc/yum.repos.d/elasticsearch.repo

    Add the following:

    name=Elasticsearch repository for 7.x packages
  4. Install elasticsearch:

    Once the Elasticsearch repo is installed, simply yum install the package:

    yum install elasticsearch
  5. Elasticsearch requires an executable tmp directory. Some VMs are configured to mount tmp with noexec, which will cause Elasticsearch to crash on start up. The best way around this would be to simply create a new tmp directory for Elasticsearch to use. This can be done by doing the following:Create a new tmp directory:

    mkdir /var/lib/elasticsearch/tmp

    Then assign the correct ownership and permissions:

    chown elasticsearch:elasticsearch /var/lib/elasticsearch/tmp
    chmod 775 /var/lib/elasticsearch/tmp

    Lastly, add the ES_TMPDIR and TMPDIR line to /etc/sysconfig/elasticsearch

    echo "ES_TMPDIR=/var/lib/elasticsearch/tmp" >> /etc/sysconfig/elasticsearch
    echo "TMPDIR=/var/lib/elasticsearch/tmp" >> /etc/sysconfig/elasticsearch
  6.  Enable and start Elasticsearch

    systemctl start elasticsearch
    systemctl enable elasticsearch

Leave a Reply

Your email address will not be published. Required fields are marked *