Elastic Search Cluster Deployment and Planning

Author

Reads 1.2K

Computer server in data center room
Credit: pexels.com, Computer server in data center room

An Elastic Search cluster is a group of nodes that work together to index, store, and retrieve data. Each node in the cluster plays a specific role, such as master, data, or client node.

A well-planned Elastic Search cluster deployment is crucial for optimal performance and scalability. A master node is responsible for managing the cluster and keeping track of the nodes and their roles.

The number of nodes in a cluster depends on the size and complexity of the data. For example, a small cluster might consist of 3-5 nodes, while a large cluster could have hundreds of nodes.

To ensure efficient data distribution, nodes are typically divided into shards, with each shard containing a portion of the data. This allows for easier scaling and maintenance of the cluster.

You might enjoy: Azure Cluster

What Is an Elastic Search Cluster

An Elasticsearch cluster is a group of one or more Elasticsearch nodes that are connected together, allowing for the distribution of tasks, searching, and indexing across all nodes.

Credit: youtube.com, 3.8 ElasticSearch Training - Monitor Cluster health

The nodes in an Elasticsearch cluster can be assigned different jobs or responsibilities, including data nodes, master nodes, client nodes, and ingest nodes.

Data nodes store data and execute data-related operations such as search and aggregation.

Master nodes are in charge of cluster-wide management and configuration actions, such as adding and removing nodes.

Client nodes forward cluster requests to the master node and data-related requests to data nodes.

Ingest nodes are for pre-processing documents before indexing.

By default, each node is automatically assigned a unique identifier, or name, used for management purposes.

A single Elasticsearch node will form a new single-node cluster entitled “elasticsearch” when installed.

These nodes need to be able to identify each other to connect.

Here's a breakdown of the different types of nodes in an Elasticsearch cluster:

  • Data nodes: stores data and executes data-related operations such as search and aggregation
  • Master nodes: in charge of cluster-wide management and configuration actions such as adding and removing nodes
  • Client nodes: forwards cluster requests to the master node and data-related requests to data nodes
  • Ingest nodes: for pre-processing documents before indexing

Setting Up Your Cluster

Setting up your Elasticsearch cluster requires careful planning and configuration.

To begin, ensure you have a clear understanding of quorum-based decision-making, which is essential for the cluster to remain functional. The quorum is based on the voting configuration, and these votes are only counted for primary-eligible nodes, whose votes should count for the election to happen.

Credit: youtube.com, Setup Elasticsearch Cluster + Kibana 8.x

For a cluster to remain functional, at least half of the votes + 1 should remain alive or participating in the cluster. This means that if there are three or four primary-eligible nodes, the cluster can tolerate one of them being unavailable.

The first step in setting up your cluster is to edit the configuration file. Ensure you have your first node's configuration set correctly, and generate the CA files and its HTP and transport security files needed for TLS configuration.

You'll need to repeat this process for each node in your cluster, making sure to copy the files from the previous node and set the proper permission and ownership of the files.

Here's a summary of the steps to set up each node:

Once you've set up your nodes, you'll need to configure network discovery settings. This can be done with the `discovery.seed_hosts` parameter, which must contain the list of all master-eligible nodes in your cluster. You'll also need to define the list of all master-eligible nodes of your cluster using the `cluster.initial_master_nodes` parameter.

Installation and Configuration

Credit: youtube.com, How to Set Up an Elasticsearch Cluster

To set up an Elasticsearch cluster, you'll need to start by planning the cluster. This involves deciding on the number and type of nodes you'll need, as well as their roles within the cluster. You can use a configuration management tool like Puppet or Ansible to automate the process, but for this example, we'll be showing you how to manually set up a cluster consisting of one master node and two data nodes, all on Ubuntu 16.04 instances on AWS EC2 running in the same VPC.

The security group should be configured to enable access from anywhere using SSH and TCP 5601 (Kibana). You'll also need to install Elasticsearch on each node, which involves adding Elastic's signing key, updating your repositories, and installing Elasticsearch. This process should be repeated on all your servers.

Here's a summary of the initial steps:

  • Plan the cluster, deciding on the number and type of nodes and their roles.
  • Configure the security group to enable access from anywhere using SSH and TCP 5601 (Kibana).
  • Install Elasticsearch on each node by adding the signing key, updating repositories, and installing Elasticsearch.

