Install Elasticsearch on Ubuntu 18.04 /16.04 LTS

Install Elasticsearch on Ubuntu 18.04 /16.04 LTS

Elasticsearch is a flexible and powerful open source, distributed real-time search and analytics engine. Using a simple set of APIs, it provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility.

This tutorial will help you to install Elasticsearch on Ubuntu 18.04 & 16.04 LTS system.

Step 1 – Prerequsities

Login to your Ubuntu system using sudo privileges. For the remote Ubuntu server using ssh to access it. Windows users can use putty or alternatives to log in to Ubuntu system.

Elasticsearch required Java to run on any system. Make sure your system has Java installed by running following command. This command will show you current Java version.

java -version

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

Also, make sure your JAVA_HOME environment variable is configured:

echo $JAVA_HOME

/usr/lib/jvm/java-8-oracle

 

Step 2 – Install Elasticsearch on Ubuntu

The Elasticsearch official team provides an apt repository to install Elasticsearch on Ubuntu Linux system. After install below package and import GPG key for Elasticsearch packages.

sudo apt-get install apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

 

Then configure the apt repository on your Debian system. The below command will add a repository to install latest Elasticsearch 6.X on your Ubuntu system.

add-apt-repository "deb https://artifacts.elastic.co/packages/6.x/apt stable main"

After adding the repository to your system. Run the following commands to update cache and then install Elasticsearch packages on your system.

sudo apt-get update
sudo apt-get install elasticsearch

Step 3 – Configure Elasticsearch

The Elasticsearch has been installed on your system. You can customize this by editing Elasticsearch configuration file. Edit configuration file in your favorite text editor and update it:

sudo nano /etc/elasticsearch/elasticsearch.yml

Change the following values:

/etc/elasticsearch/elasticsearch.yml

network.host: 0.0.0.0
cluster.name: ES_Cluster_01
node.name: "Cluster_01_Node_001"

network.host – Set the network host to 0.0.0.0 to listen on all interfaces and make it publically available. You can use your LAN address for LAN access only.
cluster.name – Name of the cluster. For the multi-node cluster, all the nodes must use the same cluster name.
node.name – Set the unique name of the node to identify in a cluster.

Step 4 – Launch Elasticsearch

To configure Elasticsearch to start automatically when the system boots up, run the following commands:

sudo /bin/systemctl enable elasticsearch.service

Elasticsearch can be started and stopped as follows:

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

Step 5 – Test Setup

The Elasticsearch service is ready to use. You can test it using curl command line utility. Run the simple GET command using curl to verify the setup. You will see the Elasticsearch cluster details with the version on your screen.

curl -X GET http://192.168.10.100:9200

Console Output

{
"name" : "California DataCenter 1",
"cluster_name" : "Cluster_01_Node_001",
"cluster_uuid" : "GWqKIFxSQOy2FhyMO-tB5g",
"version" : {
"number" : "6.4.2",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "04711c2",
"build_date" : "2018-09-26T13:34:09.098244Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

Source