Setup An Elasticsearch Cluster – Beginners Guide

 

Install Elasticsearch

1. Download the elasticsearch installation file

Note: At the time of writing, the release of elasticsearch is 2.2.0

2. Install the downloaded package.

Note: If you have downloaded any version other than 2.2.0, change the package name accordingly.

3. Start the elasticsearch service.

4. Our node es-client-01 has elasticsearch service running and we will consider as the client node. Also, you need to set elasticsearch to start automatically on bootup. Use the following command to do that.

5. Verify the elasticsearch service by sending a HTTP request to port 9200. By default elasticsearch run on port 9200.

READ  Docker Multi-Host Networking Tutorial – Using Consul

You would see a JSON response, which looks like the following.

The above output shows the name of the node, cluster name, and few other details.

If you do not specify a node name in the configuration, elasticsearch assigns a random name on every restart.

All the elasticsearch configurations are present in elasticsearch.yml file, which is located in /etc/elasticsearch folder.

6. Now, the elasticsearch.yml file has to be edited for the configuring the node as a client node. Open the elasticsearch.ym file located in /etc/elasticsearch directory and change the configurations as follows.

The configuration file has many sections like cluster, node, paths etc.

Note: Refer this config file for all the configurations explained below.

Under the cluster section, change the cluster name parameter.

Under node section, change the node name parameter and add other parameters as shown below.

Under network section, change the “network.host” parameter. Change the IP address accordingly.

For Data Node (Elasticsearch.Yml)

Under node section, add the following. refer this for configurations.

Under network section, replace the data nodes IP address as you did for the client and master nodes.

Once you configure all the three nodes, restart the elasticsearch service on all the three nodes.

Now you will have working elasticsearch cluster.

Installing Elasticsearch GUI Plugin

Once you setup an elasticsearch cluster, you can view the cluster status on the client node(es-client-01) using the following command.

But the but is not that easy to comprehend. So you can make use of the elasticsearch head plugin to view the cluster details in the browser UI.

We will install this plugin on our client node. To install the plugin, navigate to “/usr/share/elasticsearch/bin” directory and execute the following command.

Restart the elasticsearch service for the plugin to work.

Now, if you access http://<IP&gt;:9200/_plugin/head/ in your browser, you will be able to see all the cluster details.

Wrapping Up

In this tutorial, I have explained all the steps to setup a three-node elasticsearch cluster. In the next article, I will cover more on indexing strategies for elasticsearch.

Also, you can take a look at the devops cube vagrant repository for setting up the three node cluster. Elasticsearch vagrant cluster setup

Main article at :

https://devopscube.com/how-to-setup-an-elasticsearch-cluster/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s