在任何系统或软件中,当我们升级到较新版本时,需要按照几个步骤来维护应用程序设置,配置,数据和其他事情。 这些步骤是使应用程序在新系统中保持稳定或保持数据的完整性(防止数据损坏)所必需的。
以下是升级Elasticsearch的步骤 -
| 旧版 | 新版 | 升级方法 |
|---|---|---|
| 0.90.x | 2.x | 完全群集重新启动 |
| 1.x | 2.x | 完全群集重新启动 |
| 2.x | 2.y | 滚动升级(y> x) |
在开始备份过程之前,需要在Elasticsearch中注册快照存储库。
PUT /_snapshot/backup1
{
"type": "fs", "settings": {
... repository settings ...
}
}
注意 - 上面的文本是对http://localhost:9200/_snapshot/backup1的HTTP PUT请求(可以是远程服务器的IP地址,而不是localhost)。其余的文本是请求正文。可以使用fiddler2和Windows中的其他网络工具。
我们使用共享文件系统(类型:fs)进行备份; 它需要在每个主节点和数据节点中注册。只需要添加具有备份存储库路径的path.repo变量作为值。
添加存储库路径后,需要重新启动节点,然后可以通过执行以下命令来执行注册
PUT http://localhost:9200/_snapshot/backup1
{
"type": "fs", "settings": {
"location": "/mount/backups/backup1", "compress": true
}
}
完全群集重新启动
此升级过程包括以下步骤 -
第1步 - 禁用碎片分配程序,并关闭节点。
PUT http://localhost:9200/_cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
在升级0.90.x到1.x的情况下使用以下请求
PUT http://localhost:9200/_cluster/settings
{
"persistent": {
"cluster.routing.allocation.disable_allocation": false,
"cluster.routing.allocation.enable": "none"
}
}
第2步 - 对Elasticsearch进行同步刷新
POST http://localhost:9200/_flush/synced第3步 - 在所有节点上,终止所有
elastic 服务。
第4步 - 在每个节点上执行以下操作 -
config目录。 您可以从旧安装复制文件或可以更改path.conf或path.data。
第5步 - 从群集中的主节点(node.master设置为true,node.data设置为false的节点)开始重新启动节点。等待一段时间以建立群集。可以通过监视日志或使用以下请求进行检查
GET _cat/health or http://localhost:9200/_cat/health GET _cat/nodes or http://localhost:9200/_cat/health第6步 - 使用
GET _cat/health请求监视集群的形成进度,并等待黄色响应,响应将是这样
1451295971 17:46:11 elasticsearch yellow 1 1 5 5 0 0 5 0 - 50.0%第6步 - 启用分片分配过程,这是在第1步中禁用的,使用以下请求
PUT http://localhost:9200/_cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}
在将0.90.x升级到1.x的情况下,请使用以下请求
PUT http://localhost:9200/_cluster/settings
{
"persistent": {
"cluster.routing.allocation.disable_allocation": true,
"cluster.routing.allocation.enable": "all"
}
}
滚动升级
它与完全群集重新启动相同,但第3步除外。在此,停止一个节点并进行升级。升级后,重新启动节点并对所有节点重复这些步骤。 启用分片分配过程后,可以通过以下请求监视:
GET http://localhost:9200/_cat/recovery