原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。
1. 概述
在实际情况中,为了更好的提升数据库的稳定性、可靠性、安全性及高性能等方面因素,以及业务的需求情况、修复漏洞等。我们通过数据库升级的方式,来提供更加稳定、性能更佳的数据库产品,从而也修复实际现场中遇到的一些 bug,满足客户一些专项需求。本文旨在提供用户在线和离线的升级流程,方便用户有选择性的升级。
2. 升级方式
数据库升级包括在线升级和离线升级,在线升级是指在不停止业务的情况下,对数据库整个产品进行升级。离线升级是指业务离线的情况下进行升级。紧急 bug 修复时,可以单独升级高可用模块或者单独升级数据库集群,升级小版本和升级大版本在升级方式上一致。
升级操作会对产品的运行产生的影响及应对措施;我们采取的是灰度升级,对于业务测和服务是无感知的,并且可以有效的降低风险,如果在灰度升级的过程中出现问题或错误,可以立即止损并迅速回滚。这减少了影响用户体验的风险,并减少了修复问题所需的时间、资源和成本。
升级高可用模块。升级高可用是指直接对高可用模块进行升级,会对 gha_agent 和 server 进行重启,对于内核仍是沿用旧版本,升级后不改变数据库集群。
升级数据库集群。只对数据库内核进行版本升级,对高可用的版本不做升级。
升级高可用&数据库数据库集群。对数据库旧版本进行全面升级。
3. 操作步骤
3.1. 离线升级只升级高可用模块
- 上传升级版本,并进行解压
- 升级前配置 prepare
gha_ctl prepare version pkg_path install_prefix [-u 'gbase'] [-p 22] [-c gbase8c] -l dcslist [-t multiple-nodes|single-inst]
- 升级前配置处理
./gha_ctl upgrade -t catalog V5_S3.0.3B06 -l [http://10.0.7.11:2379](http://10.0.7.11:2379)
注意:高升低版本将 upgrade 更换为 rollback
停止所有节点
gha_ctl stop all -l [http://10.0.7.11:2379](http://10.0.7.11:2379)
- 升级高可用
./gha_ctl upgrade V5_S3.0.3B06 100.0.7.12 -t ha -l [http://10.0.7.11:2379](http://10.0.7.11:2379)
- 启动所有节点
gha_ctl start all -l [http://10.0.7.11:2379](http://10.0.7.11:2379)
- 升级后配置在线处理
gha_ctl upgrade -t catalog-post V5_S3.0.3B06 -l [http://10.0.7.11:2379](http://10.0.7.11:2379)
3.2. 在线升级
- 升级前查看集群状态
gha_ctl mointor all -l https://10.185.102.1:2379 -H -I -c gbase8c-cluster01
- 开启业务(升级时业务开启)
- 上传新包并解压
/data/mpp/gbase/gbase_pkg_b86
tar -zxf GBase8cV5_S3.0.3B06_centos7.6_aarch64.tar.gz
tar -zxf GBase8cV5_S3.0.3B06_CentOS_aarch64_om.tar.gz
- 升级节点执行 prepare 新版本安装包路径和软件路径
gha_ctl prepare V5_S3.0.3B06 /data/mpp/gbase/gbase_pkg_b86 /data/mpp/gbase/gbase_db -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
ETCDCTL_APL=2 etcdctl -u root:Gbase8c --endpoint http://10.185.102.1:2379 get /service/gbase8c-cluster01/meta/env_info
- 切换到加压升级版本包后的 script 下执行升级
cd /data/mpp/gbase/gbase_pkg_b86/script
a.升级高可用
gha_ctl upgrade V5_S3.0.3B06 -t ha -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
b.升级 node1
a) 触发倒换,将 node1 上的 dn,和 gtm 变为备机
gha_ctl switchover datanode dn1 dn1_3 dn1_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl switchover gtm gtm3 gtm5 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
b) 停节点上所有备 dn,备 gtm,cn
gha_ctl stop datanode dn1 dn1_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop datanode dn2 dn2_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop gtm gtm3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop coordinator cn3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
c) 升级数据库内核
./gha_ctl upgrade V5_S3.0.3B06 10.185.103.1 -t app -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
d) 启动节点
gha_ctl start datanode dn1 dn1_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start datanode dn2 dn2_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
c.升级 node2
a) 触发倒换,将 node2 上的 dn,和 gtm 变为备机
gha_ctl switchover datanode dn1 dn1_4 dn1_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl switchover datanode dn2 dn2_3 dn2_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
b) 停节点上所有备 dn,备 gtm,cn
gha_ctl stop datanode dn1 dn1_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop datanode dn2 dn2_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop gtm gtm4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop coordinator cn4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
c) 升级数据库内核
./gha_ctl upgrade V5_S3.0.3B06 10.185.103.2 -t app -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
d) 启动节点
gha_ctl start datanode dn1 dn1_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start datanode dn2 dn2_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start gtm gtm4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start coordinator cn4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
d. 升级 node3
a) 触发倒换,将 node2 上的 dn,和 gtm 变为备机
gha_ctl switchover datanode dn3 dn3_3 dn3_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
b) 停节点上所有备 dn,备 gtm,cn
gha_ctl stop datanode dn3 dn3_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop datanode dn4 dn4_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
c) 升级数据库内核
./gha_ctl upgrade V5_S3.0.3B06 10.185.103.3 -t app -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
d) 启动节点
gha_ctl start datanode dn3 dn3_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start datanode dn4 dn4_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
e. 升级 node4
a) 触发倒换,将 node2 上的 dn,和 gtm 变为备机
gha_ctl switchover datanode dn3 dn3_4 dn3_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl switchover datanode dn4 dn4_3 dn4_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl switchover gtm gtm5 gtm3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
b) 停节点上所有备 dn,备 gtm,cn
gha_ctl stop datanode dn3 dn3_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop datanode dn4 dn4_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl stop gtm gtm5 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
c) 升级数据库内核
./gha_ctl upgrade V5_S3.0.3B06 10.185.103.4 -t app -l http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379 -c gbase8c-cluster01
d) 启动节点
gha_ctl start datanode dn3 dn3_4 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start datanode dn4 dn4_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl start gtm gtm5 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
f. 触发倒换,切换各节点原主 dn
gha_ctl switchover datanode dn2 dn2_4 dn2_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
gha_ctl switchover datanode dn4 dn4_4 dn4_3 -l [http://10.185.102.1:2379,http://10.185.102.3:2379,http://10.185.102.4:2379](http://10.185.102.1:2379,http:/10.185.102.3:2379,http:/10.185.102.4:2379) -c gbase8c-cluster01
g. 验证集群状态及各节点版本号
gha_ctl monitor all -l [https://10.185.102.1:2379](https://10.185.102.1:2379) -H -I -c gbase8c-cluster01
4. 数据保护
1.升级过程中不涉及数据导入导出,从而保障数据的完整性,不会产生数据丢失或损坏。
2.在进行数据库升级之前,首先对现有数据进行备份,以防万一,在升级失败时可以回退。
1)备份机制:gha_ctl backup 属于物理备份,适用于数据量大的场景,直接复制数据库的物理文件,性能比较高,对应用的约束比较少,但只能对整个库进行备份。物理备份又分为全量备份和增量备份。增量备份又有两种方式,一种是结合数据库的脏页跟踪实现的增量备份,另外一种是根据 redo 日志的增量实现的增量备份,根据脏页进行增量备份可以和历史上的备份进行合并,较少存储空间的占用,恢复时可以恢复到增量备份的时间点,无法恢复到任意时间点。根据 redo 日志进行的增量备份在恢复时可以恢复到指定时间点。物理备份主要用于保障数据库的可靠性。
2)备份步骤:
① 设置日志归档:需要将目录存储所有备份文件包括额外的元信息、WAL 日志归档。
gha_ctl set type name archive_command='cmd' -l dcslist -c cluster
gha_ctl set type name archive_mode=on -l dcslist -c cluster
例如:
gha_ctl set gtm gtm1 -p archive_command="'scp %p 10.0.1.[47:/home/gbase/backup/gtm_wal/%f](http://0.0.0.47/home/gbase/backup/gtm_wal/%f)'" -l [http://10.0.1.44:2379](http://10.0.1.44:2379/)
gha_ctl set gtm gtm1 -p archive_mode=on -l [http://10.0.1.44:2379](http://10.0.1.44:2379/)
② 基础全量备份:包含从头恢复数据库集群所需要的所有数据文件。
gha_ctl backup all -p /home/gbase/code2/ GBase8cV5_S3.0.3/contrib/gha/template -l dcslist
注:备份所有节点,并行运行,-p 后携带配置文件所在路径,配置文件格式如下
例如:
gha_ctl backup all -p /home/gbase/backup -l http://10.0.7.64:2379
③ 备份后数据文件:备份后的数据文件均为二进制文件。
原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。