0
0
Elasticsearchquery~5 mins

Rolling upgrades in Elasticsearch

Choose your learning style9 modes available
Introduction

Rolling upgrades let you update your Elasticsearch cluster without stopping it. This keeps your search service running smoothly while you improve it.

You want to update Elasticsearch to a newer version without downtime.
You need to fix bugs or add features but can't stop your search service.
You want to upgrade nodes one by one to keep the cluster healthy.
You want to test new versions gradually before full upgrade.
You want to avoid losing data or search availability during upgrades.
Syntax
Elasticsearch
1. Disable shard allocation
PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}

2. Upgrade one node at a time
- Stop the node
- Upgrade Elasticsearch version
- Start the node

3. Enable shard allocation
PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "all"
  }
}

Use the cluster settings API to control shard allocation during upgrade.

Upgrade nodes one by one to keep the cluster stable.

Examples
This command stops Elasticsearch from moving data shards around. It helps keep data safe while upgrading nodes.
Elasticsearch
PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}
Stop the first node, upgrade its software, then start it again.
Elasticsearch
# Upgrade node 1
sudo systemctl stop elasticsearch
# Upgrade Elasticsearch software
sudo systemctl start elasticsearch
After upgrading all nodes, this command lets Elasticsearch move shards again to balance the cluster.
Elasticsearch
PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "all"
  }
}
Sample Program

This example shows the main commands to do a rolling upgrade. First, stop shard moves. Then upgrade each node safely. Finally, allow shard moves again.

Elasticsearch
# Step 1: Disable shard allocation
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}'

# Step 2: Upgrade nodes one by one (example for node1)
sudo systemctl stop elasticsearch
# (Perform upgrade commands here)
sudo systemctl start elasticsearch

# Repeat Step 2 for each node

# Step 3: Enable shard allocation
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
  "transient": {
    "cluster.routing.allocation.enable": "all"
  }
}'
OutputSuccess
Important Notes

Always check cluster health before and after each node upgrade.

Rolling upgrades avoid downtime but take more time than full cluster restart.

Make sure your Elasticsearch version supports rolling upgrades between your current and target versions.

Summary

Rolling upgrades update Elasticsearch nodes one by one without stopping the whole cluster.

Disable shard allocation before upgrading to keep data safe.

Enable shard allocation after all nodes are upgraded to rebalance data.