Installing ElasticSearch on Centos 8

Elasticsearch Is one of the most popular search engines in the field of Big Data, a scalable open source non-relational data warehouse, an analytical NoSQL DBMS with a wide range of full-text search functions.

Installing ElasticSearch from the repository

We import the PGP Key to further add the ElasticSearch repository

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

Add the repository

$ sudo nano /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]
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

Install ElasticSearch

$ sudo dnf -y install elasticsearch

Add the ElasticSearch service to startup and start it

$ sudo systemctl enable --now elasticsearch

Checking if the service has started

$ systemctl status elasticsearch

Installing ElasticSearch from an RPM Package

Download the ElasticSearch package and install it

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.3-x86_64.rpm -P /tmp
$ cd /tmp
$ sudo dnf -y localinstall elasticsearch-7.9.3-x86_64.rpm

Add the ElasticSearch service to startup and start it

$ sudo systemctl enable --now elasticsearch

Checking if the service has started

$ systemctl status elasticsearch

Checking the port

$ ss -tulnp | grep 9200

Testing

$ curl -X GET "localhost:9200/"

The system should display the entire list of information. On the second line, you should see that cluster_name is set to elasticsearch. This confirms Elasticsearch is running and listening on port 9200.

See messages logged by Elasticsearch using the command

$ sudo journalctl -u elasticsearch

ElasticSearch setup

Editing the ElasticSearch configuration file

$ sudo nano /etc/elasticsearch/elasticsearch.yml
[…]
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: localhost
#
# Set a custom port for HTTP:
#
http.port: 9200
[…]

Change the minimum / maximum size of the RAM allocated for the java machine

$ sudo nano /etc/elasticsearch/jvm.options
[…]
-Xms2g
-Xmx2g
[…]

Restarting ElasticSearch

$ sudo systemctl restart elasticsearch

Firewall configuration

Opening port 9200

$ sudo firewall-cmd --add-port=9200/tcp --permanent
$ sudo firewall-cmd --reload

SELinux configuration

Add ElasticSearch 9200 / tcp service port to SELinux policy

$ sudo semanage port -m -t http_port_t 9200 -p tcp
Sidebar