Setting Up Elasticsearch Cluster Replication: 4 Easy Methods

on Data Integration • January 3rd, 2022 • Write for Hevo

ELASTICSEARCH CLUSTER REPLICATION- Featured Image

Are you trying to derive deeper insights by replicating your data to Elasticsearch Cluster? Well, you have landed in the right place. Now, it has become easier to replicate data to Elasticsearch Cluster.

This article will give you a comprehensive guide to Elasticsearch and its various applications. You will also explore various methods to set up your Elasticsearch Cluster Replication with their pros and cons. In the end, you will be in the position to choose the best method based on your requirements. Read along to know more about these methods.

Table of Contents

Prerequisites

You will have a much easier time understanding the ways for setting up the Elasticsearch Cluster Replication if you have gone through the following aspects:

  • An active Elasticsearch account.
  • Working knowledge of Elasticsearch.
  • A clear understanding of the data that needs to be transferred.

What is Elasticsearch?

Elasticsearch Logo: Elasticsearch Cluster Replication
Image Source: Wikipedia

Elasticsearch is a distributed, open-source search & analytics engine built on Apache Lucene and developed in Java. At its core, Elasticsearch is a server that can process JSON requests & return JSON data. Elasticsearch allows you to store, search, & analyze huge volumes of data quickly & in real-time & returns answers in milliseconds. It uses a structure based on documents instead of tables & schemas and comes with extensive REST APIs for storing & searching data. Its backend components include Cluster, Node, Shards & Replicas. One of the most famous tech stacks consists of ELK Stack where ELK stands for Elastic, Logstash, Beats & Kibana. Below are the primary use cases of Elasticsearch:- 

  • Application Search 
  • Website Search 
  • Enterprise Search 
  • Logging & Log Analytics
  • Security Analytics
  • Business Analytics 
  • Infrastructure metrics & container monitoring

To know more about Elasticsearch, visit this link.

Applications of Elasticsearch Cluster Replication

Replication of data is one of the most important & necessary features demanded in today’s world. In Elasticsearch, there are multiple ways to replicate clusters to ensure the uninterrupted availability of data. Key data is stored in various clusters across ES infrastructure and it’s imperative to be able to retrieve data from a certain cluster should it go down for any reason while preserving service continuity. 

Following are some useful Applications of Elasticsearch Cluster Replication:-

  • Disaster Recovery
  • Data Locality
  • Centralized Reporting
  • Server Performance

1) Disaster Recovery

This is the need of any application running in crowded environments or non-crowded environments. It is important to recover for applications under disasters like unnatural disruption, cyber-attacks, etc. ES has always provided a solution for that in the previous versions & the most reliable one in the latest version in the technique known as Cross-Cluster Replication or CCR.   

2) Data Locality

It means the availability of data close to the required station. For example, a product catalog or any reference data that usually gets accessed around the globe needs to get replicated to multiple places so that it might get accessed easily & quickly. Data needs to be available at a central place so that it might be accessed from anywhere in the world. 

3) Centralized Reporting

Elasticsearch provides a flexible replicating system that allows data to get replicated from multiple clusters & get aggregated to one central node to be available for anyone to see centralized reporting. Many Organizations need centralized reporting including SuperMarkets, Banks, Post Offices where data is present in a scattered form at branch level & then needs to be aggregated for centralized reporting & decision making. 

4) Server Performance

Data Replication usually boosts the Server Performance as well. As whole data is not kept or present on a single server, it is kept on different servers hence the load on each server or node is balanced which results in the performance-boosting of the server. 

Methods to Set up Elasticsearch Cluster Replication

Method 1: Using Snapshots to Set Up Elasticsearch Cluster Replication

The Snapshot method would require you to save the chosen cluster in a different location. This method also provides a cloud backup of the data. However, it doesn’t allow you to restore and backup data in real-time. Also, built-in delay can cause users to lose valuable data.

Method 2: Using Cross-Cluster Replication (CCR) to Set Up Elasticsearch Cluster Replication

This method would require you to have a license that includes Cross-Cluster Replication (CCR). This method requires a lot of configurations and continuous monitoring. This is a time-consuming exercise and would need you to invest in Engineering Bandwidth.

Method 3: Using Multi-Cluster Load Balancer to Set Up Elasticsearch Cluster Replication

