Saturday, November 25, 2017

Elastic Search - Clustering

In the previous post, we saw how to install and run an elasticsearch instance. In this post, we will see how to cluster it. Clustering is required to support high availability and we will be seeing how to cluster 3 nodes of elasticsearch.

  1. Follow my post to install and run an elastic search node. Repeat it to create multiple nodes on different machines / VM in the same network or multiple nodes on the same machine running on different ports. Running multiple nodes on the same machine comes in handy while developing and researching and can be done by changing the http.port value as described in the next step

  2. Navigate to the config folder inside elasticsearch install location of each of the nodes ie: C:\Deploy\elasticsearch-1.7.2\config. Open the elasticsearch.yml file and update the following settings
    • cluster.name:  clusterXXXPool  -- Name of the cluster to be same across all nodes
    • node.name: "NodeXXX" -- Individual node name
    • bootstrap.mlockall: true -- To lock the memory
    • http.port: 9200 -- Port on which elasticsearch will run
    • discovery.zen.minimum_master_nodes: 2 -- Creates a cluster with minimum 2 master nodes
    • discovery.zen.ping.timeout: 10s
    • discovery.zen.ping.unicast.hosts:["Node1_IP:Port",”Node2_IP:Port","Node3_IP:Port"] -- Lists the node names in cluster

    These are the few settings that can be applied. The config file itself has comments for each setting and provides a good self-documentation if you want to learn more about it.

  3. Restart all the elasticsearch services that are part of the cluster for the settings to be applied.

  4. Use the following URLs on the browser to check cluster related settings
    • NodeIP:Port/_cluster/health – Cluster Health
    • NodeIP:Port/_cat/nodes – Nodes in the cluster
    • NodeIP:Port/_cat/master – Master in the cluster
    • NodeIP:Port/_cluster/settings – Settings of the cluster
    • NodeIP:Port/_cluster/nodes/stats – Statistics of each Node

    To verify if the cluster was set up properly and check its health and status, try to bring down one of the nodes by stopping the service and seeing the output of the above commands.

  5. You can also install Head Plugin to visualize the Cluster Health, Indices and Shards.



Sunday, October 29, 2017

Elasticsearch

Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data so you can discover the expected and uncover the unexpected. This is a snippet about Elasticsearch from their site https://www.elastic.co/products/elasticsearch. It is a highly efficient index store which offers a great performance.


I have used Elasticsearch for two use cases ie: searching and logging. This blog post will guide you through installing Elasticsearch on a windows machine. As an extension to this post, I will write about clustering and other use cases like ELK in future posts.

Installation
  1. Elasticsearch requires Java Runtime Environment. So go ahead and install it on your Windows Machine.

  2. After installing JRE, navigate to Control Panel --> System and Security --> Advanced System Properties --> Advanced Tab --> Environment Variables and create a new System Variable JAVA_HOME and set and the value to the JRE path.


  3. Download Elasticsearch from https://www.elastic.co/downloads/elasticsearch and extract it to a folder say C:/Deploy/ElasticSearchvx.x.

  4. Open a command prompt in admin mode and change directory to the above folder and run the command service install.This installs Elasticsearch as a service. You can also run it by executing the command elasticsearch.bat 






  5. Open Services window by entering services.msc in Run (Windows + R) and ensure that Elasticsearch service is running.




  6. Navigate to localhost:9200 on your browser and you must see an Elasticsearch status page if everything went well.





  7. You can install Sense Extension for Chrome to interact with elasticsearch
This concludes the simple guide to install Elasticsearch on a Windows Machine as a service. Please share your comments and queries and stay tuned for more posts on this series.