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..tar.gz -C /data/app/
chown -R elasticsearch.elasticsearch elasticsearch-6.2.4
拷贝配置文件和数据目录
cp -rf elasticsearch-6.1./config/ elasticsearch-6.2./
cp -rf elasticsearch-6.1./data/ elasticsearch-6.2./
修改配置文件中数据的目录
vim elasticsearch-6.2./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=
autorestart=true
startretries=
user=root
priority=
redirect_stderr=true
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=
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 , uptime ::
elasticsearch-new RUNNING pid , uptime ::
kibana RUNNING pid , uptime ::
等待集群状态健康状态为yellow就行了
curl -X GET "localhost:9200/_cat/health" :: elasticsearchbigdata yellow - 50.0% curl -X GET "localhost:9200/_cat/recovery" product_brand_100301_shop_330778_current 70ms existing_store done n/a n/a 192.168.101.55 elasticsearch n/a n/a 100.0% 100.0% 100.0%
shop_brand_100479_current 44ms existing_store done n/a n/a 192.168.101.55 elasticsearch n/a n/a 100.0% 100.0% 100.0%
#恢复分配
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": null
}
}
'