Gaussdb T通过upgrade.py对数据库进行版本升级,本文演示将数据库从GaussDB_100_1.0.0.B019 Release 0b7bb43升级至GaussDB_100_1.0.1.SPC2.B003 Release 3ae9d6c的整个过程。
1.升级前版本信息
SQL> select * from v$version;
VERSION
----------------------------------------------------------------
GaussDB_100_1.0.0.B019 Release 0b7bb43
ZENGINE
0b7bb43
3 rows fetched.
2.upgrade.py命令帮助
[omm@alldb GaussDB_100_1.0.1-DATABASE-REDHAT-64bit]$ python upgrade.py --help
upgrade.py is a utility to upgrade a Zengine server.
Usage:
python upgrade.py --help
python upgrade.py -?
python upgrade.py -t upgrade-type --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t pretest --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t precheck --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t prepare --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t replace --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t start --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t upgrade --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t sync --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t restart --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t upgrade-view --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t checkpoint --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t dbcheck --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t flush --package=path_to_package_file --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t rollback-check --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t rollback --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -t rollback-clean --backupdir=path_to_backup [--GSDB_HOME=path_to_gsdb_home] [--GSDB_DATA=path_to_data_dir] [-f cmd_config_file]
python upgrade.py -s pre-check --config-file=CONFIG_FILE [--upgrade-mode=ha|single] [--packtype=run|package] [-f cmd_config_file]
python upgrade.py -s run --config-file=CONFIG_FILE [--auto-rollback=true|false] [--upgrade-mode=ha|single] [--packtype=run|package] [-f cmd_config_file]
python upgrade.py -s cleanup --config-file=CONFIG_FILE [--upgrade-mode=ha|single] [--packtype=run|package] [-f cmd_config_file]
python upgrade.py -s rollback-check --config-file=CONFIG_FILE [--upgrade-mode=ha|single] [--packtype=run|package] [-f cmd_config_file]
python upgrade.py -s rollback --config-file=CONFIG_FILE [--upgrade-mode=ha|single] [--packtype=run|package] [-f cmd_config_file]
Common options:
--help show this help, then exit.
-? show this help, then exit.
-P input password.
-t input the function that need to be executed.
-s input the step for upgrade.
--package input the name of package containing the path.
--backupdir input the name of backup folder containing the path.
--GSDB_HOME input the name of app floder containing the path.
--GSDB_DATA input the name of data floder containing the path.
--config-file input the name of node configure file, the format is:
IP=pkg,app_path,backup_path,data1,data2,..
--auto-rollback if auto-rollback is false, will not rollback when run step failed
--upgrade-mode if upgrade-mode is ha, will upgrade all the nodes in the configure file
--packtype input upgrade package type, value scope is [run, package]
-f input the config file that provide 'parameter=value'. -P, --package, --backupdir, --GSDB_HOME, --GSDB_DATA can be configed by a file.
in the config file, interactive=True is equal with specify '-P' parameter.
for example, the config file content:
GSDB_HOME=path_to_gsdb_home
GSDB_HOME=path_to_gsdb_home
backupdir=path_to_package_file
interactive=TRUE
[omm@alldb GaussDB_100_1.0.1-DATABASE-REDHAT-64bit]$
3.上传升级介质
[omm@alldb ~]$ mkdir -p /opt/software/upgrade
[omm@alldb ~]$ cd /opt/software/upgrade
[omm@alldb upgrade]$ tar -zxvf GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/sshexkey.py
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/upgrade.py
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/funclib.py
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/install.py
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/GaussDB_100_1.0.1-RUN-REDHAT-64bit.sha256
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit/GaussDB_100_1.0.1-RUN-REDHAT-64bit.tar.gz
4.生成升级配置文件
配置文件说明:IP=升级包路径,Gausdb HOME目录,备份目录,数据目录。
[omm@alldb upgrade]$ vi config_file.ini
192.168.2.88=/opt/software/upgrade/GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz,/opt/gaussdb/app,/opt/gaussdb/backup,/opt/gaussdb/data
5.升级前检查
升级前,请确保数据库在运行。
检查命令:
python upgrade.py -s pre-check --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
检查日志:
[omm@alldb GaussDB_100_1.0.1-DATABASE-REDHAT-64bit]$ python upgrade.py -s pre-check --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
Begin to precheck for single upgrade.
Old version: 1.0.0.B019 New version: 1.0.1.SPC2.B003.
Precheck for single upgrade finished.
Upgrade [pre-check] step successfully.
6.执行升级
升级命令:
python upgrade.py -s run --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
升级日志:
[omm@alldb GaussDB_100_1.0.1-DATABASE-REDHAT-64bit]$ python upgrade.py -s run --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
Old version: 1.0.0.B019 New version: 1.0.1.SPC2.B003.
Precheck step for single upgrade.
Prepare step for single upgrade.
Replace step for single upgrade.
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.
7.升级后检查
[omm@alldb ~]$ cd $GSDB_HOME/bin
[omm@alldb bin]$
[omm@alldb bin]$ python zctl.py -t start
Successfully started instance.
[omm@alldb bin]$ zsql / as sysdba -q
connected.
SQL> select * from v$version;
VERSION
----------------------------------------------------------------
GaussDB_100_1.0.1.SPC2.B003 Release 3ae9d6c
ZENGINE
3ae9d6c
3 rows fetched.
8.升级成功后环境清理
清理命令:
python upgrade.py -s cleanup --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
清理日志:
[omm@alldb GaussDB_100_1.0.1-DATABASE-REDHAT-64bit]$ python upgrade.py -s cleanup --config-file=/opt/software/upgrade/config_file.ini --upgrade-mode=single
clean backup and tmp files.
Upgrade [cleanup] step successfully.
至此,Gaussdb T升级完成。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




