Three Node Cluster Setup

GitHub

Deploy a production-ready three-node Elasticsearch cluster

45m15m reading30m lab

Project Structure

📁three-node-cluster
├── 📄docker-compose.yml
└── 📄.env

Architecture

┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│   Node One      │  │   Node Two      │  │  Node Three     │
│ 192.168.0.11    │  │ 192.168.0.27    │  │ 192.168.0.28    │
│ Master + Data   │  │ Master + Data   │  │ Master + Data   │
└────────┬────────┘  └────────┬────────┘  └────────┬────────┘
         │                    │                    │
         └────────────────────┼────────────────────┘
                              │
                    discovery.zen.ping

Download Configuration

Node One (192.168.0.11)

mkdir ~/es-node-one && cd ~/es-node-one
wget https://raw.githubusercontent.com/JinnaBalu/infinite-containers/main/elastic-stack/three-node-cluster/elasticsearch-one.yaml -O docker-compose.yml

Node Two (192.168.0.27)

mkdir ~/es-node-two && cd ~/es-node-two
wget https://raw.githubusercontent.com/JinnaBalu/infinite-containers/main/elastic-stack/three-node-cluster/elasticsearch-two.yaml -O docker-compose.yml

Node Three (192.168.0.28)

mkdir ~/es-node-three && cd ~/es-node-three
wget https://raw.githubusercontent.com/JinnaBalu/infinite-containers/main/elastic-stack/three-node-cluster/elasticsearch-three.yaml -O docker-compose.yml

Key Configuration Points

Each node has specific settings:

# Common settings across all nodes
environment:
  - cluster.name=oio-cluster
  - discovery.zen.minimum_master_nodes=2
  - discovery.zen.ping.unicast.hosts=192.168.0.11,192.168.0.27,192.168.0.28

# Node-specific
  - node.name="oio-es-one"  # Changes per node
  - network.publish_host=192.168.0.11  # Node's IP

Start the Cluster

Start nodes in order:

# On Node One
docker compose up -d

# On Node Two
docker compose up -d

# On Node Three
docker compose up -d

Verify Cluster

# Check cluster health
curl -X GET "http://192.168.0.11:9200/_cluster/health?pretty"

# List all nodes
curl -X GET "http://192.168.0.11:9200/_cat/nodes?v"

# Expected output:
# ip           heap.percent ram.percent cpu load_1m node.role master name
# 192.168.0.28           25          75   0    0.15 mdi       *      oio-es-three
# 192.168.0.11           22          72   0    0.12 mdi       -      oio-es-one
# 192.168.0.27           24          74   0    0.14 mdi       -      oio-es-two

Fault Tolerance Test

# Stop the master node
docker stop oio-elasticsearch-three

# Check new master election (wait 30 seconds)
curl -X GET "http://192.168.0.11:9200/_cluster/health?pretty"

Lab: Deploy a Three Node Cluster

  1. 1 Download the configuration files for all three nodes
  2. 2 Start Node One and verify Elasticsearch is running
  3. 3 Start Node Two and Node Three, then check cluster health
  4. 4 Run GET _cat/nodes?v and confirm all three nodes are visible
  5. 5 Stop the master node and observe automatic master re-election
  6. 6 Restart the stopped node and verify it rejoins the cluster

Next Steps

Discussion