How to Install Elasticsearch on a Vultr CentOS 7 Server Instance

Updated on November 21, 2023
How to Install Elasticsearch on a Vultr CentOS 7 Server Instance header image

Elasticsearch is a popular open source full-text search and analytics engine. Thanks to its versatility, scalability, and ease of use, Elasticsearch is widely used as various applications' underlying technology to provide complex search features.

In this introductory tutorial, I will explain how to install Elasticsearch on a single CentOS 7 node.

Prerequisites

Before reading further, you should have:

  • Deployed a Vultr CentOS 7 server instance from scratch.
  • Logged into this CentOS 7 machine from an SSH terminal using a non-root sudo user. You can find out how to create such a user from this Vultr article.

Step 1: Update your system

Update your system to the latest stable status:

sudo yum update
sudo reboot

After the reboot, still use the same user to log in.

Step 2: Install Java

You need to install Java before you can run Elasticsearch properly. Here, you can install OpenJDK 1.8.0 using the following command:

sudo yum install java-1.8.0-openjdk.x86_64

Then, you can verify your installation with this command:

java -version

Step 3: Install Elasticsearch

Import the Elasticsearch GPG key:

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

Create an Elasticsearch repo:

sudo vi /etc/yum.repos.d/elasticsearch.repo

Copy the following code segment into the file:

[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

Save and quit:

:wq

Install Elasticsearch using YUM:

sudo yum install elasticsearch

Start Elasticsearch and set it to start on system boot:

sudo systemctl start elasticsearch.service
sudo systemctl enable elasticsearch.service

Step 4: Test Elasticsearch

After the installation, you can test Elasticsearch by using the curl command:

curl http://localhost:9200/

Upon success, a JSON document from Elasticsearch will be outputted to your terminal:

{
  "name" : "Legion",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.3.2",
    "build_hash" : "b9e4a6acad4008027e4038f6abed7f7dba346f94",
    "build_timestamp" : "2016-04-21T16:03:47Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}

This example uses the default configuration. If you want to deploy Elasticsearch in a production environment, you should use a more customized configuration. You can learn more about configuring Elasticsearch from the official website.