Elasticsearch OpenSearch Upgrade

By Opster Team

Updated: Mar 19, 2024

| 5 min read

Quick links

Overview

Upgrade refers to migrating your OpenSearch version to a newer version. The process of updating distributed systems like OpenSearch can be intricate, given the extensive data quantities, the involvement of numerous nodes, and the diverse configurations that may exist within your cluster.

An upgrade of an existing cluster can be done in two ways: through a rolling upgrade and through a full cluster restart. The benefit of a rolling upgrade is having zero downtime.

Bear in mind that any changes to your system could lead to data loss if the instructions are not adhered to accurately. Thoroughly test and strategize your upgrade, and ensure you create a backup of your data prior to executing any updates.

For Elasticsearch to OpenSearch migration, check out these guides:

What should I check before upgrading versions?

OpenSearch nodes cannot be downgraded after upgrading. Before starting the upgrade process you should: 

  • Check the deprecation log and resolve any issues.
  • Review the breaking changes to make sure you know of any functionalities which may changes or disappear. This would mainly affect node configuration, index mappings and templates, and cluster settings.
  • Check the ES plugin compatibility to ensure they are compatible with the new version.
  • Set up a test environment to test the upgrade process in a testing or staging environment first before upgrading your production cluster to avoid any issues.
  • Take a backup and snapshots from your data, as the only way to “reverse” a failed upgrade is to create a new cluster with the old version and restore the data from snapshots.

How to perform offline upgrades – full cluster restart upgrades

A complete cluster restart upgrade involves simultaneously stopping all OpenSearch nodes, updating them, and subsequently restarting each one. Inevitably, this upgrade approach will necessitate the downtime of your OpenSearch cluster throughout the entire process.

Generally, offline upgrades are simpler than online ones because there’s no need to handle a cluster with varying node versions concurrently.

The steps are:

  1. Disable shard allocation 
  2. Stop all OpenSearch nodes and upgrade them 
  3. Upgrade any plugins
  4. Start the OpenSearch cluster
  5. Re-enable shard allocation 
  6. Upgrade client libraries to new version
  7. Restart master eligible nodes
  8. Restart non-master eligible nodes

Keep in mind that during a full cluster restart, the master nodes need to be initiated prior to the non-master nodes. This is essential for allowing the master nodes to establish the cluster so that other nodes can join, which is in contrast to a rolling upstart where non-master nodes should be upgraded before the master nodes.

How to perform online upgrades – rolling restart upgrades

A rolling restart upgrade allows for updating a cluster without incurring any downtime. In this scenario, every node is sequentially upgraded and rebooted, without ever halting the entire OpenSearch cluster.

Rolling restart upgrades cannot be performed when there is a change in MAJOR versions. For this reason, when performing a rolling restart upgrade between major versions, it is imperative to ALWAYS utilize the most recent minor version as an intermediary step for upgrading to the subsequent major version.

How to upgrade nodes in a rolling upgrade


The process for upgrading your nodes is as follows, upgrading all NON master-eligible nodes first.

  1. Make sure your cluster status is green and stable

    Ensure that all replicas are available so that shutting down the node will not cause data loss.

  2. Disable unnecessary indexing

    Wherever possible, you should stop all indexing processes to increase the cluster’s stability.

  3. Disable shard allocation

    It is important to disable shard allocation so that when you stop a node for upgrade the cluster does not reallocate shards to another node. (See command below).

  4. Stop OpenSearch

    Stop OpenSearch before moving on to the next step.

  5. Upgrade OpenSearch

    The method used to upgrade will depend upon your installation method.

  6. Upgrade plugins

    OpenSearch will not start if the plugin is not the same version as OpenSearch.

  7. Start OpenSearch

    Start OpenSearch before moving on to the next step.

  8. Re-enable shard allocation

    Using the command given below.

  9. Check that the upgraded node has rejoined the cluster

    Using the command below, you can check how many nodes are in the cluster.

  10. Wait for cluster status to turn green

    The command provided below will also show you the progress of the shard recovery process on the upgraded node, until the cluster reaches a green state.

  11. Repeat

    Repeat the full process above for each node.

To disable shard allocation, run:

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "primaries"
  }
}

To re-enable shard allocation, run:

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": null
  }
}

Get cluster status and see how many nodes are in the cluster using:

GET _cluster/health

Common problems and important points

  • The major problem with upgrades is version incompatibility. OpenSearch supports rolling upgrades only between minor versions. You need to make sure to go through the official documentation to see if your cluster can support a rolling upgrade, otherwise a complete reindexing is required.
  • Once you upgrade an OpenSearch node, a rollback cannot be done. You need to make sure to backup your data before an upgrade.
  • OpenSearch continuously removes or deprecates some of its features with every release, so keep an eye on the change logs of each version before planning an upgrade. 
  • While doing a rolling upgrade, it is important to disable shard allocation before stopping a node and enable the shard allocation when node is upgraded and restarted. This process helps in avoiding unnecessary IO load in the cluster.

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?