Elasticsearch6.13 升级6.24 单节点停机升级

Posted 三木燕

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch6.13 升级6.24 单节点停机升级相关的知识,希望对你有一定的参考价值。

Elasticsearch6.x 升级6.y 是支持滚动升级的,目前我们测试环境只有一个节点只能停机升级了

准备工作

禁用分片分配

curl -X PUT "localhost:9200/_cluster/settings" -H Content-Type: application/json -d{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}

执行同步刷新,加速碎片恢复

curl -X POST "localhost:9200/_flush/synced"

关闭老版本

supervisorctl stop elasticsearch

启动新版本

下载安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
tar -zvxf elasticsearch-6.2.4.tar.gz -C /data/app/
chown -R elasticsearch.elasticsearch elasticsearch-6.2.4

拷贝配置文件和数据目录

cp -rf elasticsearch-6.1.3/config/ elasticsearch-6.2.4/
cp -rf elasticsearch-6.1.3/data/ elasticsearch-6.2.4/

修改配置文件中数据的目录

vim elasticsearch-6.2.4/config/elasticsearch.yml

# Path to directory where to store the data (separate multiple locations by comma):
#
 path.data: /data/app/elasticsearch/data

启动新版本

vim /etc/supervisor/conf.d/es-new.conf

[program:elasticsearch-new]
directory=/data/app/elasticsearch-6.2.4/bin/
command=su - elasticsearch -c "/data/app/elasticsearch-6.2.4/bin/elasticsearch"
autostart=true
startsecs=30
autorestart=true
startretries=5
user=root
priority=1
redirect_stderr=true
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_logfile=/var/log/elasticsearch/es-new_supervisor.out
stopasgroup=false
killasgroup=false

 

supervisorctl reload
supervisorctl start elasticsearch-new 
supervisorctl status

elasticsearch                    STOPPED   May 22 12:58 PM
elasticsearch-head               RUNNING   pid 890, uptime 0:42:25
elasticsearch-new                RUNNING   pid 889, uptime 0:42:25
kibana                           RUNNING   pid 887, uptime 0:42:25

等待集群状态健康状态为yellow就行了

curl -X GET "localhost:9200/_cat/health"

1526964363 12:46:03 elasticsearchbigdata yellow 1 1 1674 1674 0 0 1674 0 - 50.0%

curl -X GET "localhost:9200/_cat/recovery"

product_brand_100301_shop_330778_current 0 70ms  existing_store done n/a n/a 192.168.101.55 elasticsearch n/a n/a 0 0 100.0% 4  0 0 100.0% 31141    0 0 100.0%
shop_brand_100479_current                0 44ms  existing_store done n/a n/a 192.168.101.55 elasticsearch n/a n/a 0 0 100.0% 4  0 0 100.0% 5667     0 0 100.0%

#恢复分配

curl -X PUT "localhost:9200/_cluster/settings" -H Content-Type: application/json -d{
  "persistent": {
    "cluster.routing.allocation.enable": null
  }
}

 

以上是关于Elasticsearch6.13 升级6.24 单节点停机升级的主要内容,如果未能解决你的问题,请参考以下文章

zabbix2.2升级到3.0.4

6.24

6.24我要移民!

6.24我要移民!2

2021. 6.24

COMP9021--6.24