How To Install Elasticsearch On The Cent OS

Have a Database Problem? Speak with an Expert for Free
Get Started >>

Introduction

The service provided by Elastic is a versatile analytics and archiving platform. It has a wealth of useful supporting software made to be integrated into its mechanism. The initial step to open up the impressive functionality of this system is to install Elasticsearch for a foundation. The guide that follows will equip the user with the knowledge to perform a complete installation. Once this is in place, other tools can be added as desired. As the usable features expand the user will be able to fully engage the enhanced abilities of the program detailed below.

CentOS is based on Red Hat Linux, and the preferred method for installation is using Elastic’s RPM distribution for Elasticsearch and for the entire ELK stack.

Prerequisites

  • Elasticsearch only has 64-bit architecture support. Many, if not all, of the Elastic products, will have trouble working properly on a 32-bit environment.
  • The user will need to obtain SSH access to the CentOS Linux server with root privileges, by making use of a private key.
  • Elasticsearch is structured upon Java, requiring a minimum of Java 8 to run. Oracle’s Java and OpenJDK are the only ones supported. The JDK can be downloaded from their website. For more information, a user can consult Oracle’s Installation Guide. Older versions may require JDK 7, and only version 6.2 of ES has official support for JDK 9.
  • To ensure Java installed properly, use this command while accessing the server remotely via SSH in terminal:
1
javac -version
  • If Java and JDK 8 are installed properly, the user will see text output that looks like this in the terminal:
1
2
3
4
5
6
7
8
9
java version "1.8.0_65"



Java(TM) SE Runtime Environment (build 1.8.0_65-b17)



Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
  • JDK 8 should now be installed properly. If JDK is not installed, use the yum package manager to install Java using root privileges:
1
sudo yum install java-1.8.0-openjdk-devel
  • If the installed version is not compatible, the user can always use yum’s remove command to uninstall Java. Be sure to replace the Xs with the correct version number being uninstalled:
1
sudo yum remove java-1.X.X

Installing Elasticsearch

  • The simplest method to install on a CentOS server is to use their rpm package on their downloads page. Just use the wget command followed by the package URL for the RPM repository to download the item onto the server:
1
wget https://artifacts.elastic.co/downloads/Elasticsearch/Elasticsearch-6.6.1.rpm
  • Once the server has finished downloading, the Red Hat RPM package manager can be used for installing the program from the containing archive:
1
sudo rpm -ivh Elasticsearch-6.6.1.rpm

Check That The Elasticsearch Service Is Running

  • To ensure that the service is running, use this command:
1
service Elasticsearch status
  • The user can also work with cURL to return some build and version information; just enter this command in the Linux terminal:
1
curl -XGET 'localhost:9200'
  • If it’s running properly, the cURL request should return an object in JSON that looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
    "name" : "a1ABCDE",
    "cluster_name" : "Elasticsearch",
    "cluster_uuid" : "ABCD123456",
    "version" : {
        "number" : "6.6.1",
        "build_flavor" : "default",
        "build_type" : "",
        "build_hash" : "",
        "build_date" : "2019-XX-XX",
        "build_snapshot" : false,
        "lucene_version" : "7.6.0",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
},
    "tagline" : "You Know, for Search"
}
  • The configuration files are found in the /etc/Elasticsearch directory. If it is not running, then use this command to start the service:
1
./bin/Elasticsearch
  • Or the user can try to use sudo if they do not have root permissions, or if they are running into a permissions error:
1
sudo ./bin/Elasticsearch
  • If the service still refuses to start or if there is a connection problem, the user can always try running the service as an executable:
1
2
3
4
5
sudo chmod +x Elasticsearch.in.sh



sudo ./Elasticsearch.in.sh
  • The easiest way to install it on CentOS is to just simply SSH into the server and install using the RPM package.
  • When trying to remotely start the service the user might get a Connection Refused error. If this happens the user should check the firewall settings and edit the Elasticsearch.yml file.
  • Uncomment the network.host: variable (by removing the # character at the start of the line) in the YML file, and change its value to 0.0.0.0. At the terminal, nano can be used for editing the file:
1
sudo nano edit /etc/Elasticsearch/

It should look just like this after making the changes:

1
2
3
4
5
6
7
8
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host
: 0.0.0.0
...
...

Be sure not to forget about saving the changes before closing the editor. Press CTRL + O, then press Y to verify the command and output the changes.

After that, the server can be made remotely accessible by changing the firewall setting to:

1
2
3
4
5
firewall-cmd --zone=public --add-port=9200/tcp --permanent



firewall-cmd --reload

The port 9200 is added as the default port for Elasticsearch. After making all changes the user can restart the Elastic service using this command:

1
sudo systemctl restart Elasticsearch.service

Conclusion

The instructions laid out in this guide show a user how to install the Elasticsearch service onto the Cent OS. Be certain to give close attention to the assorted tips and links contained in this walkthrough to enjoy an install free of issues. When it is implemented correctly, the benefits of this valuable platform will be as close as the user’s understanding of how they can to be used. Take note of the various links to further documentation on the topics covered in this tutorial. They will assist during the installation and successful operation of the explained program.

Pilot the ObjectRocket Platform Free!

Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.

Get Started

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.