This method is achieved by using an Elasticsearch “Coordinating only node” which is also known as “client node”. These nodes help in processing incoming HTTP requests and redirecting operations to other nodes. This method would also require you to invest in Engineering Bandwidth.

Method 4: Using Hevo to Set Up Elasticsearch Cluster Replication

Hevo Data, an Automated Data Pipeline provides you with a hassle-free solution to perform the Elasticsearch Database Replication with an easy-to-use no-code interface. Hevo is fully managed and completely automates the process of not only replicating data from Elasticsearch but also enriching the data and transforming it into an analysis-ready form without having to write a single line of code.

Hevo’s fault-tolerant Data Pipeline offers a faster way to move your data from Elasticsearch and 100+ other data sources(including 40+ free data sources) into Data Warehouses, Databases, BI Tools, or any other destination of your choice. Hevo will take full charge of the data replication process, allowing you to focus on key business activities.

Methods to Set Up Elasticsearch Cluster Replication

There are many ways of replicating data to Elasticsearch Cluster. Here, you are going to look into 4 popular methods. In the end, you will have a good understanding of each of these methods. Below are the 4 methods that you can use to set up Elasticsearch Cluster Replication:

Method 1: Using Snapshots to Set Up Elasticsearch Cluster Replication

Firstly, the Snapshot method ensures that the data on a chosen cluster is replicated and saved in a different location. In this case, the data is backed up to an external file system, like S3, GCS, or any other backend repository that has an official plugin.

The primary disadvantage of the Snapshot method is that the data is not backed up and restored in real-time. The built-in delay can cause users to lose valuable data collected between Snapshots. 

The advantage of this method is that users gain a cloud backup of the data. Should both the primary and secondary clusters crash, users can still access their data in the external file system (minus whatever data was collected in the time since the last Snapshot) and restore it in a new cluster.

Method 2: Using Cross-Cluster Replication (CCR) to Set Up Elasticsearch Cluster Replication

This methodology of Cluster Replication was not available before Elasticsearch 6.7.0 version & replication was done using other methods & third-party technologies which used to be very cumbersome ways to replicate data. With Cross Clustering implemented natively, it has now become a very useful solution with many advantages like comprehensive error handling, availability of APIs which can help in better usage of replication. Elasticsearch also provides User Interface in Kibana which helps in managing & monitoring CCR. 

Elasticsearch Cross cluster replication: Elasticsearch Cluster Replication
Image Source: Elasticsearch

In CCR, the indices in clusters are replicated to preserve the data in them. The replicated cluster is called the remote cluster, while the cluster with the backup data is known as the local cluster.

CCR is designed around an active-passive index model. An index in one Elasticsearch cluster can be configured to replicate changes from an index in another Elasticsearch cluster. The index that is replicating changes is termed a “follower index” and the index being replicated from is termed the “leader index”.

Setting Up Cross-Cluster Replication

To set up Cross-Cluster Replication, the following are the prerequisites:- 

  • A license on both clusters that include cross-cluster replication. You can start your free trial using this link.
  • Need some privileges including read_ccr, monitor & read privileges for the leader index on the remote cluster. The privileges can be accessed & changed using the following link.
  • Similarly, you need some privileges like manage_ccr, monitor, read, write & manage_follow_index to configure remote clusters and follower indices on the local cluster. You can configure local cluster privileges using the following link.     
  • An index on the remote cluster contains the data needed for replication. 
Connecting to a Remote Cluster

To replicate an index on a remote cluster (Cluster A) to a local cluster (Cluster B), you configure Cluster A as a remote on Cluster B. 

Connecting to a remote cluster:  Elasticsearch Cluster Replication
Image Source: Elastic Guide

To configure a remote cluster from Stack Management in Kibana:

  1. Select Remote Clusters from the side navigation.
  2. Specify the IP address or hostname of the remote cluster (ClusterB), followed by the transport port of the remote cluster (defaults to 9300). For example, 192.168.1.1:9300.

Further steps included to complete the replication process are:- 

  • Enabling soft deletes on leader indices.
  • Creating a follower index to replicate a specific index.
  • Creating an auto-follow pattern to replicate time-series indices.

Further details on the above-mentioned processes can be found out at the following link. 

