0
0
ElasticsearchHow-ToBeginner · 4 min read

How to Add a Node to an Elasticsearch Cluster Easily

To add a node to an Elasticsearch cluster, configure the new node's elasticsearch.yml file with the same cluster.name as the existing cluster and set unique node.name. Then start the Elasticsearch service on the new node, and it will join the cluster automatically.
📐

Syntax

To add a node to an Elasticsearch cluster, update the elasticsearch.yml configuration file on the new node with these key settings:

  • cluster.name: Must match the existing cluster's name.
  • node.name: Unique name for the new node.
  • network.host: IP address or hostname of the new node.
  • discovery.seed_hosts: List of existing cluster nodes to discover.
  • cluster.initial_master_nodes: List of master-eligible nodes (only needed on first cluster start).

After configuring, start the Elasticsearch service on the new node to join the cluster.

yaml
cluster.name: my-elasticsearch-cluster
node.name: node-2
network.host: 192.168.1.2
discovery.seed_hosts: ["192.168.1.1", "192.168.1.3"]
cluster.initial_master_nodes: ["node-1"]
💻

Example

This example shows how to configure a new node to join an existing cluster named my-elasticsearch-cluster. The new node has the name node-2 and IP 192.168.1.2. It discovers other nodes at 192.168.1.1 and 192.168.1.3.

bash
cluster.name: my-elasticsearch-cluster
node.name: node-2
network.host: 192.168.1.2
discovery.seed_hosts: ["192.168.1.1", "192.168.1.3"]

# Start Elasticsearch service on the new node
sudo systemctl start elasticsearch

# Check cluster health
curl -X GET "http://192.168.1.1:9200/_cluster/health?pretty"
Output
{ "cluster_name" : "my-elasticsearch-cluster", "status" : "green", "number_of_nodes" : 3, "number_of_data_nodes" : 3, "active_primary_shards" : 5, "active_shards" : 10, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }
⚠️

Common Pitfalls

Common mistakes when adding a node to an Elasticsearch cluster include:

  • Not matching the cluster.name exactly, causing the node to form a separate cluster.
  • Using duplicate node.name values, which can confuse the cluster.
  • Incorrect discovery.seed_hosts that prevent the new node from finding existing nodes.
  • Firewall or network issues blocking communication between nodes.
  • Forgetting to start the Elasticsearch service after configuration changes.

Always verify network connectivity and check Elasticsearch logs for errors.

yaml
## Wrong: Different cluster name
cluster.name: wrong-cluster

## Right: Matching cluster name
cluster.name: my-elasticsearch-cluster
📊

Quick Reference

SettingDescriptionExample
cluster.nameName of the Elasticsearch clustermy-elasticsearch-cluster
node.nameUnique name for the nodenode-2
network.hostIP address or hostname of the node192.168.1.2
discovery.seed_hostsList of nodes to discover cluster["192.168.1.1", "192.168.1.3"]
cluster.initial_master_nodesMaster-eligible nodes for initial cluster boot["node-1"]

Key Takeaways

Ensure the new node's cluster.name matches the existing cluster exactly.
Assign a unique node.name to avoid conflicts in the cluster.
Configure discovery.seed_hosts with reachable existing nodes for discovery.
Start the Elasticsearch service on the new node after configuration.
Check network connectivity and Elasticsearch logs if the node does not join.