Keep in mind that this is just the beginning of the process, and you'll need to configure the Elasticsearch cluster and set up discovery to get everything up and running smoothly.

Setting Up Your Third System

From above of pair of small brilliant hearts made of elastic hair ties on pale pink surface
Credit: pexels.com, From above of pair of small brilliant hearts made of elastic hair ties on pale pink surface

You'll be glad to know that setting up the third node is a breeze, as most of the work is already done with the first two nodes.

The third node is pupnode172 (192.168.40.172), and you'll be repeating the steps done for the second node. This means you can skip ahead to steps 9-14 from the second node setup.

Just remember to replace the IP addresses, hostnames, and paths with the correct ones for the third node. For example, in your /etc/elasticsearch/elasticsearch.yml file, the IP address should be 192.168.40.172.

To make things easier, you can refer to the steps for the second node, as they are identical. Just copy the files from the first node to the third node, set the proper permissions and ownership, and make sure the xpack.security.http.ssl.keystore.path, xpack.security.transport.ssl.keystore.path, and xpack.security.transport.ssl.truststore.path are set to the correct paths.

Here's a quick checklist of the steps to follow:

  1. Copy the files from the first node to the third node using scp.
  2. Set the proper permissions and ownership of the files.
  3. Verify that the xpack.security.http.ssl.keystore.path, xpack.security.transport.ssl.keystore.path, and xpack.security.transport.ssl.truststore.path are set to the correct paths.

Installing

To install an Elasticsearch cluster, you can use a configuration management tool like Puppet or Ansible to automate the process. However, for this example, we'll manually set up a cluster consisting of one master node and two data nodes on Ubuntu 16.04 instances on AWS EC2 running in the same VPC.

Contemporary computer on support between telecommunication racks and cabinets in modern data center
Credit: pexels.com, Contemporary computer on support between telecommunication racks and cabinets in modern data center

You'll need to add Elastic's signing key to verify the downloaded package. This step can be skipped if you've already installed packages from Elastic. Next, add the repository definition to your system.

To install Elasticsearch, you'll need to update your repositories and install the package. It's essential to save the password generated during the installation process, as it will be needed to set up the other nodes in the cluster later on.

Here are the steps to install Elasticsearch:

  1. Add Elastic's signing key to verify the downloaded package.
  2. Add the repository definition to your system.
  3. Update your repositories and install Elasticsearch.

Make sure to update your repositories and install Elasticsearch on all your servers. This will ensure a consistent installation process across your cluster.

Configuring

To configure your Elasticsearch cluster, you'll need to set up the nodes so they can connect and communicate with each other.

First, open the Elasticsearch configuration file for each node. This file contains multiple settings for different sections, so browse through it and enter the following configurations, replacing the IPs with your node IPs.

High-tech server rack in a secure data center with network cables and hardware components.
Credit: pexels.com, High-tech server rack in a secure data center with network cables and hardware components.

The Elasticsearch configuration file is quite long, so make sure to enter the correct settings for each node. You'll need to set the cluster.initial_master_nodes and network.host variables correctly.

You'll also need to set the discovery.seed_hosts variable, which should contain the list of all master-eligible nodes in your cluster. This will allow your nodes to connect to each other.

For the xpack.security settings, you'll need to empty the three settings by running a command, as you didn't set a password when generating your certificates and PEM files.

Here are the specific settings you'll need to configure:

  • node.name: a unique name for each node
  • cluster.name: the same value for all nodes in the cluster
  • network.host: the IP address or hostname of the node
  • node.roles: based on the role of the node, such as master or data
  • index.number_of_shards: based on the data volume and query load
  • index.number_of_replicas: based on the redundancy requirements

Here's a sample configuration file summarizing these points:

Remember to add the cluster.initial_master_nodes parameter to the configuration file only once, when you start your production cluster for the first time. After the cluster has been successfully bootstrapped, this setting must be removed from the configuration file.

JVM Heap Size Adjustment

Adjusting the JVM heap size is crucial for Elasticsearch's optimal performance. The default JVM heap size is set to 1 GB, but this can be adjusted.

