您的位置:  首页 > 技术杂谈 > 正文

openGauss数据库3.0.0升级5.0.0操作实践

2023-05-17 11:00 https://my.oschina.net/gaussdb/blog/8796404 Gauss松鼠会 次阅读 条评论

 

文章目录

  • 1.1 前言
  • 1.2 升级须知
    • 升级流程
    • 升级方式
    • 升级约束
  • 1.3 升级前准备
  • 1.4 升级操作
  • 1.5 升级验证
  • 1.6 提交升级

 

1.1 前言

openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。之前基于3.0.0版本进行了一些实践,本篇就详细介绍如何将openGauss数据库从3.0.0升级到最新发布的5.0.0版本。

1.2 升级须知

升级流程

 

升级方式

用户挑选升级方式后,系统会自动判断并选择合适的升级策略。

  • 就地升级:升级期间需停止业务进行,一次性升级所有节点。
  • 灰度升级:灰度升级支持全业务操作,也是一次性升级所有节点。(openGauss1.1.0版本之后的版本支持该功能)
  • 滚动升级:基于灰度升级,支持升级指定节点,支持部分节点升级。(openGauss3.1.0版本之后的版本支持该功能)。
    本次我们采用灰度升级方式。

升级约束

升级约束官网文档详细列出,具体就不再一一列举。主要就是升级期间不要做增删改。生产和商业环境务必按照要求执行。

1.3 升级前准备

1.检查OS。

[root@hecs-1105531 etc]# cat centos-release
CentOS Linux release 7.6.1810 (Core)

2.检查升级前版本

[omm@hecs-1105531 ~]$ gsql --version
gsql (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr

3.查看数据库节点磁盘使用率,低于80%时再执行升级操作。

[omm@hecs-1105531 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G   24K  1.9G   1% /dev/shm
tmpfs           1.9G  175M  1.7G  10% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/vda1        40G  9.3G   28G  25% /
tmpfs           379M     0  379M   0% /run/user/0

4.以数据库用户(如omm)登录节点,确认数据库状态Normal。

[omm@hecs-1105531 ~]$ gs_om -t status
--------------------------------------------------------------------

cluster_name    : ogCluster
cluster_state   : Normal
redistributing  : No

----------------------------------------------------------------------

5.以root用户执行如下命令对服务器的OS参数进行检查。检查服务器的OS参数的目的是为了保证数据库正常通过预安装,并且在安装成功后可以安全高效的运行。详细的检查项目请参见《工具参考》中的“服务端工具 > gs_checkos”工具。

cd /root/gauss_om/omm/script/
gs_checkos -i A

 

6.官网并没有单独的升级包,所以根据情况获取新的版本包。本次操作的基础版本是centos企业版,继续获取5.0.0企业版。
https://opengauss.org/zh/download.html

7.手动备份
升级一旦失败,有可能会影响到业务的正常开展。如有重要数据,请参考《数据库运维指南》中的“备份与恢复”章节,完成数据的备份。

1.4 升级操作

1.root用户创建新包目录。

mkdir -p /opt/software/gaussdb_upgrade

2.将需要更新的新包上传至目录“/opt/software/gaussdb_upgrade”并解压。

[root@hecs-1105531 script]# mkdir -p /opt/software/gaussdb_upgrade
[root@hecs-1105531 script]# cp /opt/software/openGauss-5.0.0-CentOS-64bit-all.tar.gz /opt/software/gaussdb_upgrade/
[root@hecs-1105531 script]# cd /opt/software/gaussdb_upgrade
[root@hecs-1105531 gaussdb_upgrade]# tar -zxvf openGauss-5.0.0-CentOS-64bit-all.tar.gz
[root@hecs-1105531 gaussdb_upgrade]# tar -zxvf openGauss-5.0.0-CentOS-64bit-om.tar.gz

3.进入安装包解压出的script目录下,在升级前执行前置脚本gs_preinstall。cluster_config.xml是之前安装基础版本时所使用的那个文件。

cd /opt/software/gaussdb_upgrade/script
./gs_preinstall -U omm -G dbgrp -X  /opt/software/openGauss/cluster_config.xml

执行过程如下

[root@hecs-1105531 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/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 hecs-1105531 --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.

4.切换至omm用户 使用如下命令进行就地升级或者灰度升级。最后提示successfully upgrade all nodes.就可以了。

[omm@hecs-1105531 ~]$ gs_upgradectl -t auto-upgrade -X /opt/software/openGauss/cluster_config.xml --grey
Static configuration matched with old static configuration files.
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 'hecs-1105531'.
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.
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_a07d57c3.
Successfully copy certs from /opt/huawei/install/app_02c14696 to /opt/huawei/install/app_a07d57c3.
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.
Start check CMS parameter.
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  hecs-1105531 192.168.0.243   15400      6001       P Primary Normal
Create checkpoint before switching.
Start to wait for om_monitor.
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 ['hecs-1105531'] 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/openGauss/cluster_config.xml

Successfully upgrade all nodes.

1.5 升级验证

以数据库用户(如omm)执行如下命令查看数据库状态,查询结果的cluster_state为Normal代表数据库正常。

gs_om -t status
gs_ssh -c "gsql -V"

 

用户可以自行验证其他数据库对象。

1.6 提交升级

升级完成后,如果验证也没问题,接下来就可以提交升级,需要注意的是,一旦提交操作完成,则不能再执行回滚操作。
以数据库用户(如omm)执行如下命令完成升级提交。

[omm@hecs-1105531 ~]$ gs_upgradectl -t commit-upgrade  -X /opt/software/openGauss/cluster_config.xml

 

至此,openGauss3.0.0升级5.0.0版本完成。

展开阅读全文
  • 0
    感动
  • 0
    路过
  • 0
    高兴
  • 0
    难过
  • 0
    搞笑
  • 0
    无聊
  • 0
    愤怒
  • 0
    同情
热度排行
友情链接