本文旨在介绍如何升级GaussDB单机版数据库,从1.0.0升级到1.0.2版本。单机支持小版本升级和二进制升级这两种类型的自动升级。进行自动升级时,只需要在节点上执行一次升级命令。
1、上传软件包以及解压
上传以下两个软件包至同一目录:
GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz
DIALECT-SCRIPT-GaussDB_T_1.0.2.tar.gz
[omm@hwd10 gaussdb]$ tar -xzf GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz
2、创建配置文件
[omm@hwd10 gaussdb]$ vi /opt/gaussdb/config_file.ini
192.168.120.31=/opt/software/gaussdb/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz,/opt/gaussdb/app,/opt/gaussdb/
backup,/opt/gaussdb/data
[omm@hwd10 gaussdb]$ mkdir /opt/gaussdb/backup
- 192.168.120.31是数据库所在服务器IP。
- /opt/software/gaussdb/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz是升级包的绝对路径。
- /opt/gaussdb/app是数据库安装路径。
- /opt/gaussdb/backup是升级过程中备份文件的存储路径(需手工创建)。
- /opt/gaussdb/data是数据库实例的数据文件目录。安装多个实例时,使用同一个安装目录启动的数据库实例必须一次性升级,此时需要指定多个数据库实例的数据目录,多个数据目录之间使用逗号分隔。
3、获取升级类型(可选)
[omm@hwd10 ~]$ cd /opt/software/gaussdb/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit [omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -t upgrade-type --GSDB_HOME=/opt/gaussdb/app --GSDB_DATA=/opt/gaussdb/data --package=/opt/software/gaussdb/GaussDB_T/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz --backupdir=/opt/gaussdb/backup Old version: 1.0.0.SPC1.B002 New version: 1.0.2.B319. systable-upgrade
返回Upgrade type: binary-upgrade.时,自动升级时进行二进制升级;返回Upgrade type: systable-upgrade.时,自动升级时进行小版本升级。
4、升级环境检查
[omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -s pre-check --config-file=/opt/gaussdb/config_file.ini --upgrade-mode=single Begin to precheck for single upgrade. Old version: 1.0.0.SPC1.B002 New version: 1.0.2.B319. Precheck for single upgrade finished. Upgrade [pre-check] step successfully. [omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$
5、执行一键升级
[omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -s run --config-file=/opt/gaussdb/config_file.ini --upgrade-mode=single
Old version: 1.0.0.SPC1.B002 New version: 1.0.2.B319.
Precheck step for single upgrade.
Prepare step for single upgrade.
Replace step for single upgrade.
Begin distrubute key to other instances.
output:
attr:MOUNT
single=============output:
connected.
SQL>
VALUE
----------------------------------------------------------------
(/opt/gaussdb/data/protect/kmc_a.ksf, /opt/gaussdb/data/protect/kmc_b.ksf)
1 rows fetched.
single===========status:0
Start step for single upgrade.
Upgrade step for single upgrade.
Sync step for single upgrade.
Dbcheck step for single upgrade.
Flush step for single upgrade.
Run for single upgrade finished.
Upgrade [run] step successfully.
升级完成后,数据库处于关闭状态,打开数据库,通过查询version视图也可以获取到升级后的版本信息。
6、清理环境
执行cleanup清理环境时会删除升级过程中产生的日志文件(upgrade.log文件),如果后期需要查看,请在执行cleanup前手动保存upgrade.log文件。upgrade.log文件的存储路径是/opt/gaussdb/backup/ha_upgrade_backup/upgrade.log,其中/opt/gaussdb/backup是用户手动创建的升级过程中备份文件的存储路径。
[omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -s cleanup --config-file=/opt/gaussdb/config_file.ini --upgrade-mode=single
clean backup and tmp files.
Upgrade [cleanup] step successfully.
7、回滚操作
如果数据库升级失败后,需要通过自动回滚的方式回滚数据库。
7.1 回滚检查
进入upgrade.py所在目录,执行下面的命令:
[omm@hwd10 ~]$ cd /opt/software/gaussdb/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit
[omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -s rollback-check --config-file=/opt/gaussdb/config_file.ini --upgrade-mode=single
7.2 执行回滚
[omm@hwd10 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]$ python upgrade.py -s rollback --config-file=/opt/gaussdb/config_file.ini --upgrade-mode=single
来源:51CTO
作者:candon123
链接:https://blog.51cto.com/candon123/2477572