Method 3: Using Multi-Cluster Load Balancer to Set Up Elasticsearch Cluster Replication

This can be achieved by using an Elasticsearch Coordinating only node, also known as the client node on the same machine as Kibana. This is the easiest & most effective way to set up a load balancer for ES nodes to use with Kibana. 

Elasticsearch Coordinating only nodes are essentially load-balancers that act in a very smart way. They process incoming HTTP requests, redirect operations to the other nodes in the cluster as needed, and gather and return the results. For more information on this process, you can have a look at the following link

The following steps are required to balance the load on multiple Elasticsearch nodes:- 

  1. Install Elasticsearch on the same machine as Kibana.
  2. The node must be configured as a Coordinating only node. In elasticsearch.yml file, the following changes must be made:- 
node.master: false
node.data: false
node.ingest: false
  1. Configure the client node to join the Elasticsearch Cluster. In elasticsearch.yml, set the cluster.name to the name of your cluster.
cluster.name: “my_cluster”

      4.   Make the following changes in the file as well:-

network.host: localhost
http.port: 9200

     5.    Lastly, make sure that Kibana is configured to point to the local client node. 

elasticsearch.hosts: ["http://localhost:9200"]

Method 4: Using Hevo to Set Up Elasticsearch Cluster Replication

Elasticsearch Replication: Hevo Logo
Image Source

Hevo Data, an Automated No Code Data Pipeline, helps you replicate data from Elasticsearch to Data Warehouses, Business Intelligence Tools, or any other destination of your choice in a completely hassle-free & automated manner. Hevo connects to your Elasticsearch cluster using the Elasticsearch Transport Client and synchronizes the data available in the cluster to your preferred data warehouse using indices. Furthermore, Hevo’s fully managed Data Pipleine caters to both Generic Elaticsearh and AWs Elasticsearch Data Replications.

To learn more, check out Hevo’s documentation for Elasticsearch Database Replication.

Check out what makes Hevo amazing:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled in a secure, consistent manner with zero data loss.
  • Auto Schema Mapping: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data from Elasticsearch and replicates it to the destination schema.
  • Quick Setup: Hevo with its automated features, can be set up in minimal time. Moreover, with its simple and interactive UI, it is extremely easy for new customers to work on and perform operations.
  • Transformations: Hevo provides preload transformations through Python code. It also allows you to run transformation code for each event in the Data Pipelines you set up. You need to edit the event object’s properties received in the transform method as a parameter to carry out the transformation. Hevo also offers drag and drop transformations like Date and Control Functions, JSON, and Event Manipulation to name a few. These can be configured and tested before putting them to use for aggregation.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.

Use Hevo’s no-code data pipeline to replicate data from Elasticearch to a destination of your choice in a seamless and automated way. Try our 14-day full feature access free trial.

Get Started with Hevo for Free

Example of Elasticsearch Cluster Replication

You can leverage Elasticsearch Cluster Replicas to provide high failover and availability. A higher number of replicas can also come in handy for faster searches. Here is an example to illustrate how you can update replica count using Elasticsearch Cluster Replication:

Update Replica Count

PUT /api-logs/_settings?pretty
{
    "index" : {
        "number_of_replicas" : 2
    }
}

Conclusion

Cluster Replication is an important feature introduced in Elasticsearch after version 6.7.0 that resolved a very critical issue. These methods mentioned above for Elasticsearch Cluster Replication need some technical expertise depending upon the recovery management plans & load management plans. Moreover, you will need to implement it manually, which will consume your time & resources and is error-prone. You will also need full working knowledge of the backend tools to successfully implement the in-house Data Replication mechanism.

Hevo Data provides an Automated No-code Data Pipeline that empowers you to overcome the above-mentioned limitations. Hevo caters to 100+ data sources (including 40+ free sources) and can seamlessly perform Elasticearch Replication in real-time. Hevo’s fault-tolerant architecture ensures a consistent and secure replication of your Oracle data. It will make your life easier and make data replication hassle-free.

Visit our Website to Explore Hevo

Want to take Hevo for a spin? Sign up for a 14-day free trial and experience the feature-rich Hevo suite firsthand.

Share your thoughts on Elasticsearch Cluster Replication in the comments!

No-code Data Pipeline for your Data Warehouse