Credit: youtube.com, How to Increase the Heap Size of JVM

To ensure Elasticsearch has enough operational leeway, the default JVM heap size should be adjusted. The maximum heap size should be set up to 50% of your RAM, but no more than 32GB due to Java pointer inefficiency in larger heaps.

Elastic recommends making the maximum and minimum heap size identical for optimal performance. These values can be configured using the Xmx and Xms settings in the jvm.options file.

Next, open the /etc/default/elasticsearch file to make the necessary changes.

Increasing Open File Descriptor Limit

Increasing the open file descriptor limit is crucial for Elasticsearch, as it uses a large amount of file descriptors. The common recommendation for this setting is 65,536 and higher.

On Debian and RPM systems, the default settings are already configured to suit this requirement, but you can fine-tune it if needed.

Verify Logs and Runtime Status

To verify the logs and runtime status of your Elasticsearch cluster, start by checking the logs. You can use the netstat command to check the ports and processes running for Elasticsearch.

Credit: youtube.com, Elasticsearch Local Development Shows Yellow Health Status

You can also check the log file located in /var/log/elasticsearch/, where the file name is the cluster name. For example, if your cluster name is "default", the log file will be named "default.log".

The logs will show you the last 10 lines of your Elasticsearch node logs, giving you an idea of what's happening in real-time. Check the Elasticsearch documentation for more information on node roles.

By monitoring the logs, you can troubleshoot any issues that may arise and ensure your cluster is running smoothly.

APIs and Health

Elasticsearch Cluster APIs are incredibly useful for managing and monitoring your cluster. They allow you to define which node to call using its internal ID, name, or address.

To get a general idea of your cluster's health, you can use the Cluster Health API. This API provides a quick snapshot of your cluster's status.

The response from the Cluster Health API gives you a clear picture of your cluster's health, allowing you to gauge its overall well-being.

APIs

Detailed view of server racks with glowing lights in a data center environment.
Credit: pexels.com, Detailed view of server racks with glowing lights in a data center environment.

APIs are a crucial part of managing and monitoring your Elasticsearch cluster.

Elasticsearch supports a large number of cluster-specific API operations, allowing you to define which Elasticsearch node to call using either the internal node ID, its name or its address.

You can use APIs to manage and monitor your Elasticsearch cluster, with most APIs allowing you to specify which node to call.

For example, you can use the internal node ID to call a specific node, or use its name or address for more flexibility.

Elasticsearch cluster APIs allow you to perform various operations, including defining which node to call.

Reading the blog post on advanced usage of cluster APIs can provide more information on how to use these APIs effectively.

Health

The health of an API is crucial for its performance and reliability. Cluster Health APIs can provide general information on the cluster and gauge its health.

You can use the Cluster Health API to see if your cluster is running smoothly. This API can be used to see general info on the cluster and gauge its health.

Monitoring the health of your API is essential for detecting potential issues early on.

A unique perspective: Python Api Elasticsearch

Pending Tasks and Enrollment

Credit: youtube.com, AWS re:Invent 2018: Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1)

In an Elasticsearch cluster, you can track changes at the cluster level using the Pending Cluster Tasks API. This API returns a list of tasks, including updated mapping, failed sharding, and index creation.

To join a cluster, you can use the enrollment token approach, introduced in Elasticsearch version 8.x. This approach simplifies the process of setting up a cluster by automating the creation of private and public keys and certificates.

To use the enrollment token approach, you need to run a command on the first node to create a token. Then, on the nodes you want to join or create a cluster, you run a different command that will manage the setup of private and public keys and certificates for you.

Here are the settings you need to configure in your elasticsearch.yml file to use the enrollment token approach:

  • cluster.initial_master_nodes
  • http.host
  • transport.host
  • network.host
  • discovery.seed_hosts

Pending Tasks

When it comes to managing pending tasks, it's essential to understand what they are and how to track them.

Computer server in data center room
Credit: pexels.com, Computer server in data center room

The Pending Cluster Tasks API tracks changes at the cluster level, including updated mapping, failed sharding, and index creation.

This API can return a list of tasks with a simple GET request.

Enrolling in a system with pending tasks can be a complex process, but knowing what to expect can make it more manageable.

