Linux is a great operating system and many companies rely on it for their business solutions. That is why more and more projects are born to be implemented in them. In this article, I will explain how to install Elasticsearch in CentOS 7.
In short, Elastichsearch is a document-oriented search engine that allows us to index a large volume of data to make queries about them later. It’s open source licensed under the Apache License 2.0. With this in mind, let’s install Elasticsearch.
0. What you need
To install Elasticsearch on CentOS7, you need in a first place, get administrator privileges, to perform the commands correctly.
Then, you need a machine with CentOS 7 and the possibility of accessing the server through ssh.
It is always useful to have knowledge about the use of the terminal.
1.- Upgrading the System and Installing Java
We are going to perform the installation on a server, this implies that we must always have updated packages in order to always get the latest security patches.
To become a root user, type in the terminal:
:~$ sudo -i
After entering the root password, we will be able to upgrade the system.
:~# yum update
Before starting to install Elasticsearch, you must make sure you have Java on your computer as the application requires it.
:~# yum install java-1.8.0-openjdk.x86_64
When the installation is finished, you can run the following command to be sure of it.
:~# java --version
2.- Install Elasticsearch
A simple and practical way to install Elasticsearch is to do it through your .rpm packages. This is very useful if you need to install it in other distributions like Suse or RHEL.
First, download the packages:
:~# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.rpm :~# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.rpm.sha512
The first is the program itself, the second package is to verify its integrity, something vital because you are doing the installation on a server.
After downloading the packages, it is necessary to check them.
:~# shasum -a 512 -c elasticsearch-6.4.1.rpm.sha512
And finally, install the packages.
:~# rpm --install elasticsearch-6.4.1.rpm
Then it’s your turn to set up the Elasticsearch service in order to enable and initialize it.
:~# systemctl daemon-reload :~# systemctl enable elasticsearch :~# systemctl start elasticsearch
3. Check that Elasticsearch is working
Now that you have installed Elasticsearch, you must check that everything is in order, to do so, run:
:~# lsof -i :9200
You must remember or know that Elasticsearch uses port 9200 by default. That’s why the command makes an inspection of the applications that use the mentioned port.
You can also check
/var/log/elasticsearch/elasticsearch.log for errors.
A small configuration and Conclusion
It is possible to make Elasticsearch listen to a single IP in particular. Open the file
:~# nano /etc/elasticsearch/elasticsearch.yml
You can also further protect the instance by disabling public access. In that same file, add the following at the end.
Then, restart the service.
As a conclusion, it can be said that Elasticsearch is a solution intended for large data and companies but is still easy to install on a server with CentOS.
We want to know about your experience, have you used elasticsearch?
Please share this article on your social networks.