Full cluster restart upgradeedit

To upgrade directly to Elasticsearch 7.2.1 from versions 6.0-6.7, you must shut down all nodes in the cluster, upgrade each node to 7.2.1, and restart the cluster.

If you are running a version prior to 6.0, upgrade to 6.8 and reindex your old indices or bring up a new 7.2.1 cluster and reindex from remote.

Preparing to upgradeedit

It is important to prepare carefully before starting an upgrade. Once you have started to upgrade your cluster to version 7.2.1 you must complete the upgrade. As soon as the cluster contains nodes of version 7.2.1 it may make changes to its internal state that cannot be reverted. If you cannot complete the upgrade then you should discard the partially-upgraded cluster, deploy an empty cluster of the version before the upgrade, and restore its contents from a snapshot.

Before you start to upgrade your cluster to version 7.2.1 you should do the following.

  1. Check the deprecation log to see if you are using any deprecated features and update your code accordingly.
  2. Review the breaking changes and make any necessary changes to your code and configuration for version 7.2.1.
  3. If you use any plugins, make sure there is a version of each plugin that is compatible with Elasticsearch version 7.2.1.
  4. Test the upgrade in an isolated environment before upgrading your production cluster.
  5. Back up your data by taking a snapshot!

Upgrading your clusteredit

To perform a full cluster restart upgrade to 7.2.1:

  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. Temporarily stop the tasks associated with active machine learning jobs and datafeeds. (Optional)

    If your machine learning indices were created before 6.x, you must reindex the indices.

    If your machine learning indices were created in 6.x, you can:

    • Leave your machine learning jobs running during the upgrade. When you shut down a machine learning node, its jobs automatically move to another node and restore the model states. This option enables your jobs to continue running during the upgrade but it puts increased load on the cluster.
    • Temporarily halt the tasks associated with your machine learning jobs and datafeeds and prevent new jobs from opening by using the set upgrade mode API:

      POST _ml/set_upgrade_mode?enabled=true

      When you disable upgrade mode, the jobs resume using the last model state that was automatically saved. This option avoids the overhead of managing active jobs during the upgrade and is faster than explicitly stopping datafeeds and closing jobs.

    • Stop all datafeeds and close all jobs. This option saves the model state at the time of closure. When you reopen the jobs after the upgrade, they use the exact same model. However, saving the latest model state takes longer than using upgrade mode, especially if you have a lot of jobs or jobs with large model states.
  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.

    If you are upgrading from 6.2 or earlier and use X-Pack, run bin/elasticsearch-plugin remove x-pack to remove the X-Pack plugin before you upgrade. The X-Pack functionality is now included in the default distribution and is no longer installed separately. The node won’t start after upgrade if the X-Pack plugin is present. You will need to downgrade, remove the plugin, and reapply the upgrade.

    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.

      If you use monitoring features, re-use the data directory when you upgrade Elasticsearch. Monitoring identifies unique Elasticsearch 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, logs and plugins 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.

If upgrading from a 6.x cluster, you must also configure cluster bootstrapping by setting the cluster.initial_master_nodes setting on the master-eligible nodes.

  1. 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.

  2. If you use Elasticsearch security features to define realms, verify that your realm settings are up-to-date. The format of realm settings changed in version 7.0, in particular, the placement of the realm type changed. See Realm settings.
  3. 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 enough 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.

  4. 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.

  5. 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
  6. Restart machine learning jobs.

    If you temporarily halted the tasks associated with your machine learning jobs, use the set upgrade mode API to return them to active states:

    POST _ml/set_upgrade_mode?enabled=false

    If you closed all machine learning jobs before the upgrade, open the jobs and start the datafeeds from Kibana or with the open jobs and start datafeed APIs.