前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >openGauss数据库从3.0.0升级到3.1.0操作实践

openGauss数据库从3.0.0升级到3.1.0操作实践

作者头像
大柏树
发布2022-12-13 10:04:11
3310
发布2022-12-13 10:04:11
举报
文章被收录于专栏:数据库运维笔记

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

具体就不再一一列举,主要就是升级期间不要做增删改,生产和商业环境务必按照要求执行。

►►►

升级前准备

1. 检查升级前版本

代码语言:javascript
复制
[omm@pekphisprb70593 ~]$ gsql --version

gsql (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr

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

代码语言:javascript
复制
[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

3. 以数据库用户(如omm)登录节点,执行如下命令查看数据库状态,确认cluster_state : Normal。

代码语言:javascript
复制
[omm@pekphisprb70593 ~]$ gs_om -t status

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

cluster_name    : opengSingle

cluster_state   : Normal

redistributing  : No

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

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

代码语言:javascript
复制
gs_checkos -i A

5. 在官网获取新的版本安装包:

https://opengauss.org/zh/download.html

6. 手动备份

根据需要多一重备份,可在升级前自己先建个表,验证升级后是不是正常。

►►►

升级操作

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

代码语言:javascript
复制
mkdir -p /opt/software/gaussdb_upgrade

2.将需要更新的新包上传至目录“/opt/software/gaussdb_upgrade”并解压,把之前旧版本使用的cluster_config.xml也拷贝过来。

3. 修改属主

代码语言:javascript
复制
[root@pekphisprb70593 software]# chown -R omm:dbgrp gaussdb_upgrade/

4. 进入安装包解压出的script目录下,在升级前执行前置脚本gs_preinstall。

代码语言:javascript
复制
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安装包目录下。

代码语言:javascript
复制
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
make
make install

重新执行gs_preinstall命令成功。

代码语言:javascript
复制
[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.

5. 切换至omm用户 使用如下命令进行就地升级或者灰度升级。

代码语言:javascript
复制
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环境变量,执行如下命令查看所有节点的版本信息。

代码语言:javascript
复制
[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代表数据库正常。

代码语言:javascript
复制
[omm@pekphisprb70593 script]$ gs_om -t status

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

cluster_name    : opengSingle

cluster_state   : Normal

redistributing  : No

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

原来的数据也在,新建也正常。

代码语言:javascript
复制
opengauss_db=# select * from test1;

id

----

1

(1 row)

►►►

提交升级

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

以数据库用户(如omm)执行如下命令完成升级提交。

代码语言:javascript
复制
gs_upgradectl -t commit-upgrade  -X /opt/software/gaussdb_upgrade/cluster_config.xml

至此,升级完成。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-12-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 数据库运维笔记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档