How to install Elasticsearch on Centos 7?

How to install elasticsearch on centos 7

In this tutorial, I am going to tell you how to install Elasticsearch on Centos 7?

Elasticsearch is an open-source search engine that you can install on your store, to search and analyze the large volume of data in real-time. Many applications that rely on intensive search operations, like an eCommerce store or data applications, use Elasticsearch.

For example:

When a user opens an eCommerce store, he may browse the site via the menu. Or the user will use the search function to find a product on the site.

Now there are millions of products on an eCommerce store, and that’s why they need a powerful tool that can perform the search quickly.

Speed is important for eCommerce SEO and also for customer satisfaction. Elasticsearch empowers the site to analyze and search the data quickly

Must Read: How to Install Magento 2.4 with Command Line?. 

How to install Elasticsearch on Centos 7?

There are several ways to install Elasticsearch on your server depending on the OS distribution, but the easiest way of doing so is to download the RPM from artifacts.elastic.co.

Install and Verify Java

Since elasticsearch is built on Java, we will require the OpenJDK package as a prerequisite.

You can check if Java is installed on your server by executing:

# java -version

The expected result would be:

install Elasticsearch on Centos 7

If java is not installed, you can easily install java using the command below.

# yum -y install java

Once java is installed, go ahead.

Download and Install the Elasticsearch

Execute the below commands one by one to download, verify, and install Elasticsearch.

# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.0-x86_64.rpm
install Elasticsearch on Centos 7
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.0-x86_64.rpm.sha512
install Elasticsearch on Centos 7
# shasum -a 512 -c elasticsearch-7.7.0-x86_64.rpm.sha512 
image2 1 install Elasticsearch on Centos 7
# rpm --install elasticsearch-7.7.0-x86_64.rpm
image4 1 install Elasticsearch on Centos 7

Start and enable the elasticsearch service. 

# systemctl start elasticsearch
# systemctl enable elasticsearch

Verify the Elasticsearch Installation

Verify the installation with the following command:

# systemctl status elasticsearch
elasticsearch

By default, elasticsearch listens on port 9200. You can verify that elasticsearch is running by sending a GET request to port 9200 using CURL.

# curl -XGET http://localhost:9200

The output should look like this:

image10 install Elasticsearch on Centos 7

Elasticsearch is now installed successfully on your server. 

Optimize the Elasticsearch

Now, we need to set the HEAP_SIZE for elasticsearch to ensure the maximum performance while keeping the server resources in mind. 

By default, Elasticsearch tells the JVM to use a heap with a minimum and maximum size of 1 GB. 

This is defined in the file /etc/elasticsearch/jvm.options as shown below.

-Xms1g
-Xmx1g

Where:

  • Xms represents the initial size of total heap space
  • Xmx represents the maximum size of total heap space

A recommended value would be no more than 50% of the total physical RAM.

Once the value is set, restart elasticsearch service using the command below and you’re good to go!

# systemctl restart elasticsearch

Configure Elasticsearch on Magento Store

To configure Elasticsearch on your Magento, follow the steps below.

Log in to your Magento Admin, navigate to Stores > Settings > Configuration.

Magento Elasticsearch

In the left panel, expand Catalog and choose Catalog underneath and expand the Catalog Search section.

Elasticsearch in Magento

For Search Engine, deselect the Use system value checkbox and choose the version that is installed on your server.

Add the configuration details to the fields and click on Test Connection.

Magento elasticsearch

That’s All

By following this tutorial, you can easily install Elasticsearch on Centos 7.

Solr is an alternative of Elasticsearch that you can try too. Read the difference between Solr and Elasticsearch.

I also mentioned how to configure it for the Magento store, and how to optimize the Elasticsearch for the best performance.

If you run into any error or any issue, do leave it in the comment box.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new modules, and more. 100% Magento Goodness, a promise!

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

We can help you. Right now.

Fast growing merchants depend ServerGuy for high-performance hosting. Experience counts. Let's get started.

Talk to a sales representative

USA / Worldwide

+1.714.2425683

India

+91.9852704704

Core Web Vitals Book COver

Is your website ready for Core Web Vitals?

Take this FREE book with you and optimize your store for speed.

Learn all about new Google new ranking factors and get that top ranking.