Bird
Raised Fist0
Elasticsearchquery~10 mins

Rolling upgrades in Elasticsearch - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - Rolling upgrades
Start: Current Cluster Version
Select Node for Upgrade
Take Node Out of Cluster
Upgrade Node Software
Restart Node with New Version
Node Rejoins Cluster
Verify Cluster Health
Repeat for Next Node
All Nodes Upgraded
Upgrade Complete
Rolling upgrades upgrade one node at a time to keep the cluster running without downtime.
Execution Sample
Elasticsearch
PUT /_cluster/settings
{
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}
Disables shard allocation temporarily to safely upgrade a node.
Execution Table
StepActionNode StateCluster StateResult
1Select node1 for upgradenode1 activeAll nodes activeReady to upgrade node1
2Disable shard allocationnode1 activeAllocation disabledPrevents shard movement
3Stop node1node1 stoppedCluster yellowNode1 offline, cluster still running
4Upgrade node1 softwarenode1 stoppedCluster yellowNode1 upgraded
5Start node1 with new versionnode1 active (new version)Cluster recoveringNode1 rejoins cluster
6Enable shard allocationnode1 activeAllocation enabledCluster rebalances shards
7Verify cluster healthAll nodes activeCluster greenNode1 upgrade successful
8Repeat steps 1-7 for node2node2 activeCluster greenNode2 upgraded
9Repeat steps 1-7 for node3node3 activeCluster greenNode3 upgraded
10All nodes upgradedAll nodes active (new version)Cluster greenRolling upgrade complete
💡 All nodes upgraded one by one, cluster remains available throughout
Variable Tracker
VariableStartAfter Step 3After Step 5After Step 7After Step 10
node1 stateactivestoppedactive (new version)active (new version)active (new version)
cluster allocationenableddisableddisabledenabledenabled
cluster healthgreenyellowyellowgreengreen
Key Moments - 3 Insights
Why do we disable shard allocation before stopping a node?
Disabling shard allocation (see step 2 in execution_table) prevents shards from moving around during the node upgrade, avoiding extra load and instability.
What happens to cluster health when a node is stopped?
Cluster health changes from green to yellow (step 3) because one node is offline, but the cluster remains available.
Why upgrade nodes one at a time instead of all at once?
Upgrading one node at a time (steps 1-9) keeps the cluster running and avoids downtime, ensuring continuous availability.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the cluster health after stopping node1 (step 3)?
Agreen
Byellow
Cred
Dunknown
💡 Hint
Check the 'Cluster State' column at step 3 in the execution_table.
At which step is shard allocation re-enabled during the upgrade of node1?
AStep 2
BStep 4
CStep 6
DStep 8
💡 Hint
Look for 'Enable shard allocation' action in the execution_table.
If shard allocation was not disabled before stopping a node, what would likely happen?
AShards would move causing extra load and instability
BCluster health would remain green
CNode would upgrade faster
DNothing changes
💡 Hint
Refer to the key_moments explanation about disabling shard allocation.
Concept Snapshot
Rolling upgrades upgrade one node at a time.
Disable shard allocation before stopping a node.
Stop, upgrade, restart node with new version.
Re-enable allocation and verify cluster health.
Repeat for each node until all upgraded.
Cluster stays available during the process.
Full Transcript
Rolling upgrades in Elasticsearch mean upgrading nodes one by one to keep the cluster running without downtime. The process starts by disabling shard allocation to prevent shards from moving during the upgrade. Then, a node is stopped, upgraded, and restarted with the new version. After the node rejoins the cluster, shard allocation is re-enabled and cluster health is checked. This process repeats for each node until all nodes are upgraded. Cluster health may temporarily degrade but remains available throughout. This method avoids downtime and keeps data safe.

Practice

(1/5)
1. What is the main purpose of performing a rolling upgrade in Elasticsearch?
easy
A. To disable the cluster permanently during upgrade
B. To upgrade all nodes simultaneously for faster updates
C. To upgrade nodes one by one without stopping the entire cluster
D. To delete old data before upgrading

Solution

  1. Step 1: Understand rolling upgrade concept

    A rolling upgrade updates nodes one at a time to keep the cluster running.
  2. 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.
  3. Final Answer:

    To upgrade nodes one by one without stopping the entire cluster -> Option C
  4. Quick Check:

    Rolling upgrade = upgrade nodes individually [OK]
