Simple configuration of a two host ElasticSearch Cluster

Introduction

The following article describes the process of setting up a simple two host elastic search cluster using the unicast discovery method.

Pre-Requisites

This assumes you have installed two Elastic Search hosts built and you would like to configure them to work together in a simple elastic cluster.

Proposed Scenario

For the purposes of this article I am going to create a cluster named MyElasticCluster which will be made up of two hosts esa.kitswebkitchen.com and esb.kitswebkitchen.com. Both hosts are able to hold data and both can be elected as masters. I am not going to use the multicast discover method.

elasticSearchSimple

Configuration

The configuration of the cluster is very simple.

You need to edit the elasticsearch yml configuration file on each of the hosts (esa and esb)

Firstly let’s make a copy of the file to a file called elasticsearch.yml.bak for safe keeping


mv /etc/elasticsearch/config/elasticsearch.yml /etc/elasticsearch/config/elasticsearch.yml.bak

Once we have backed up we can begin editing the file so on each of the two cluster hosts lets fire up the file in vi.


vi /etc/elasticsearch/config/elasticsearch.yml

We want our files to look like this:

For host esa.kitswebkitchen.com


cluster.name: OurCluster
node.name: "esa"
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["esb.kitswebkitchen.com"]

and for host esb.kitswebkitchen.com


cluster.name: OurCluster
node.name: "esb"
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["esa.kitswebkitchen.com"]

This should enable both hosts to function in the cluster when started. Below is an overview of the cluster with the elasticsearch head gui which we can see the two hosts appearing in the cluster.

simple_elastic_cluster_running

I hope this is useful for those of you testing their first simple cluster.

Comments are closed.