The Pending Cluster Tasks API can handle tasks such as updated mapping, failed sharding, and index creation, making it a crucial tool for system administrators.

A list of tasks can be retrieved using a GET request to the Pending Cluster Tasks API.

Understanding how to track and manage pending tasks can save time and reduce stress in the enrollment process.

Joining with Enrollment Token

In Elasticsearch 8.x and later, you can create a cluster using tokens, making it easier to manage cluster setup. This approach also allows you to join a node to an existing cluster.

To create a token, you'll need to run a command on the first node during installation. The installation output log will reveal the necessary command. For example, you might run `elasticsearch --create-enrollment-token cluster`.

Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.
Credit: pexels.com, Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.

On nodes you want to join or create a cluster, you'll need to run a different command. This command will generate private and public keys, as well as certificates for cluster and client communication. The keys and certificates will be stored in /etc/elasticsearch/certs.

Make sure to set up the following parameters in your elasticsearch.yml configuration file:

  • cluster.initial_master_nodes
  • http.host
  • transport.host
  • network.host
  • discovery.seed_hosts

Verifying and Tuning

Verifying the cluster setup is crucial to ensure everything is running smoothly. You can do this by sending a GET request to the ‘_cluster/health’ endpoint.

The response should show the status of the cluster as ‘green’, the number of nodes in the cluster, and the number of data and master-eligible nodes.

To verify the health of the cluster, you can use the Elasticsearch /_cat/nodes API, which can be accessed by sending a curl request to any of the nodes in the cluster. This is where you can use the generated file /etc/elasticsearch/certs/elasticsearch-ca.pem to request a secure connection with your Elasticsearch nodes.

Credit: youtube.com, Elasticsearch performance tuning (2 Solutions!!)

The output will define the current primary node and the roles assigned to each node, which can be one of the following: c (cold node), d (data node), f (frozen node), h (hot node), i (ingest node), l (machine learning node), m (primary-eligible node), r (remote cluster client node), s (content node), t (transform node), v (voting-only node), w (warm node), or – (coordinating node only).

Here is a list of node roles:

  • c (cold node)
  • d (data node)
  • f (frozen node)
  • h (hot node)
  • i (ingest node)
  • l (machine learning node)
  • m (primary-eligible node)
  • r (remote cluster client node)
  • s (content node)
  • t (transform node)
  • v (voting-only node)
  • w (warm node)
  • – (coordinating node only)

After verifying the cluster setup, it's essential to tune the cluster for optimal performance. The JVM heap size should be set to no more than 50% of the available RAM, but at most 30.5GB.

Verifying

Verifying your Elasticsearch cluster is crucial to ensure it's running smoothly. You can verify the cluster setup by sending a GET request to the ‘_cluster/health’ endpoint.

The response should show the status of the cluster as ‘green’, the number of nodes in the cluster, and the number of data and master-eligible nodes. This will give you a quick overview of your cluster's health.

Networking cables plugged into a patch panel, showcasing data center connectivity.
Credit: pexels.com, Networking cables plugged into a patch panel, showcasing data center connectivity.

To collect information on your cluster nodes, you can use the API to retrieve data for a single node or multiple nodes. This will provide you with detailed information about each node.

Information about ingest processors should appear in the API response, showing the different types of processors running on each node. This can be helpful in troubleshooting or optimizing your cluster.

Checking the logs is another way to verify your cluster's status. You can use the netstat command to check the ports and processes running on each node, and then check the log file to see if everything is running accordingly.

To check the logs, you can use the command `tail -n 10 /var/log/elasticsearch.log` to view the last 10 lines of the Elasticsearch node logs. This will give you a quick snapshot of any issues or errors that may be occurring.

Here is a list of node roles that you may encounter in your Elasticsearch cluster:

  • c (cold node)
  • d (data node)
  • f (frozen node)
  • h (hot node)
  • i (ingest node)
  • l (machine learning node)
  • m (primary-eligible node)
  • r (remote cluster client node)
  • s (content node)
  • t (transform node)
  • v (voting-only node)
  • w (warm node)
  • – (coordinating node only)

This list provides a brief description of each node role, which can be helpful in understanding your cluster's configuration.

