ElasticSearch 小版本 RPM 滚动升级(如 7.14.0 → 7.17.10,无服务中断)

小版本升级(同一系列内)无破坏性变更,支持逐个节点滚动升级,集群整体服务不中断,步骤如下:

步骤 1:单个节点禁用分片分配(减少资源消耗)

登录待升级节点,执行命令禁止分片迁移:

bash 复制代码
curl -XPUT "http://<当前节点IP>:9200/_cluster/settings" -H "Content-Type: application/json" -d '{
    "persistent": {
        "cluster.routing.allocation.enable": "none"
        }
}'

步骤 2:停止当前节点的 Elasticsearch 系统服务

RPM 安装的 ES 以 systemd 管理,停止服务命令:

bash 复制代码
# 停止 ES 服务
systemctl stop elasticsearch.service

# 验证服务已停止
systemctl status elasticsearch.service

步骤 3:使用 YUM 升级当前节点的 Elasticsearch RPM 包

直接通过 yum update 升级(自动匹配 YUM 仓库中的最新小版本):

bash 复制代码
# 升级 Elasticsearch(仅升级该包,不升级其他依赖)
yum update elasticsearch -y

说明:YUM 会自动保留原有配置文件(/etc/elasticsearch),并将新版本配置文件以 .rpmnew 后缀留存(若有差异),无需手动替换二进制文件。

步骤 4:修复权限(RPM 升级后可能重置权限)

确保 ES 相关目录的所属用户仍为 elasticsearch(RPM 默认创建该用户):

bash 复制代码
chown -R elasticsearch:elasticsearch /etc/elasticsearch
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
chown -R elasticsearch:elasticsearch /var/log/elasticsearch

步骤 5:重新加载 systemd 配置,启动 ES 服务

bash 复制代码
# 重新加载 systemd 配置(防止服务文件变更)
systemctl daemon-reload

# 启动 ES 服务
systemctl start elasticsearch.service

# 设置开机自启(保持原有配置)
systemctl enable elasticsearch.service

# 验证服务启动成功
systemctl status elasticsearch.service

步骤 6:验证节点状态,启用分片分配

  1. 验证节点是否正常加入集群,版本是否更新:
bash 复制代码
curl -XGET "http://<当前节点IP>:9200/_nodes/version?pretty"
  1. 启用分片分配,等待分片同步完成(集群回到 green 状态):bash运行
bash 复制代码
curl -XPUT "http://<当前节点IP>:9200/_cluster/settings" -H "Content-Type: application/json" -d '{
  "persistent": {
    "cluster.routing.allocation.enable": "all"
  }
}'

# 等待集群恢复 green,超时 5 分钟
curl -XGET "http://<当前节点IP>:9200/_cluster/health?wait_for_status=green&timeout=300s&pretty"

步骤 7:重复步骤 1-6,升级集群中所有其他节点

逐个节点完成滚动升级,确保所有节点最终版本一致,升级完成后再次全局检查集群健康和版本一致性。

相关推荐
Elasticsearch1 小时前
使用 Elastic Agent Builder 和 Sarvam AI 构建多语言语音 agent
elasticsearch
武子康4 天前
调查研究-197 FAISS vs Elasticsearch 全面对比:从向量检索、全文搜索到 RAG 选型指南
人工智能·elasticsearch·agent
Elasticsearch5 天前
Elasticsearch ES|QL:现已支持视图、子查询和读取时模式定义
elasticsearch
Elasticsearch8 天前
Kibana 中的 SNMP 拓扑数据:从采集到 Canvas
elasticsearch
Elasticsearch10 天前
3个信号、2个环境变量、0个采集器:使用 Python 和 Elastic 的托管 OTLP 端点实现 OpenTelemetry
elasticsearch
Elasticsearch12 天前
如何通过 Claude Code 来写入 CSV 数据到 Elasticsearch
elasticsearch
大志哥12314 天前
ES和Logstash日志链路系统上线后遭遇切片爆炸(解决)
大数据·elasticsearch
TableRow14 天前
参数化搜索的实现原理:从多维索引到查询优化
elasticsearch·全文检索
醉颜凉14 天前
Elasticsearch高性能优化:Bulk API大规模数据导入性能调优全攻略
elasticsearch·性能优化·jenkins