Install and configure elasticsearch cluster on Ubuntu 14.04 LTS

Elasticsearch is a popular search server based on Lucene. It is well developed in Java and with awesomeness of Open source, it is available to all. In this tutorial we will talk about how to install and configure elasticsearch cluster on Ubuntu 14.04 LTS.

Details Of Elasticsearch Cluster Architecture

Operating System : Ubuntu 14.04 LTS Server Edition
Network : AWS Cloud Computing
Package Name and version : elasticsearch-1.4.4
No. of Servers : 2
elasticnode01 = 172.31.49.78 (Name of server)
elasticnode02 = 172.31.63.200 (Name of server)
Ports opened in both servers :

Port Number Source Destination
9100 elasticnode01 elasticnode02
9200 elasticnode01 elasticnode02
9300 elasticnode01 elasticnode02
9100 elasticnode02 elasticnode01
9200 elasticnode02 elasticnode01
9300 elasticnode02 elasticnode01

elastic

Prerequisite

1. Java

Install and configure elasticsearch

In this section we will practically implement the 2 node elasticsearch cluster. You can increase the server count from 2 to any as per your requirement.

NOTE: The given below steps are implementing on elasticnode01 & elasticnode02.

Step 1. Install Java on both server – elasticnode01 and elasticnode02 .

You can follow our guide to install Java on Ubuntu in case if it is not in your system. We are using the jdk-1.8 in this practical.

Install and set Java on Ubuntu 14.04 LTS with tar ball file

Step 2. Login into your system and switch to superuser by given below command.
In both server – elasticnode01 and elasticnode02

sudo su -

Step 3. In both server – elasticnode01 and elasticnode02 download latest elastic search package from their website.

We have downloaded the package elasticsearch-1.4.4 on our system with wget command.

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz

Step 4. In both server elasticnode01 and elasticnode02 , extracting downloaded elasticsearch package file (elasticsearch-1.4.4.tar.gz) into /opt directory.

The package will be extracted to /opt .

tar -xvzf elasticsearch-1.4.4.tar.gz  -C /opt/

Step 5. In both server elasticnode01 and elasticnode02 , edit the /etc/hosts file and map the both servers ip address . Replace the below given ip addresses with your server’s ip addresses.

vi /etc/hosts
172.31.49.78 elasticnode01
172.31.63.200 elasticnode02

Step 6. In both server elasticnode01 and elasticnode02, change to directory where elasticsearch package you have extracted out.

cd /opt/elasticsearch-1.4.4

Step 7. Edit config/elasticsearch.yml file and update the given below parameters.

In Server elasticnode01 :

vi config/elasticsearch.yml
cluster.name: mycluster
node.name: "elasticnode01"
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["elasticnode02"]

In Server elasticnode02 :

vi config/elasticsearch.yml
cluster.name: mycluster
node.name: "elasticnode02"
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["elasticnode01"]

Step 8 . Start the elasticsearch server. Use the command in both server – elasticnode01 and elasticnode02 .

nohup /opt/elasticsearch-1.4.4/bin/elasticsearch -p /opt/elasticsearch-1.4.4/elasticsearch.pid  > elasticsearch.out 2> elasticsearch.error < /dev/null & 

Step 9. Checking cluster through command line . You can run from any node server (elasticnode01 / elasticnode02).

checking cluster health -

curl 'localhost:9200/_cat/health?v'

checking node status in cluster -

curl 'localhost:9200/_cat/nodes?v'

Given below is reference from our servers -

root@ip-172-31-63-200:/opt/elasticsearch-1.4.4# curl 'localhost:9200/_cat/health?v'
epoch      timestamp cluster   status node.total node.data shards pri relo init unassign 
1427039801 15:56:41  mycluster green           2         2      0   0    0    0        0 
root@ip-172-31-63-200:/opt/elasticsearch-1.4.4# 

root@ip-172-31-63-200:/opt/elasticsearch-1.4.4# curl 'localhost:9200/_cat/nodes?v'
host             ip            heap.percent ram.percent load node.role master name          
ip-172-31-49-78  172.31.49.78             4          27 0.00 d         *      elasticnode01 
ip-172-31-63-200 172.31.63.200            4          27 0.00 d         m      elasticnode02 
root@ip-172-31-63-200:/opt/elasticsearch-1.4.4# 

Step 10. Putting some sample indices for testing. We have taken reference from Elasticsearch site.
You can run command from any node because the data will be put and get from both servers.

Create index:

curl -XPUT 'localhost:9200/customer?pretty'

Put information into our customer index:

curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '
{
  "name": "John Doe"
}'

List all indexes:

curl 'localhost:9200/_cat/indices?v'

Step 11. Installing useful plugin for GUI. Install the plugin in both server that is elasticnode01 and elasticnode02 .

(a) elasticsearch-head : A web front end for an Elasticsearch cluster

cd /opt/elasticsearch-1.4.4
bin/plugin --install mobz/elasticsearch-head

You can see elasticsearch-head web interface in web browser -
http://ip-address-node:9200/_plugin/head

Screenshot of elasticsearch-head.
ECS-1

(a) Bigdesk : Installing bigdesk plugin in both servers.

cd /opt/elasticsearch-1.4.4
bin/plugin --install lukas-vlcek/bigdesk

Open bigdesk in web browser -
http://ip-address-node:9200/_plugin/bigdesk/

Screenshot of elasticsearch-bigdesk.
bigdesk