Before you dig into reading this guide, have you tried asking OpsGPT what this log means? You’ll receive a customized analysis of your log.
Try OpsGPT now for step-by-step guidance and tailored insights into your OpenSearch operation.
Briefly, this error occurs when OpenSearch is attempting to upgrade the version of your index templates. This process involves updating some templates and removing others. To resolve this issue, ensure that you have a backup of your current templates before the upgrade. If there are templates that you don’t want to be removed, you can manually update them to the new version. Also, check the OpenSearch logs for any specific errors related to the template upgrade process. Lastly, ensure that your OpenSearch cluster has sufficient resources to handle the upgrade process.
For a complete solution to your to your search operation, try for free AutoOps for Elasticsearch & OpenSearch . With AutoOps and Opster’s proactive support, you don’t have to worry about your search operation – we take charge of it. Get improved performance & stability with less hardware.
This guide will help you check for common problems that cause the log ” Starting template upgrade to version {}; {} templates will be updated and {} will be removed ” to appear. To understand the issues related to this log, read the explanation below about the following OpenSearch concepts: cluster, upgrade, template, version, metadata.
Overview
An OpenSearch cluster consists of a number of servers (nodes) working together as one. Clustering is a technology which enables OpenSearch to scale up to hundreds of nodes that together are able to store many terabytes of data and respond coherently to large numbers of requests at the same time.
Search or indexing requests will usually be load-balanced across the OpenSearch data nodes, and the node that receives the request will relay requests to other nodes as necessary and coordinate the response back to the user.
Notes and good things to know
The key elements to clustering are:
Cluster State – Refers to information about which indices are in the cluster, their data mappings and other information that must be shared between all the nodes to ensure that all operations across the cluster are coherent.
Master Node – Each cluster must elect a single master node responsible for coordinating the cluster and ensuring that each node contains an up-to-date copy of the cluster state.
Cluster Formation – OpenSearch requires a set of configurations to determine how the cluster is formed, which nodes can join the cluster, and how the nodes collectively elect a master node responsible for controlling the cluster state. These configurations are usually held in the opensearch.yml config file, environment variables on the node, or within the cluster state.
Node Roles – In small clusters it is common for all nodes to fill all roles; all nodes can store data, become master nodes or process ingestion pipelines. However as the cluster grows, it is common to allocate specific roles to specific nodes in order to simplify configuration and to make operation more efficient. In particular, it is common to define a limited number of dedicated master nodes.
Replication – Data may be replicated across a number of data nodes. This means that if one node goes down, data is not lost. It also means that a search request can be dealt with by more than one node.
Common problems
Many OpenSearch problems are caused by operations which place an excessive burden on the cluster because they require an excessive amount of information to be held and transmitted between the nodes as part of the cluster state. For example:
- Shards too small
- Too many fields (field explosion)
Problems may also be caused by inadequate configurations causing situations where the OpenSearch cluster is unable to safely elect a Master node. These type problems include:
- Master node not discovered
- Split brain problem
Backups
Because OpenSearch is a clustered technology, it is not sufficient to have backups of each node’s data directory. This is because the backups will have been made at different times and so there may not be complete coherency between them. As such, the only way to backup an OpenSearch cluster is through the use of snapshots, which contain the full picture of an index at any one time.
Cluster resilience
When designing an OpenSearch cluster, it is important to think about cluster resilience. In particular – what happens when a single node goes down? And for larger clusters where several nodes may share common services such as a network or power supply – what happens if that network or power supply goes down? This is where it is useful to ensure that the master eligible nodes are spread across availability zones, and to use shard allocation awareness to ensure that shards are spread across different racks or availability zones in your data center.
Quick links
- Overview
- What should I check before upgrading versions?
- How to perform offline upgrades – full cluster restart upgrades
- How to perform online upgrades – rolling restart upgrades
- Common problems and important points
- Easily upgrade versions
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:
- How to Migrate from Elasticsearch to OpenSearch
- How to migrate from Elasticsearch to OpenSearch for versions after 7.10
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:
- Disable shard allocation
- Stop all OpenSearch nodes and upgrade them
- Upgrade any plugins
- Start the OpenSearch cluster
- Re-enable shard allocation
- Upgrade client libraries to new version
- Restart master eligible nodes
- 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.
- 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.
- Disable unnecessary indexing
Wherever possible, you should stop all indexing processes to increase the cluster’s stability.
- 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).
- Stop OpenSearch
Stop OpenSearch before moving on to the next step.
- Upgrade OpenSearch
The method used to upgrade will depend upon your installation method.
- Upgrade plugins
OpenSearch will not start if the plugin is not the same version as OpenSearch.
- Start OpenSearch
Start OpenSearch before moving on to the next step.
- Re-enable shard allocation
Using the command given below.
- Check that the upgraded node has rejoined the cluster
Using the command below, you can check how many nodes are in the cluster.
- 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.
- 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.
Easily upgrade versions with OMC
To upgrade OpenSearch versions without risking data loss, you can use the free Opster Management Console. The OMC enables version upgrades with no downtime and upgrading from significantly older versions to new ones at the click of a button, completely for free.
Log Context
Log “Starting template upgrade to version {}; {} templates will be updated and {} will be removed” classname is TemplateUpgradeService.java.
We extracted the following from OpenSearch source code for those seeking an in-depth context :
lastTemplateMetadata = templates; Optional; Set >> changes = calculateTemplateChanges(templates); if (changes.isPresent()) { if (upgradesInProgress.compareAndSet(0; changes.get().v1().size() + changes.get().v2().size() + 1)) { logger.info("Starting template upgrade to version {}; {} templates will be updated and {} will be removed"; Version.CURRENT; changes.get().v1().size(); changes.get().v2().size()); assert threadPool.getThreadContext().isSystemContext();