Tuning

A modern data center featuring a computer setup with monitor and keyboard, emphasizing technology infrastructure.
Credit: pexels.com, A modern data center featuring a computer setup with monitor and keyboard, emphasizing technology infrastructure.

Tuning is a crucial step in ensuring your cluster runs smoothly and efficiently.

Setting the JVM heap size to no more than 50% of the available RAM is a good starting point. This will help prevent memory issues and keep your cluster running smoothly.

The 'indices.fielddata.cache.size' parameter should be set to limit the amount of memory used for field data cache. You can limit it using either an absolute size, such as 10GB, or a percentage value of the available heap, such as 10%.

The 'indices.breaker.total.limit' parameter is also important to set, as it limits the amount of memory used by all circuit breakers. This will help prevent memory issues and keep your cluster running smoothly.

Setting the 'thread_pool.search.size' and 'thread_pool.search.queue_size' parameters based on the query load is also crucial. This will help ensure that your cluster can handle the query load without any issues.

For another approach, see: Elasticsearch Indices

Deploying and Planning

Deploying an Elasticsearch cluster requires careful planning to ensure it meets your data volume, query load, and redundancy requirements. You should have at least one master-eligible node, with three recommended for production clusters.

Credit: youtube.com, Elasticsearch Tutorials | Creating An Elasticsearch cluster and Deploy Application | Cloudlearnhub.

To plan the cluster's size and structure, consider the data volume and query load. The number of data nodes can be scaled up based on these factors.

A simple Elasticsearch cluster can be deployed with one Elasticsearch node, but for production workloads, you'll likely want to allocate more storage and have more control over it. Consider allocating a persistent volume of more than 1GiB for storage.

A ClusterIP Service is automatically created for your cluster, which is necessary to make requests to the Elasticsearch API. To do this, you'll need to get the credentials, which can be done by defaulting to a user named elastic with the password stored inside a Kubernetes secret.

Readers also liked: Elasticsearch Tiered Storage

Deploy an

Deploying an Elasticsearch cluster is a straightforward process that can be completed in a few minutes. It involves creating and managing Kubernetes resources to achieve the desired state of the cluster.

The operator automatically creates all the necessary resources, including a ClusterIP Service, which is automatically created for your cluster. This service allows you to make requests to the Elasticsearch API.

Close-up of network server showing organized cable management and patch panels in a data center.
Credit: pexels.com, Close-up of network server showing organized cable management and patch panels in a data center.

To deploy a simple Elasticsearch cluster, you can use the provided quickstart guide, which allocates a persistent volume of 1GiB for storage using the default storage class defined for the Kubernetes cluster. However, for production workloads, you'll likely want more control over storage allocation.

Here are the steps to deploy an Elasticsearch cluster:

1. Get the credentials for the default user elastic, which can be obtained by running `kubectl get secret quickstart-es-elastic-user -o go-template='{{.data.elastic | base64decode}}'`.

2. Request the Elasticsearch root API using the `curl` command with the `-k` flag, as shown in the quickstart guide.

Once you've completed these steps, you can access the pod's logs and check the status of your cluster using the `get` command.

Broaden your view: Elasticsearch Storage

Planning

Planning is a crucial step in deploying a cluster. It's essential to plan the cluster's size and structure based on the data volume, query load, and redundancy requirements.

The cluster should have at least one master-eligible node, and three are recommended for production clusters. Multiple data nodes are also necessary for storing data.

The number of data nodes can be scaled up based on the data volume and query load. This allows for flexibility and adaptability as the cluster grows or changes.

Frequently Asked Questions

What is a 3 node cluster?

A 3-node cluster is a high-availability setup that combines three servers to ensure continuous operation and quick recovery in case of a failure. It's often used to safeguard critical applications that require 24/7 uptime.

Cora Stoltenberg

Junior Writer

Cora Stoltenberg is a skilled writer with a passion for crafting engaging content on a wide range of topics. Her expertise spans various categories, including Search Engine Optimization (SEO) Strategies, where she provides actionable tips and insights to help businesses improve their online presence. With a keen eye for detail and a knack for simplifying complex concepts, Cora's writing is both informative and accessible to readers of all levels.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.