"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/docs/reference/upgrade.asciidoc" (29 Dec 2021, 3324 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming AsciiDoc format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Rolling upgrades

A rolling upgrade allows an Elasticsearch cluster to be upgraded one node at a time so upgrading does not interrupt service. Running multiple versions of Elasticsearch in the same cluster beyond the duration of an upgrade is not supported, as shards cannot be replicated from upgraded nodes to nodes running the older version.

Rolling upgrades can be performed between minor versions. Elasticsearch 6.x supports rolling upgrades from Elasticsearch 5.6. Upgrading from earlier 5.x versions requires a full cluster restart. You must reindex to upgrade from versions prior to 5.x.

Warning
If the {es} {security-features} are enabled on your 5.x cluster, before you can do a rolling upgrade you must encrypt the internode-communication with SSL/TLS, which requires a full cluster restart. For more information about this requirement and the associated bootstrap check, see [bootstrap-checks-tls].
Warning
The format used for the internal indices used by Kibana and {xpack} has changed in 6.x. When upgrading from 5.6 to 6.x, these internal indices have to be {stack-ref}/upgrading-elastic-stack.html#upgrade-internal-indices[upgraded] before the rolling upgrade procedure can start. Otherwise the upgraded node will refuse to join the cluster.

To perform a rolling upgrade:

  1. Disable shard allocation.

    When you shut down a node, the allocation process waits for index.unassigned.node_left.delayed_timeout (by default, one minute) before starting to replicate the shards on that node to other nodes in the cluster, which can involve a lot of I/O. Since the node is shortly going to be restarted, this I/O is unnecessary. You can avoid racing the clock by disabling allocation of replicas before shutting down the node:

    PUT _cluster/settings
    {
      "persistent": {
        "cluster.routing.allocation.enable": "primaries"
      }
    }
  2. Stop non-essential indexing and perform a synced flush. (Optional)

    While you can continue indexing during the upgrade, shard recovery is much faster if you temporarily stop non-essential indexing and perform a synced-flush.

    POST _flush/synced

    When you perform a synced flush, check the response to make sure there are no failures. Synced flush operations that fail due to pending indexing operations are listed in the response body, although the request itself still returns a 200 OK status. If there are failures, reissue the request.

  3. Stop any machine learning jobs that are running.

    If your {ml} indices were created earlier than the previous major version, they must be reindexed. In those circumstances, there must be no machine learning jobs running during the upgrade.

    In all other circumstances, there is no requirement to close your {ml} jobs. There are, however, advantages to doing so. If you choose to leave your jobs running during the upgrade, they are affected when you stop the {ml} nodes. The jobs move to another {ml} node and restore the model states. This scenario has the least disruption to the active {ml} jobs but incurs the highest load on the cluster.

    To close all {ml} jobs before you upgrade, see {ml-docs}/stopping-ml.html[Stopping {ml}]. This method persists the model state at the moment of closure, which means that when you open your jobs after the upgrade, they use the exact same model. This scenario takes the most time, however, especially if you have many jobs or jobs with large model states.

    To temporarily halt the tasks associated with your {ml} jobs and {dfeeds} and prevent new jobs from opening, use the set upgrade mode API:

    POST _ml/set_upgrade_mode?enabled=true

    This method does not persist the absolute latest model state, rather it uses the last model state that was automatically saved. By halting the tasks, you avoid incurring the cost of managing active jobs during the upgrade and it’s quicker than stopping {dfeeds} and closing jobs.

  4. Shut down a single node.

    • If you are running Elasticsearch with systemd:

      sudo systemctl stop elasticsearch.service
    • If you are running Elasticsearch with SysV init:

      sudo -i service elasticsearch stop
    • If you are running Elasticsearch as a daemon:

      kill $(cat pid)
  5. Upgrade the node you shut down.

    Important
    If you are upgrading from a version prior to 6.3 and use {xpack} then you must remove the {xpack} plugin before upgrading with bin/elasticsearch-plugin remove x-pack. As of 6.3, {xpack} is included in the default distribution so make sure to upgrade to that one. If you upgrade without removing the {xpack} plugin first the node will fail to start. If you did not remove the {xpack} plugin and the node fails to start then you must downgrade to your previous version, remove {xpack}, and then upgrade again. In general downgrading is not supported but in this particular case it is.

    To upgrade using a Debian or RPM package:

    • Use rpm or dpkg to install the new package. All files are installed in the appropriate location for the operating system and Elasticsearch config files are not overwritten.

    To upgrade using a zip or compressed tarball:

    1. Extract the zip or tarball to a new directory. This is critical if you are not using external config and data directories.

    2. Set the ES_PATH_CONF environment variable to specify the location of your external config directory and jvm.options file. If you are not using an external config directory, copy your old configuration over to the new installation.

    3. Set path.data in config/elasticsearch.yml to point to your external data directory. If you are not using an external data directory, copy your old data directory over to the new installation.

      Important
      If you use {monitoring}, re-use the data directory when you upgrade {es}. Monitoring identifies unique {es} nodes by using the persistent UUID, which is stored in the data directory.
    4. Set path.logs in config/elasticsearch.yml to point to the location where you want to store your logs. If you do not specify this setting, logs are stored in the directory you extracted the archive to.

    When you extract the zip or tarball packages, the elasticsearch-n.n.n directory contains the Elasticsearch config, data, and logs directories.

    We recommend moving these directories out of the Elasticsearch directory so that there is no chance of deleting them when you upgrade Elasticsearch. To specify the new locations, use the ES_PATH_CONF environment variable and the path.data and path.logs settings. For more information, see Important Elasticsearch configuration.

    The Debian and RPM packages place these directories in the appropriate place for each operating system. In production, we recommend installing using the deb or rpm package.

  6. Upgrade any plugins.

    Use the elasticsearch-plugin script to install the upgraded version of each installed Elasticsearch plugin. All plugins must be upgraded when you upgrade a node.

  7. Start the upgraded node.

    Start the newly-upgraded node and confirm that it joins the cluster by checking the log file or by submitting a _cat/nodes request:

    GET _cat/nodes
  8. Reenable shard allocation.

    Once the node has joined the cluster, remove the cluster.routing.allocation.enable setting to enable shard allocation and start using the node:

    PUT _cluster/settings
    {
      "persistent": {
        "cluster.routing.allocation.enable": null
      }
    }
  9. Wait for the node to recover.

    Before upgrading the next node, wait for the cluster to finish shard allocation. You can check progress by submitting a _cat/health request:

    GET _cat/health?v

    Wait for the status column to switch to green. Once the node is green, all primary and replica shards have been allocated.

    Important

    During a rolling upgrade, primary shards assigned to a node running the new version cannot have their replicas assigned to a node with the old version. The new version might have a different data format that is not understood by the old version.

    If it is not possible to assign the replica shards to another node (there is only one upgraded node in the cluster), the replica shards remain unassigned and status stays yellow.

    In this case, you can proceed once there are no initializing or relocating shards (check the init and relo columns).

    As soon as another node is upgraded, the replicas can be assigned and the status will change to green.

    Shards that were not sync-flushed might take longer to recover. You can monitor the recovery status of individual shards by submitting a _cat/recovery request:

    GET _cat/recovery

    If you stopped indexing, it is safe to resume indexing as soon as recovery completes.

  10. Repeat

    When the node has recovered and the cluster is stable, repeat these steps for each node that needs to be updated. You can monitor the health of the cluster with a _cat/health request:

    GET /_cat/health?v

    And check which nodes have been upgraded with a _cat/nodes request:

    GET /_cat/nodes?h=ip,name,version&v
  11. Restart machine learning jobs.

    If you closed all {ml} jobs before the upgrade, you must open them. Use {kib} or the open jobs API.

    Alternatively, if you temporarily halted the tasks associated with your {ml} jobs, use the set upgrade mode API to return them to active states:

    POST _ml/set_upgrade_mode?enabled=false
Important

During a rolling upgrade, the cluster continues to operate normally. However, any new functionality is disabled or operates in a backward compatible mode until all nodes in the cluster are upgraded. New functionality becomes operational once the upgrade is complete and all nodes are running the new version. Once that has happened, there’s no way to return to operating in a backward compatible mode. Nodes running the previous major version will not be allowed to join the fully-updated cluster.

In the unlikely case of a network malfunction during the upgrade process that isolates all remaining old nodes from the cluster, you must take the old nodes offline and upgrade them to enable them to join the cluster.

Full cluster restart upgrade

A full cluster restart upgrade requires that you shut all nodes in the cluster down, upgrade them, and restart the cluster. A full cluster restart was required when upgrading to major versions prior to 6.x. Elasticsearch 6.x supports rolling upgrades from Elasticsearch 5.6. Upgrading to 6.x from earlier versions requires a full cluster restart. See the Upgrade paths table to verify the type of upgrade you need to perform.

To perform a full cluster restart upgrade:

  1. Disable shard allocation.

    When you shut down a node, the allocation process waits for index.unassigned.node_left.delayed_timeout (by default, one minute) before starting to replicate the shards on that node to other nodes in the cluster, which can involve a lot of I/O. Since the node is shortly going to be restarted, this I/O is unnecessary. You can avoid racing the clock by disabling allocation of replicas before shutting down the node:

    PUT _cluster/settings
    {
      "persistent": {
        "cluster.routing.allocation.enable": "primaries"
      }
    }
  2. Stop indexing and perform a synced flush.

    Performing a synced-flush speeds up shard recovery.

    POST _flush/synced

    When you perform a synced flush, check the response to make sure there are no failures. Synced flush operations that fail due to pending indexing operations are listed in the response body, although the request itself still returns a 200 OK status. If there are failures, reissue the request.

  3. Stop any machine learning jobs that are running.

    If your {ml} indices were created earlier than the previous major version, they must be reindexed. In those circumstances, there must be no machine learning jobs running during the upgrade.

    In all other circumstances, there is no requirement to close your {ml} jobs. There are, however, advantages to doing so. If you choose to leave your jobs running during the upgrade, they are affected when you stop the {ml} nodes. The jobs move to another {ml} node and restore the model states. This scenario has the least disruption to the active {ml} jobs but incurs the highest load on the cluster.

    To close all {ml} jobs before you upgrade, see {ml-docs}/stopping-ml.html[Stopping {ml}]. This method persists the model state at the moment of closure, which means that when you open your jobs after the upgrade, they use the exact same model. This scenario takes the most time, however, especially if you have many jobs or jobs with large model states.

    To temporarily halt the tasks associated with your {ml} jobs and {dfeeds} and prevent new jobs from opening, use the set upgrade mode API:

    POST _ml/set_upgrade_mode?enabled=true

    This method does not persist the absolute latest model state, rather it uses the last model state that was automatically saved. By halting the tasks, you avoid incurring the cost of managing active jobs during the upgrade and it’s quicker than stopping {dfeeds} and closing jobs.

  4. Shutdown all nodes.

    • If you are running Elasticsearch with systemd:

      sudo systemctl stop elasticsearch.service
    • If you are running Elasticsearch with SysV init:

      sudo -i service elasticsearch stop
    • If you are running Elasticsearch as a daemon:

      kill $(cat pid)
  5. Upgrade all nodes.

    Important
    If you are upgrading from a version prior to 6.3 and use {xpack} then you must remove the {xpack} plugin before upgrading with bin/elasticsearch-plugin remove x-pack. As of 6.3, {xpack} is included in the default distribution so make sure to upgrade to that one. If you upgrade without removing the {xpack} plugin first the node will fail to start. If you did not remove the {xpack} plugin and the node fails to start then you must downgrade to your previous version, remove {xpack}, and then upgrade again. In general downgrading is not supported but in this particular case it is.

    To upgrade using a Debian or RPM package:

    • Use rpm or dpkg to install the new package. All files are installed in the appropriate location for the operating system and Elasticsearch config files are not overwritten.

    To upgrade using a zip or compressed tarball:

    1. Extract the zip or tarball to a new directory. This is critical if you are not using external config and data directories.

    2. Set the ES_PATH_CONF environment variable to specify the location of your external config directory and jvm.options file. If you are not using an external config directory, copy your old configuration over to the new installation.

    3. Set path.data in config/elasticsearch.yml to point to your external data directory. If you are not using an external data directory, copy your old data directory over to the new installation.

      Important
      If you use {monitoring}, re-use the data directory when you upgrade {es}. Monitoring identifies unique {es} nodes by using the persistent UUID, which is stored in the data directory.
    4. Set path.logs in config/elasticsearch.yml to point to the location where you want to store your logs. If you do not specify this setting, logs are stored in the directory you extracted the archive to.

    Tip

    When you extract the zip or tarball packages, the elasticsearch-n.n.n directory contains the Elasticsearch config, data, and logs directories.

    We recommend moving these directories out of the Elasticsearch directory so that there is no chance of deleting them when you upgrade Elasticsearch. To specify the new locations, use the ES_PATH_CONF environment variable and the path.data and path.logs settings. For more information, see Important Elasticsearch configuration.

    The Debian and RPM packages place these directories in the appropriate place for each operating system. In production, we recommend installing using the deb or rpm package.

  6. Upgrade any plugins.

    Use the elasticsearch-plugin script to install the upgraded version of each installed Elasticsearch plugin. All plugins must be upgraded when you upgrade a node.

  7. Start each upgraded node.

    If you have dedicated master nodes, start them first and wait for them to form a cluster and elect a master before proceeding with your data nodes. You can check progress by looking at the logs.

    As soon as the minimum number of master-eligible nodes have discovered each other, they form a cluster and elect a master. At that point, you can use _cat/health and _cat/nodes to monitor nodes joining the cluster:

    GET _cat/health
    
    GET _cat/nodes

    The status column returned by _cat/health shows the health of each node in the cluster: red, yellow, or green.

  8. Wait for all nodes to join the cluster and report a status of yellow.

    When a node joins the cluster, it begins to recover any primary shards that are stored locally. The _cat/health API initially reports a status of red, indicating that not all primary shards have been allocated.

    Once a node recovers its local shards, the cluster status switches to yellow, indicating that all primary shards have been recovered, but not all replica shards are allocated. This is to be expected because you have not yet reenabled allocation. Delaying the allocation of replicas until all nodes are yellow allows the master to allocate replicas to nodes that already have local shard copies.

  9. Reenable allocation.

    When all nodes have joined the cluster and recovered their primary shards, reenable allocation by restoring cluster.routing.allocation.enable to its default:

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

    Once allocation is reenabled, the cluster starts allocating replica shards to the data nodes. At this point it is safe to resume indexing and searching, but your cluster will recover more quickly if you can wait until all primary and replica shards have been successfully allocated and the status of all nodes is green.

    You can monitor progress with the _cat/health and _cat/recovery APIs:

    GET _cat/health
    
    GET _cat/recovery
  10. If you use {security} and are upgrading directly to {version} from 5.5 or earlier, you must upgrade the .security index after you restart {es}.

    Important
    Native realm users cannot authenticate until the index is upgraded. For instructions, see {stack-ref}/upgrading-elastic-stack.html#upgrade-internal-indices[Upgrading internal indices]. You also need to upgrade the .security index if you restore a pre-5.6 snapshot to a fresh 6.0 install.
  11. Restart machine learning jobs.

    If you closed all {ml} jobs before the upgrade, you must open them. Use {kib} or the open jobs API.

    Alternatively, if you temporarily halted the tasks associated with your {ml} jobs, use the set upgrade mode API to return them to active states:

    POST _ml/set_upgrade_mode?enabled=false

Reindex before upgrading

Elasticsearch can read indices created in the previous major version. Older indices must be reindexed or deleted. Elasticsearch 6.x can use indices created in Elasticsearch 5.x, but not those created in Elasticsearch 2.x or before. Elasticsearch 5.x can use indices created in Elasticsearch 2.x, but not those created in 1.x or before.

Elasticsearch nodes will fail to start if incompatible indices are present.

To upgrade an Elasticsearch 5.x cluster that contains indices created in 2.x, you must reindex or delete them before upgrading to 6.x. For more information, see Reindex in place.

To upgrade an Elasticsearch cluster running 2.x, you have two options:

  • Perform a full cluster restart upgrade to 5.6, reindex the 2.x indices, then perform a rolling upgrade to 6.x. If your Elasticsearch 2.x cluster contains indices that were created before 2.x, you must either delete or reindex them before upgrading to 5.6. For more information about upgrading from 2.x to 5.6, see Upgrading Elasticsearch in the Elasticsearch 5.6 Reference.

  • Create a new 6.x cluster and reindex from remote to import indices directly from the 2.x cluster.

To upgrade an Elasticsearch 1.x cluster, you have two options:

Upgrading time-based indices

If you use time-based indices, you likely won’t need to carry pre-5.x indices forward to 6.x. Data in time-based indices generally becomes less useful as time passes and are deleted as they age past your retention period.

Unless you have an unusually long retention period, you can just wait to upgrade to 6.x until all of your pre-5.x indices have been deleted.

Reindex in place

To manually reindex your old indices with the reindex API:

  1. Create a new index and copy the mappings and settings from the old index.

  2. Set the refresh_interval to -1 and the number_of_replicas to 0 for efficient reindexing.

  3. Reindex all documents from the old index into the new index using the reindex API.

  4. Reset the refresh_interval and number_of_replicas to the values used in the old index.

  5. Wait for the index status to change to green.

  6. In a single update aliases request:

    1. Delete the old index.

    2. Add an alias with the old index name to the new index.

    3. Add any aliases that existed on the old index to the new index.

Migration assistance and upgrade tools

{xpack} 5.6 provides migration assistance and upgrade tools that simplify reindexing and upgrading to 6.x. These tools are free with the X-Pack trial and Basic licenses and you can use them to upgrade whether or not X-Pack is a regular part of your Elastic Stack. For more information, see {stack-ref}/upgrading-elastic-stack.html.

Reindex from a remote cluster

You can use reindex from remote to migrate indices from your old cluster to a new 6.x cluster. This enables you move to 6.x from a pre-5.6 cluster without interrupting service.

Warning

Elasticsearch provides backwards compatibility support that enables indices from the previous major version to be upgraded to the current major version. Skipping a major version means that you must resolve any backward compatibility issues yourself.

{es} does not support forward compatibility across major versions. For example, you cannot reindex from a 7.x cluster into a 6.x cluster.

To migrate your indices:

  1. Set up a new 6.x cluster alongside your old cluster. Enable it to access your old cluster by adding your old cluster to the reindex.remote.whitelist in elasticsearch.yml:

    reindex.remote.whitelist: oldhost:9200
    Note

    The new cluster doesn’t have to start fully-scaled out. As you migrate indices and shift the load to the new cluster, you can add nodes to the new cluster and remove nodes from the old one.

  2. For each index that you need to migrate to the 6.x cluster:

    1. Create a new index in 6.x with the appropriate mappings and settings. Set the refresh_interval to -1 and set number_of_replicas to 0 for faster reindexing.

    2. Reindex from remote to pull documents from the old index into the new 6.x index:

      POST _reindex
      {
        "source": {
          "remote": {
            "host": "http://oldhost:9200",
            "username": "user",
            "password": "pass"
          },
          "index": "source",
          "query": {
            "match": {
              "test": "data"
            }
          }
        },
        "dest": {
          "index": "dest"
        }
      }

      If you run the reindex job in the background by setting wait_for_completion to false, the reindex request returns a task_id you can use to monitor progress of the reindex job with the task API: GET _tasks/TASK_ID.

    3. When the reindex job completes, set the refresh_interval and number_of_replicas to the desired values (the default settings are 30s and 1).

    4. Once replication is complete and the status of the new index is green, you can delete the old index.