Hint: Rolling upgrade means upgrading nodes one by one [OK]
Common Mistakes:
  • Thinking all nodes upgrade at once
  • Confusing rolling upgrade with cluster shutdown
  • Assuming data is deleted during upgrade
2. Which command is recommended to disable shard allocation before starting a rolling upgrade?
easy
A. PUT /_cluster/settings {"persistent": {"cluster.routing.allocation.enable": "none"}}
B. POST /_cluster/disable_shards
C. GET /_cluster/settings {"allocation": "disable"}
D. DELETE /_cluster/shards

Solution

  1. Step 1: Identify correct syntax to disable shard allocation

    The correct way is to update cluster settings with PUT and set allocation to "none".
  2. Step 2: Check options

    Only PUT /_cluster/settings {"persistent": {"cluster.routing.allocation.enable": "none"}} uses the correct HTTP method, endpoint, and JSON body.
  3. Final Answer:

    PUT /_cluster/settings {"persistent": {"cluster.routing.allocation.enable": "none"}} -> Option A
  4. Quick Check:

    Disable shard allocation = PUT cluster settings with allocation none [OK]
Hint: Use PUT with cluster settings and allocation none to disable shards [OK]
Common Mistakes:
  • Using wrong HTTP method like POST or GET
  • Wrong endpoint or missing persistent key
  • Trying to delete shards instead of disabling allocation
3. Given the following sequence during a rolling upgrade:
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?
medium
A. The cluster will stop accepting new data
B. The cluster will rebalance shards across all nodes
C. The cluster will delete old shards permanently
D. The cluster will remain unbalanced with shards stuck

Solution

  1. Step 1: Understand shard allocation states

    Disabling shard allocation prevents shard movement during upgrade; enabling it allows rebalancing.
  2. Step 2: Analyze cluster behavior after enabling allocation

    After enabling, the cluster redistributes shards to balance load.
  3. Final Answer:

    The cluster will rebalance shards across all nodes -> Option B
  4. Quick Check:

    Enable allocation = rebalance shards [OK]
Hint: Enabling shard allocation triggers shard rebalancing [OK]
Common Mistakes:
  • Thinking cluster stops accepting data
  • Assuming shards get deleted
  • Believing shards remain stuck after enabling allocation
4. You ran a rolling upgrade but forgot to disable shard allocation first. What problem might occur?
medium
A. Shards may move during upgrade causing data loss or instability
B. The upgrade will fail immediately with syntax error
C. The cluster will automatically disable allocation for you
D. Nothing happens; upgrade proceeds safely

Solution

  1. Step 1: Understand shard allocation role during upgrade

    Disabling allocation prevents shards from moving and keeps data safe during node restarts.
  2. Step 2: Consequence of not disabling allocation

    If not disabled, shards may relocate while nodes restart, risking data loss or cluster instability.
  3. Final Answer:

    Shards may move during upgrade causing data loss or instability -> Option A
  4. Quick Check:

    Not disabling allocation risks shard movement and instability [OK]
Hint: Always disable shard allocation before upgrade to avoid shard moves [OK]
Common Mistakes:
  • Expecting upgrade to fail with syntax error
  • Assuming cluster disables allocation automatically
  • Thinking upgrade is safe without disabling allocation
5. During a rolling upgrade, you want to ensure minimal downtime and data safety. Which sequence of actions is best practice?
hard
A. Upgrade all nodes simultaneously -> Disable shard allocation -> Enable shard allocation -> Restart cluster
B. Restart cluster -> Disable shard allocation -> Upgrade nodes one by one -> Enable shard allocation
C. Enable shard allocation -> Upgrade nodes one by one -> Disable shard allocation -> Verify cluster health
D. Disable shard allocation -> Upgrade nodes one by one -> Enable shard allocation -> Verify cluster health

Solution

  1. Step 1: Identify correct upgrade steps

    Best practice is to disable shard allocation first to prevent shard moves, then upgrade nodes one by one.
  2. Step 2: Finalize upgrade process

    After upgrading all nodes, enable shard allocation to rebalance shards and verify cluster health to confirm stability.
  3. Final Answer:

    Disable shard allocation -> Upgrade nodes one by one -> Enable shard allocation -> Verify cluster health -> Option D
  4. Quick Check:

    Disable allocation, upgrade nodes, enable allocation, check health [OK]
Hint: Disable allocation first, upgrade nodes, then enable allocation [OK]
Common Mistakes:
  • Upgrading all nodes at once causing downtime
  • Enabling allocation before upgrade completion
  • Restarting cluster unnecessarily