How to install Elasticsearch 7.x on AlmaLinux 8 Print

  • 0

Elasticsearch is gaining popularity as a modern, fast and powerful search engine. It can integrate into many pre-built applications and CMS' as well as custom coded applications using its fantastic API.  Today we'll give a simple overview of how to install Elasticsearch 7.x versions onto AlmaLinux 8. We'll assume that you've already logged into your server using console or SSH, and that you have obtained root or su access.

1. Install Java

Elasticsearch is written in Java, so we first need to install Java on the server.

yum install java-11-openjdk-devel

2. Import Elasticsearch GPG Key

Elasticsearch packages are signed for authenticity, so we should import their GPG key for best security.

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

3. Add the RPM repo

The easiest way to install and keep updated with Elasticsearch is to use its RHEL repository. First let's open a new file:

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

Then, paste in the repo contents:

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Then, hit CTRL + X to exit the file, remembering to save changes.

4. Installing the Elasticsearch service

Now we actually install Elasticsearch from the new repo we've created.

yum install --enablerepo=elasticsearch elasticsearch

5. Fix the JVM options

By default, AlmaLinux + Java + Elasticsearch settings do not play nice with each other. We need to update Java's temp directory to ensure it can correctly start and run Elasticsearch and properly log entries. Open this file:

nano /etc/elasticsearch/jvm.options

Now locate the line that reads:

-Djava.io.tmpdir=${ES_TMPDIR}

Then, comment out the line (or just delete it), and then replace it with:

-Djava.io.tmpdir=/var/log/elasticsearch

Then exit out of nano with CTRL + X,  remembering to save changes.

6. Configure the Elasticsearch cluster

Elasticsearch won't start without some basic cluster configurations. So pull up the config file in Nano and define them:

nano /etc/elasticsearch/elasticsearch.yml

Now, search for the following lines, uncomment them, and edit accordingly.

cluster.name: yourserverhostnamehere
node.name: node-1
path.data: /var/lib/elasticsearch
network.host: 127.0.0.1

7. Enable Elasticsearch on boot and start it

Finally we want to enable Elasticsearch as a system service that automatically runs on boot:

systemctl enable elasticsearch

And then we want to run it for the first time:

systemctl start elasticsearch

8. Customise and use Elasticsearch

That's it, you're done for the installation! Elasticsearch is now running on your server on its default port 9200. Now it's over to you for the final configuration and customisation of your choosing.


Was this answer helpful?

« Back