Monday , December 23 2024

How To Install Elasticsearch On Centos

In this article I will tell the installation of Elasticsearch on Centos 7. We will perform the installation with an example scenario. Before reading this article, I suggest you read the following article on Elasticsearch.

What is Elasticsearch

We will use 5 servers for installation. 3 of these 5 servers will be the data node. The other 2 servers will be the master node. And we will install kibana on one of the master nodes.

Example Scenario

As you can see in the screenshot below, we have 5 servers.

We will install two servers as master nodes. we will install three servers as data nodes. We will also install Kibana on the second master node. If you want you can install Kibana on another server.

Installation Steps

Java Installation

First, we are installing java. To install Java you must download the file that is compatible with your system from the link below.

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Since we are going to install on 64 bit linux system, we are downloading the file below.

Then we create a folder like below to install java. The Java installation is done under the usr/bin folder by default. I’ll make installation in the folder I’ll create below for easier use.

as root:

We extract the downloaded java files into the /opt/jdk directory and ensure that the java works from this directory.

We set JAVA_HOME using the following commands.

Elasticsearch Installation

You can download the installation file from the link below.

https://www.elastic.co/downloads/elasticsearch

Since we will install on CENTOS, we download the RPM package and copy it to the server.

You can go to the directory where you copied the RPM package on the server and install elascticsearch using the following command.

as root:

It will ask a question. Type “y” and click enter.

If you have internet access via the server, you can perform elasticsearch installation as below.

yum install https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.rpm

Necessary Configurations After Installation

SET JAVA_HOME For Elasticsearch

After the installation is completed, we open the following file with the command “vi” and we show the path of JAVA to elasticsearch.

as root:

After the file is opened, we set JAVA HOME as follows. you must press the Insert key to make changes.

Press ESC and save with “wq” command as follows and press enter.

Enable elasticsearch service

We enable elasticsearch service using the command below.

The path of the service is as follows.

Elasticsearch Configurations

Before configuring, we create two directories to store elasticsearch’s data files and error log files.

Note: You should do this with elasticsearch. You can switch to the elasticsearch user using the “su elasticsearch” command.

as root:

Assign the elasticsearch user as the owner for the data folder and for all directories under it.

We’re changing the privileges of elasticsearch.

We are editing the elasticsearch.yml file which is the elasticsearch configuration file using the command below.

After opening the file, we configure it as follows. If there is # at the beginning of the line, this line is a comment line or contains an inactive configuration information.

Note: I recommend that you read the lines beginning with #. Because I’ve written some notes.

Do not copy the below yml file. Just change the necessary parameters according to your system.

If you are going to use the searchguard, you should copy the searchguard’s keystore information to the elasticsearch.yml file. For detailed information, please read the following article.

“How To Install Searchguard For Elasticsearch and Kibana(Managing Multiple Indice In Elasticsearch Seperately and Password Protection on Elasticsearch)”

Start Elasticsearch Service

After the necessary configurations are done as above, we start the service as below.

We do the same for all master and data nodes. The only different step in the installation is the following parameters in the yml file.

If we set the “node.data:” parameter as follows, that node becomes the master.

If we set the “node.master:” parameter as follows, that node becomes the data node.

After Elastic 6.0 we can use xpack for authentication instead of search guard. If you set xpack.security.enabled: true, this means that you will use xpack’s authentication when connecting elasticsearch. After this you must set passwords for specific users with below command.

Check Everything is Correct

All installations and configurations have been completed.

Open a browser and write your IP:port to the browser.

If everything is succesfull, everything should be as follows.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *