openGauss 数据库从 3.0.0 升级到 3.1.0 操作实践
收录于合集 #技术干货 83 个
openGauss 在 9 月 30 日新出了 3.1.0 版本。想必有些小伙伴已经跃跃欲试了。也有小伙伴反馈不知道如何升级或在升级过程中遇到一些问题,因此,本文将为大家详细介绍如何从 openGauss 数据库 3.0.0 升级到 3.1.0。
升级约束官网文档可查看:https://opengauss.org/zh/docs/3.1.0/docs/UpgradeGuide/%E5%8D%87%E7%BA%A7%E5%89%8D%E5%BF%85%E8%AF%BB.html
具体就不再一一列举,主要就是升级期间不要做增删改,生产和商业环境务必按照要求执行。
►►►
升级前准备
检查升级前版本
[omm@pekphisprb70593 ~]$ gsql --version
gsql (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr
复制代码
查看数据库节点磁盘使用率,低于 80%时再执行升级操作。
[omm@pekphisprb70593 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda3 35G 7.0G 26G 22% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 12K 3.9G 1% /dev/shm
tmpfs 3.9G 49M 3.8G 2% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda1 976M 117M 793M 13% /boot
tmpfs 783M 0 783M 0% /run/user/0
复制代码
以数据库用户(如 omm)登录节点,执行如下命令查看数据库状态,确认 cluster_state : Normal。
[omm@pekphisprb70593 ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : opengSingle
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
复制代码
以 root 用户执行如下命令对服务器的 OS 参数进行检查。检查服务器的 OS 参数的目的是为了保证数据库正常通过预安装,并且在安装成功后可以安全高效的运行。详细的检查项目请参见《工具参考》中的“服务端工具 > gs_checkos”工具。
在官网获取新的版本安装包:
https://opengauss.org/zh/download.html
手动备份
根据需要多一重备份,可在升级前自己先建个表,验证升级后是不是正常。
升级操作
root 用户创建新包目录。
mkdir -p /opt/software/gaussdb_upgrade
复制代码
2.将需要更新的新包上传至目录“/opt/software/gaussdb_upgrade”并解压,把之前旧版本使用的 cluster_config.xml 也拷贝过来。
修改属主
[root@pekphisprb70593 software]# chown -R omm:dbgrp gaussdb_upgrade/
复制代码
进入安装包解压出的 script 目录下,在升级前执行前置脚本 gs_preinstall。
cd /opt/software/gaussdb_upgrade/script
./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb_upgrade/cluster_config.xml
复制代码
这里可能会出现报错,可根据提示重新编译 python,补充 CFLAGS=-fPIC ,cd 到 Python 安装包目录下。
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
make
make install
复制代码
重新执行 gs_preinstall 命令成功。
[root@pekphisprb70593 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb_upgrade/cluster_config.xml
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Setting host ip env
Successfully set host ip env.
Are you sure you want to create the user[omm] (yes/no)? no
Preparing SSH service.
Successfully prepared SSH service.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opt/software/gaussdb_upgrade/script/gs_checkos -i A -h pekphisprb70593 --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
复制代码
切换至 omm 用户 使用如下命令进行就地升级或者灰度升级。
gs_upgradectl -t auto-upgrade -X /opt/software/gaussdb_upgrade/cluster_config.xml --grey
[omm@pekphisprb70593 script]$ gs_upgradectl -t auto-upgrade -X /opt/software/gaussdb_upgrade/cluster_config.xml --grey
Static configuration matched with old static configuration files.
The authenticity of host 'pekphisprb70593 (fe80::f816:3eff:fee3:12fb%eth0)' can't be established.
ECDSA key fingerprint is SHA256:yOyJOqmNfoKjxATR/5n3JNeEQDqH2BVAKz/Sxr27clA.
ECDSA key fingerprint is MD5:42:8f:e9:f1:88:6e:18:c0:d0:68:6a:97:30:0b:d0:77.
Are you sure you want to continue connecting (yes/no)? yes
omm@pekphisprb70593's password:
omm@pekphisprb70593's password:
Successfully set upgrade_mode to 0.
Checking upgrade environment.
Successfully checked upgrade environment.
Start to do health check.
Successfully checked cluster status.
Upgrade one node 'pekphisprb70593'.
NOTICE: The directory /opt/huawei/install/app_02c14696 will be deleted after commit-upgrade, please make sure there is no personal data.
Performing grey rollback.
omm@pekphisprb70593's password:
omm@pekphisprb70593's password:
No need to rollback.
The directory /opt/huawei/install/app_02c14696 will be deleted after commit-upgrade, please make sure there is no personal data.
Installing new binary.
copy certs from /opt/huawei/install/app_02c14696 to /opt/huawei/install/app_4e931f9a.
Successfully copy certs from /opt/huawei/install/app_02c14696 to /opt/huawei/install/app_4e931f9a.
Successfully backup hotpatch config file.
Sync cluster configuration.
Successfully synced cluster configuration.
Switch symbolic link to new binary directory.
Successfully switch symbolic link to new binary directory.
Switching all db processes.
Check cluster state.
Cluster state: [ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip port instance state
-------------------------------------------------------------------------------
1 pekphisprb70593 10.x.x.218 15400 6001 P Primary Normal
Create checkpoint before switching.
Switching DN processes.
Ready to grey start cluster.
Grey start cluster successfully.
Wait for the cluster status normal or degrade.
Successfully switch all process version
The nodes ['pekphisprb70593'] have been successfully upgraded to new version. Then do health check.
Start to do health check.
Successfully checked cluster status.
Waiting for the cluster status to become normal.
.
The cluster status is normal.
Upgrade main process has been finished, user can do some check now.
Once the check done, please execute following command to commit upgrade:
gs_upgradectl -t commit-upgrade -X /opt/software/gaussdb_upgrade/cluster_config.xml
Successfully upgrade all nodes.
复制代码
中途根据提示多次输入 omm 用户的密码,最后提示 successfully upgrade all nodes.就可以了。
升级验证
以数据库用户(如 omm)登录节点,source 环境变量,执行如下命令查看所有节点的版本信息。
[omm@pekphisprb70593 script]$ gsql --version
gsql (openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr
复制代码
以数据库用户(如 omm)执行如下命令查看数据库状态,查询结果的 cluster_state 为 Normal 代表数据库正常。
[omm@pekphisprb70593 script]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : opengSingle
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
复制代码
原来的数据也在,新建也正常。
opengauss_db=# select * from test1;
id
----
1
(1 row)
复制代码
提交升级
升级完成后,如果验证也没问题,接下来就可以提交升级,需要注意的是,一旦提交操作完成,则不能再执行回滚操作。
以数据库用户(如 omm)执行如下命令完成升级提交。
gs_upgradectl -t commit-upgrade -X /opt/software/gaussdb_upgrade/cluster_config.xml
复制代码
至此,升级完成。
评论