数据盘升级步骤: 1 es数据迁移 2 磁盘升级 3 数据迁回
一、ucloud磁盘容量扩容 1.1、ES迁移数据 curl -X PUT "10.19.86.53:9200/_cluster/settings" -H 'Content-Type: application/json' -d' { "transient" : { "cluster.routing.allocation.exclude._ip" : "10.19.153.121" } }' 10.19.86.53集群主节点 10.19.153.121迁移数据的节点 ES数据迁回(暂停迁移) curl -X PUT "10.19.86.53:9200/_cluster/settings" -H 'Content-Type: application/json' -d' { "transient" : { "cluster.routing.allocation.exclude._ip" : "" } }' 数据迁移完后下掉节点: jps|grep -i elasticsearch 1300 Elasticsearch kill -SIGTERM 1300
1.2.1、磁盘升级 //针对ext4文件格式的操作系统(如CentOS6):// umount /dev/vdb e2fsck -f /dev/vdb resize2fs /dev/vdb mount /dev/vdb /data
//针对xfs文件格式的操作系统(如CentOS7)// umount /dev/vdb xfs_repair /dev/vdb mount /dev/vdb /data xfs_growfs /data
1.2.2、更换磁盘 ansible 10.9.160.129 -m script -a 'umount.sh' -k 卸载磁盘脚本: more umount.sh
#!/bin/bash
echo "关闭所有服务"
supervisorctl stop all
jps|grep -i elasticsearch |awk -F " " '{print $1}'|xargs kill -SIGTERM
echo "备份data"
cp /data/* /mnt/ -R
echo "卸载磁盘"
lsof |grep /data|awk -F " " '{print $2}'|xargs kill -9
umount /data
云控制台卸载磁盘购买新的磁盘 ansible 10.9.160.129 -m script -a 'mount.sh' -k 挂载磁盘脚本: more mount.sh
#!/bin/bash
sed -i '/data/'d /etc/fstab
echo "初始化磁盘"
mkfs.xfs /dev/vdb
echo "挂载磁盘"
mount /dev/vdb /data
systemctl daemon-reload
echo "开机自动挂载"
UUID=$(blkid |grep vdb|awk -F ' ' '{print $2}')
echo "$UUID /data xfs defaults 0 0" >> /etc/fstab
echo "迁回配置授权es启动用户"
cp /mnt/* /data/ -R
chown -R elsearch:elsearch /data/e*
1.3、数据迁回 集群老机器恢复数据: 3.1、启动服务 su elsearch -c "/data/elasticsearch/bin/elasticsearch -d" 3.2、数据迁回 curl -X PUT "10.19.153.121:9200/_cluster/settings" -H 'Content-Type: application/json' -d' { "transient" : { "cluster.routing.allocation.exclude._ip" : "" } }'
查看文档: https://yq.aliyun.com/articles/672521
二、腾讯云数据盘更换 2.1、ES数据迁移 curl -X PUT "172.21.16.76:9200/_cluster/settings" -H 'Content-Type: application/json' -d' { "transient" : { "cluster.routing.allocation.exclude._ip" : "172.21.16.64" } }' 172.21.16.76:9200 ###是主节点IP 172.21.16.64 ###要移除的节点IP 2.2、卸载磁盘 ansible远程执行脚本: ansible 172.21.16.73 -m script -a 'umount.sh' -k more umount.sh
#!/bin/bash
echo "迁移完数据关闭es"
jps|grep -i elasticsearch |awk -F " " '{print $1}'|xargs kill -SIGTERM
echo "关闭所有服务"
supervisorctl stop all
/etc/init.d/zabbix_agentd stop
chkconfig zabbix_agentd off
echo "备份data"
cp /data/* /mnt/ -R
echo "卸载磁盘"
lsof |grep /data|awk -F " " '{print $2}'|xargs kill -9
umount /data
2.3、挂载磁盘: ansible执行远程挂载磁盘脚本: ansible 172.21.16.73 -m script -a 'mount.sh' -k more mount.sh
#!/bin/bash
sed -i '/data/'d /etc/fstab
. /root/.bash_profile
set -m
echo "初始化磁盘"
echo "n
p
1
w
" | fdisk /dev/vdb
mkfs.xfs /dev/vdb1
mount /dev/vdb1 /data
systemctl daemon-reload
echo "开机自动挂载"
UUID=$(blkid |grep sdb|awk -F ' ' '{print $2}')
echo "$UUID /data xfs defaults 0 0" >> /etc/fstab
cp /mnt/* /data/ -R
chown -R elsearch:elsearch /data/e*
2.4、启动服务: ansible执行远程启动脚本: ansible 172.21.16.73 -m script -a 'services.sh' -k more services.sh
cp /mnt/* /data/ -R
chown -R elsearch:elsearch /data/e*
systemctl start supervisord
supervisorctl restart elasticsearch
2.5、磁盘升级 2.5.1、使用扩容工具进行扩容 jps|grep -i elasticsearch |awk -F " " '{print $1}'|xargs kill -SIGTERM supervisorctl stop all cp /data/* /mnt/ -R lsof |grep /data|awk -F " " '{print $2}'|xargs kill -9 umount /data wget -O /tmp/devresize.py https://raw.githubusercontent.com/tencentyun/tencentcloud-cbs-tools/master/devresize/devresize.py python /tmp/devresize.py /dev/vdb y y mount /dev/vdb /data df -h 2.5.2、使用命令进行扩容 jps|grep -i elasticsearch |awk -F " " '{print $1}'|xargs kill -SIGTERM supervisorctl stop all cp /data/* /mnt/ -R lsof |grep /data|awk -F " " '{print $2}'|xargs kill -9 umount /data fdisk /dev/vdb d n p 1 w xfs_growfs /dev/vdb1
挂载新分区 fdisk -l Disk /dev/vda: 161.1 GB, 161061273600 bytes, 314572800 sectors /dev/vda1 * 6295552 62914559 28309504 83 Linux fdisk /dev/vda Command (m for help): n Select (default p): p First sector (2048-314572799, default 2048): 62914560 Command (m for help): w cp -R /data/* /mnt/ 通知系统分区表的变化 partprobe 格式化 mkfs.xfs -f /dev/vda2