Rolling upgrades let you update your Elasticsearch cluster without stopping it. This keeps your search service running smoothly while you improve it.
Rolling upgrades in Elasticsearch
Start learning this pattern below
Jump into concepts and practice - no test required
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.
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "none"
}
}# Upgrade node 1 sudo systemctl stop elasticsearch # Upgrade Elasticsearch software sudo systemctl start elasticsearch
PUT /_cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "all"
}
}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.
# 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" } }'
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.
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.
Practice
rolling upgrade in Elasticsearch?Solution
Step 1: Understand rolling upgrade concept
A rolling upgrade updates nodes one at a time to keep the cluster running.Step 2: Compare options
Only To upgrade nodes one by one without stopping the entire cluster describes upgrading nodes one by one without stopping the cluster.Final Answer:
To upgrade nodes one by one without stopping the entire cluster -> Option CQuick Check:
Rolling upgrade = upgrade nodes individually [OK]
- Thinking all nodes upgrade at once
- Confusing rolling upgrade with cluster shutdown
- Assuming data is deleted during upgrade
Solution
Step 1: Identify correct syntax to disable shard allocation
The correct way is to update cluster settings with PUT and set allocation to "none".Step 2: Check options
Only PUT /_cluster/settings {"persistent": {"cluster.routing.allocation.enable": "none"}} uses the correct HTTP method, endpoint, and JSON body.Final Answer:
PUT /_cluster/settings {"persistent": {"cluster.routing.allocation.enable": "none"}} -> Option AQuick Check:
Disable shard allocation = PUT cluster settings with allocation none [OK]
- Using wrong HTTP method like POST or GET
- Wrong endpoint or missing persistent key
- Trying to delete shards instead of disabling allocation
1. Disable shard allocation
2. Upgrade node 1
3. Upgrade node 2
4. Enable shard allocation
What is the expected cluster behavior after step 4?
Solution
Step 1: Understand shard allocation states
Disabling shard allocation prevents shard movement during upgrade; enabling it allows rebalancing.Step 2: Analyze cluster behavior after enabling allocation
After enabling, the cluster redistributes shards to balance load.Final Answer:
The cluster will rebalance shards across all nodes -> Option BQuick Check:
Enable allocation = rebalance shards [OK]
- Thinking cluster stops accepting data
- Assuming shards get deleted
- Believing shards remain stuck after enabling allocation
Solution
Step 1: Understand shard allocation role during upgrade
Disabling allocation prevents shards from moving and keeps data safe during node restarts.Step 2: Consequence of not disabling allocation
If not disabled, shards may relocate while nodes restart, risking data loss or cluster instability.Final Answer:
Shards may move during upgrade causing data loss or instability -> Option AQuick Check:
Not disabling allocation risks shard movement and instability [OK]
- Expecting upgrade to fail with syntax error
- Assuming cluster disables allocation automatically
- Thinking upgrade is safe without disabling allocation
Solution
Step 1: Identify correct upgrade steps
Best practice is to disable shard allocation first to prevent shard moves, then upgrade nodes one by one.Step 2: Finalize upgrade process
After upgrading all nodes, enable shard allocation to rebalance shards and verify cluster health to confirm stability.Final Answer:
Disable shard allocation -> Upgrade nodes one by one -> Enable shard allocation -> Verify cluster health -> Option DQuick Check:
Disable allocation, upgrade nodes, enable allocation, check health [OK]
- Upgrading all nodes at once causing downtime
- Enabling allocation before upgrade completion
- Restarting cluster unnecessarily
