This guide will take you through how to install Elasticsearch 7.x on CentOS 7/Fedora 29. Elasticsearch is the heart of Elastic Stack.
Our previous guide described how to install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8.
Install Elasticsearch 7.x on Ubuntu 18.04/Debian 9.8
Install Elasticsearch 7.x on CentOS 7/Fedora 29
Again, you can install Elasticsearch using the tar.gz archive, RPM package or from RPM repository. We will discuss the use of RPM and RPM repository in this guide.
Install Elasticsearch 7.x using RPM Repository
To install Elasticsearch 7.x on CentOS 7/Fedora 29 using the RPM repository, perform system update before proceeding
On CentOS 7
yum update
yum upgrade
On Fedora 29
dnf update
dnf upgrade
Import the Elasticsearch PGP Key
Once the system upgrade is done, run the command below to import the Elasticsearch PGP Signing Key.
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Add Elasticsearch 7.x RPM Repository
To add the Elasticsearch 7.x repository that will allow you to install Elasticsearch 7.0.0 on CentOS 7/Fedora 29, run the command below
cat > /etc/yum.repos.d/elastic-7.x.repo << EOF
[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
EOF
Once you have created the Elasticsearch repository, update your system and install Elasticsearch.
On CentOS 7
yum update
yum install elasticsearch
On Fedora 29
dnf update
dnf install elasticsearch
If the installation is successful, you should be able to see such an output snippet.
...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Installing : elasticsearch-7.0.0-1.x86_64 1/1
Running scriptlet: elasticsearch-7.0.0-1.x86_64 1/1
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
Verifying : elasticsearch-7.0.0-1.x86_64 1/1
Installed:
elasticsearch-7.0.0-1.x86_64
Complete!
Install Elasticsearch 7.x using RPM package
To manually install Elasticsearch 7.0 on CentOS 7/Fedora 29 using RPM package, download the RPM package.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm
Next, download the checksum for verifying the integrity of the RPM package.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm.sha512
Run the integrity check by comparing the checksums. Before that, install perl-Digest-SHA -y
which provides shasum for checksum comparison.
yum install perl-Digest-SHA -y
dnf install perl-Digest-SHA -y
shasum -a 512 -c elasticsearch-7.0.0-x86_64.rpm.sha512
If all is well, then you will get an OK output.
elasticsearch-7.0.0-x86_64.rpm: OK
Next, Install Elasticsearch 7.0.0 on CentOS 7/Fedora 29
On CentOS 7
sudo yum localinstall elasticsearch-7.0.0-x86_64.rpm
On Fedora 29
sudo dnf install ./elasticsearch-7.0.0-x86_64.rpm
Running Elasticsearch
Once the installation is done, you can start elasticsearch service by executing;
systemctl daemon-reload
systemctl start elasticsearch
To stop or configure elasticsearch service to start automatically on system boot, run the commands below respectively.
systemctl stop elasticsearch
systemctl enable elasticsearch
To check the status;
systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2019-04-28 23:21:53 EAT; 8s ago
Docs: http://www.elastic.co
Main PID: 25905 (java)
CGroup: /system.slice/elasticsearch.service
├─25905 /usr/share/elasticsearch/jdk/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInit…
└─25969 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
Apr 28 23:21:53 Cent7.example.com systemd[1]: Started Elasticsearch.
Apr 28 23:21:54 Cent7.example.com elasticsearch[25905]: OpenJDK 64-Bit
You can also use curl to check the status.
curl -X GET "localhost:9200/"
{
"name" : "Cent7.example.com",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "_C5MBUk4So6v7e0qQvRv_g",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
If FirewallD is running, you need to open tcp port 9200 on it.
sudo firewall-cmd --add-port=9200/tcp --permanent
sudo firewall-cmd --reload
Great, that is all it takes to install Elasticsearch 7.0 on CentOS 7/Fedora 29. We will cover more about Elastic Stack in our next tutorials. Enjoy.
Reference:
Thanks a lot. I didn’t notice that the firewalld was blocking me to access the URL. 🙂
Everything works fine now.
Glad you fixed the issue. Enjoy