Installing Elasticsearch on CentOS, RHEL, or Fedora provides a local search and analytics engine with an HTTP API for indexing and querying large datasets.

The official RPM packages register an Elasticsearch systemd unit, place configuration under /etc/elasticsearch, and store data and logs under /var/lib/elasticsearch and /var/log/elasticsearch.

Kernel settings such as vm.max_map_count must be raised before running Elasticsearch under load, and recent releases enable TLS and authentication by default for the port 9200 API. Binding the service to a non-local address requires additional configuration and firewall review, so initial validation is typically performed on localhost.

Steps to install Elasticsearch on CentOS, RHEL, or Fedora:

  1. Create the Elasticsearch repository file at /etc/yum.repos.d/elasticsearch.repo.
    [elasticsearch]
    name=Elasticsearch repository for 8.x packages
    baseurl=https://artifacts.elastic.co/packages/8.x/yum
    gpgcheck=1
    gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    enabled=1

    Use yum instead of dnf on older CentOS releases.

  2. Install the Elasticsearch package.
    $ sudo dnf install --assumeyes elasticsearch
    Installing:
      elasticsearch-8.19.9-1.aarch64
  3. Persist the vm.max_map_count requirement for Elasticsearch.
    $ echo "vm.max_map_count=262144" | sudo tee /etc/sysctl.d/99-elasticsearch.conf
    vm.max_map_count=262144
  4. Reload sysctl values.
    $ sudo sysctl --system
    * Applying /etc/sysctl.d/99-elasticsearch.conf
  5. Enable the Elasticsearch service in systemd.
    $ sudo systemctl enable --now elasticsearch
    Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service -> /usr/lib/systemd/system/elasticsearch.service.

    The --now option starts the service immediately.

  6. Verify the service is running.
    $ sudo systemctl status elasticsearch --no-pager
    * elasticsearch.service - Elasticsearch
         Active: active (running)
    ##### snipped #####
  7. Reset the elastic user password for API authentication.
    $ sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
    This tool will reset the password of the [elastic] user.
    Please confirm that you would like to continue [y/N] y
    Password for the [elastic] user successfully reset.
    New value: 9wqfXqP0K9r8n2uY5HcF

    Store the generated password securely for authenticated API calls.

  8. Test the HTTPS endpoint using the local CA certificate with the elastic password.
    $ ES_PASS='9wqfXqP0K9r8n2uY5HcF'
    $ curl -s --cacert /etc/elasticsearch/certs/http_ca.crt -u "elastic:${ES_PASS}" https://localhost:9200
    {
      "name" : "es-1",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "8JwLw3ssQbS5W7w1j1LqPw",
      "version" : {
        "number" : "8.12.2"
      },
      "tagline" : "You Know, for Search"
    }

    The CA certificate installed by the RPM is located at /etc/elasticsearch/certs/http_ca.crt.