简体   繁体   English

如何将正在运行的 Elasticsearch 旧实例升级到新版本?

[英]How to upgrade a running Elasticsearch older instance to a newer version?

Essentially I cannot find documents or resources that explains the procedure of upgrading a running Elasticsearch instance into the current version.基本上,我找不到解释将正在运行的 Elasticsearch 实例升级到当前版本的过程的文档或资源。

Please help me out in a few scenarios:请在以下几种情况下帮助我:

  1. If I am running an Elasticsearch instance in a single server, how do I upgrade the instance and not lose data?如果我在单台服务器上运行 Elasticsearch 实例,如何升级实例而不丢失数据?

  2. If I am running multiple Elasticsearch instances in a number of servers, how do I keep my operations running, while I upgrade my Elasticsearch instances without losing data?如果我在多个服务器中运行多个 Elasticsearch 实例,我如何在升级 Elasticsearch 实例的同时保持操作运行而不会丢失数据?

If there are proper procedures or explanations on this it will greatly help my understanding and work.如果对此有适当的程序或解释,将对我的理解和工作有很大帮助。 Thanks!谢谢!

  1. All node data is stored in elasticsearch data directory.所有节点数据都存储在elasticsearch数据目录中。 It's data/cluster_name/nodes by default in elasticsearch home.在 elasticsearch 主页中默认为 data/cluster_name/nodes。 So, in general, as long as data directory is preserved and config files in the new version are compatible with the old version, the new instance should have the same data as the old one.所以,一般来说,只要保留数据目录,并且新版本中的配置文件与旧版本兼容,新实例应该与旧实例具有相同的数据。 Please note that some releases have special additional requirements outlined in release notes .请注意,某些版本具有发行说明中概述的特殊附加要求。 For example, upgrade to 0.19 from 0.18 requires issuing a full flush of all the indices in the cluster.例如,从 0.18 升级到 0.19 需要发出集群中所有索引的完全刷新。

  2. There is really no good way to accomplish this.真的没有什么好方法可以做到这一点。 Nodes are communicating using binary protocol that is not backward compatible.节点使用不向后兼容的二进制协议进行通信。 So, if protocol in the new version changes, old nodes and new nodes are unable to understand each other.因此,如果新版本中的协议发生变化,新旧节点将无法相互理解。 Sometimes it's possible to mix nodes with different minor versions within the same cluster and do rolling upgrade.有时可以在同一集群中混合具有不同次要版本的节点并进行滚动升级。 However, as far as I understand, there is no explicit guarantee on compatibility between nodes even within minor releases and major releases always require require full cluster restart.但是,据我所知,即使在次要版本中也没有明确保证节点之间的兼容性,而主要版本总是需要完全重启集群。 If downtime during full cluster restart is not an option, a nice technique by DrTech might be a solution.如果在整个集群重新启动期间停机不是一种选择, DrTech 的一项不错的技术可能是一种解决方案。

There is a lot more information about ElasticSearch upgrade these days than it used to be.如今,关于 ElasticSearch 升级的信息比过去多得多。

Here are my usual steps when upgrading ElasticSearch:以下是我升级 ElasticSearch 时的常用步骤:

  1. Backup the data : Snapshot and Restore备份数据:快照和还原

  2. Upgrade Guide : Upgrading ElasticSearch升级指南: 升级 ElasticSearch

The main idea is that you shut down one instance of the ES cluster at a time, upgrade the ES version on that instance node, and bring it up again so it can join back the cluster.主要思想是您一次关闭 ES 集群的一个实例,升级该实例节点上的 ES 版本,然后再次启动它,以便它可以重新加入集群。

In brief, here are the important steps:简而言之,以下是重要步骤:

  1. Disable Shard reallocation禁用分片重新分配

    curl -XPUT localhost:9200/_cluster/settings -d '{ "transient" : { "cluster.routing.allocation.enable" : "none" } }' curl -XPUT localhost:9200/_cluster/settings -d '{“transient”:{“cluster.routing.allocation.enable”:“none”}}'

  2. Shutdown the instance:关闭实例:

    curl -XPOST 'http://localhost:9200/_cluster/nodes/_local/_shutdown'

  3. Install the new ElasticSearch version on the host and Start it.在主机上安装新的 ElasticSearch 版本并启动它。

  4. Enable shard re-allocation:启用分片重新分配:

    curl -XPUT localhost:9200/_cluster/settings -d '{ "transient" : { "cluster.routing.allocation.enable" : "all" } }' curl -XPUT localhost:9200/_cluster/settings -d '{“transient”:{“cluster.routing.allocation.enable”:“all”}}'

  5. Watch cluster go from yellow state to green with:观察集群从yellow状态变为green

