multiple servers

Production Elasticsearch Cluster

Using Ansible to Set Up a Production Elasticsearch Cluster

Did you know that Ansible can be a good installer for Elasticsearch?

Elasticsearch has been making the popularity because it is a software that can be downloaded for free. It is an open source search server that is commonly used for real-time distribution search and analysis of data.

Basically, Elasticsearch has been deployed across multiple servers as a cluster that’s guaranteed to have the best performance, stability, and scalability. While it is undeniable how good Elasticsearch in deploying multiple servers, it has been a question for everyone on how compatible it is with Ansible.

Recently, when developers release the new version of Elasticsearch 2.0.0 a completely new Ansible role also has been released. This shows that these two definitely complements each other.

In today’s blog, we will prove more on how you can use Ansible to set up a production Elasticsearch PHP tutorial. Let’s check this out!

Knowing Elasticsearch and Ansible

Elasticsearch was based on Lucene as is a distributed search and analytics engine. In was written in Java language and is under the Apache license. Its official clients can be found and available in Java, .NET, Groovy and Python and other more programming languages.

While Ansible is known to be as a configuration management system written in Python using the declarative markup language for its configuration description.  Basically, the program is used to automate the process of installing and setting the software— which will be Elasticsearch.

In most cases, it is often used with a Linux-based node, although the program can also support using Windows. It also supports Python 2.4 and other higher onboard via SSH or WinRM connection.  For a piece of more thorough information on Ansible, you can check or search for Ansible tutorial PDF.

Basically, these two programs can work together just like in using Ansible to set up an Elasticsearch cluster. Today, let’s find out how exactly you can do that.

Knowing Elasticsearch and Ansible

Steps in Setting up

First and foremost, you need to make sure that you have already downloaded the ansible-elasticsearch playbook. Doing so will help you in defining a few host groups and assign appropriate roles to each group.

Afterward, you can then begin with this Elasticsearch PHP tutorial.

1.Update site.yml

You have to edit the master Playbook file, which is the site/yml, to a map three of different elasticsearch roles to three different Ansible host group. Doing so will allow you to create a dedicated master, data, and master-eligible/data Elasticsearch nodes by adding hosts to its appropriate nodes.

2.Map Elasticsearch dedicated to the master role to the group

Right at the bottom part of the file is a map. You can then map the dedicated master elasticsearch role to the elasticsearch_master_nodes option group by adding these few lines:

  • yml— Dedicated master node
  • – { role: elasticsearch, es_instance_name: “node1”, es_config: { “node01, node02, node03”, “_tun0_, _local_”, “production”, false,  http.port: 9200, transport.tcp.port: 9300, false, node.master: true, bootstrap.mlockall: true } }


    es_major_version: “2.x”

    es_version: “2.2.1”

    es_heap_size: “2g”

    es_cluster_name: “production”

These were just a given sample, you can then continue mapping everything to its appropriate master or group with their equivalent nodes.

3.Save and exit

Once you are done with mapping everything to its assigned groups you can then save changes and exit. Most likely, you will have to map three roles to Ansible so make sure there’s three of them completed. Although, you can still add more Elasticsearch roles and host group mappings later.

4.Update host inventory file

At this moment, it is for sure that the new Elasticsearch roles have been mapped to its assigned host groups, then it is time for you to create different types of Elasticsearch nodes by adding the hosts to is appropriate to host groups.

To do this, you have to edit the inventory file and add the three groups that correspond to the mappings that you have defined.

Once done, you can start to create an Elasticsearch cluster by running the playbook. But you must also verify the cluster status first before you get to enjoy the program.

Apart from Ansible, you can also make use of Weka. Try to see more Weka Java tutorial online.