Setup a Multi-Node Elasticsearch Cluster

Hands-On Lab

 

Photo of Myles Young

Myles Young

BigData Training Architect II in Content

Length

01:30:00

Difficulty

Intermediate

What makes Elasticsearch so appropriate for big data storage, search, and analytics is the fact that it is, well, elastic. Elasticsearch is infinitely scalable, so it can operate as a single node cluster or a one thousand node cluster. In this hands-on lab, we will be showing how to configure Elasticsearch to form a cluster of multiple nodes. In this case, we will be creating a cluster of only 3 nodes, but the procedure is the same for small and large clusters alike.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Setup a Multi-Node Elasticsearch Cluster

Introduction

What makes Elasticsearch so appropriate for big data storage, search, and analytics is the fact that it is, well, elastic. Elasticsearch is infinitely scalable, so it can operate as a single node cluster or a one thousand node cluster. In this hands-on lab, we will be showing how to configure Elasticsearch to form a cluster of multiple nodes. In this case, we will be creating a cluster of only 3 nodes, but the procedure is the same for small and large clusters alike.

Solution

  1. Begin by logging in to the lab servers using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS
  2. Become the root user:

    sudo su -

> Note: It is helpful to log in to each of the lab servers in separate tabs in your terminal application.

Bind Elasticsearch to the local and site-local addresses

  1. Edit the file /etc/elasticsearch/elasticsearch.yml and change the line:

    #network.host: 192.168.0.1

    To:

    network.host: [_site_, _local_]
  2. Repeat for each node.

Configure the discovery hosts array for the cluster

  1. Edit the file /etc/elasticsearch/elasticsearch.yml and change the line:

    #discovery.zen.ping.unicast.hosts: ["host1", "host2"]

    To:

    discovery.zen.ping.unicast.hosts: ["node1_private_ip", "node2_private_ip", "node3_private_ip"]

    Be sure to replace the IP placeholders in the array to your node's private IPs.

  2. Repeat for each node.

Set the minimum master nodes

  1. Edit the file /etc/elasticsearch/elasticsearch.yml and change the line:

    #discovery.zen.minimum_master_nodes

    To:

    discovery.zen.minimum_master_nodes: 2
  2. Repeat for each node.

Start Elasticsearch and verify cluster formation

  1. Start Elasticsearch:

    systemctl start elasticsearch
  2. Repeat for each node.

  3. Then, verify that the three nodes formed a single cluster with:

    curl localhost:9200/_cat/nodes?v

Conclusion

Congratulations — you've completed this hands-on lab!