curl -X GET http://localhost:9200/_cat/health?v // monitors the overal cluster state curl -X GET http://localhost:9200/_cat/health?v // 监控集群整体状态

curl -X GET http://localhost:9200/_cat/nodes?v // verify that the new node joined the cluster curl -X GET http://localhost:9200/_cat/nodes?v // 验证新节点加入集群

curl -X GET http://localhost:9200/_cat/shards?v // see shards being started, initialized and relocated curl -X GET http://localhost:9200/_cat/shards?v // 查看分片正在启动、初始化和重新定位

  1. Repeat for the next node.对下一个节点重复。

In the terms of ordering, update first the master nodes , then data nodes, then load-balancing/client nodes.在排序方面,首先更新主节点,然后是数据节点,然后是负载均衡/客户端节点。

It should be worth mentioning that there is now documentation on doing this upgrade but it doesn't rank very highly on search results:值得一提的是,现在有关于进行此升级的文档,但它在搜索结果中的排名并不高:

Upgrade Elasticsearch 升级 Elasticsearch

as well as a breaking changes document:以及一个重大变更文件:

Breaking Changes 重大变化

The other answers are a little dated based off what exists now, so this new information will supplement upgrading newer versions of Elasticsearch, like upgrading 6.x to 7.x, or 5.x to 6.x.其他答案根据现在存在的情况有些过时,因此这些新信息将补充升级较新版本的 Elasticsearch,例如将 6.x 升级到 7.x,或将 5.x 升级到 6.x。 There are two main options for an Elasticsearch upgrade: rolling upgrade or full cluster restart . Elasticsearch 升级有两个主要选项: 滚动升级完整集群重启

The rolling upgrade allows nodes to be upgraded one at a time so service is not interrupted.滚动升级允许一次升级一个节点,因此服务不会中断。 On the other hand, the full cluster restart requires every node to be shut down, upgraded, and then brought back up.另一方面,完整的集群重启需要关闭、升级每个节点,然后重新启动。 This means there will be downtime between upgrades that must be accounted for.这意味着必须考虑升级之间的停机时间。

This is much easier to do compared to a few years ago when the only viable option was a snapshot & restore.与几年前唯一可行的选择是快照和恢复相比,这要容易得多。

Here are two articles about this question that I really liked!这里有两篇关于这个问题的文章,我非常喜欢!

Basically the approach is to start a new cluster (with the latest ElasticSearch version you want), keep your data synced by changing your code to make it index a new / updated entity in both (old and new) clusters and start a full reindex on to your new cluster.基本上采取的办法是开始一个新的群集(你想要的最新ElasticSearch版本),不断改变你的代码同步你的数据,使其指数在这两个(新老)集群新/更新的实体并启动完全重新索引上到您的新集群。

At this time you should have two perfectly synced clusters regarding your data.此时,您应该有两个关于您的数据的完美同步的集群。 That allows you to start plugging your read features to the new cluster, see how it goes, probably fix the code making the ES requests regarding the breaking changes (between your current ES version and the new one you want to use), easily rollback to the old cluster if needed.这允许您开始将读取功能插入到新集群中,看看它是如何进行的,可能会修复发出 ES 请求的代码(在您当前的 ES 版本和您想要使用的新版本之间),轻松回滚到如果需要,旧集群。

Once you are all good you can start plugging your write / updates features... and eventually after a few weeks or months turn off the old cluster.一旦一切顺利,您就可以开始插入您的写入/更新功能……并最终在几周或几个月后关闭旧集群。

It's really flexible but all depends of the usecase / timeline your are facing.它非常灵活,但一切都取决于您面临的用例/时间表。 The main possible issue is : does the mapping of the old cluster will be fully compatible with the new one ?主要可能的问题是:旧集群的映射是否与新集群完全兼容?

Hope it helps!希望能帮助到你! I wish you a great day :)我祝福你有个美好的一天 :)

If you are running Ubuntu or Debian based Linux, here is an Ansible script to do a rolling upgrade, as long as you are not upgrading between major versions.如果您运行的是基于 Ubuntu 或 Debian 的 Linux,这里有一个 Ansible 脚本来进行滚动升级,只要您不在主要版本之间进行升级。

Minor versions such as 1.3 -> 1.4.3 are ok次要版本,例如 1.3 -> 1.4.3 都可以

Major versions such as 0.8 -> 1.4.3 will not work. 0.8 -> 1.4.3 等主要版本将无法运行。

https://github.com/ekhoinc/ansible-examples/blob/master/elasticsearch-rolling-upgrade.yml https://github.com/ekhoinc/ansible-examples/blob/master/elasticsearch-rolling-upgrade.yml

It could easily be modified to work with RHEL based linux (just 2 lines to change)它可以很容易地修改为与基于 RHEL 的 linux 一起使用(只需更改 2 行)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM