# 升级方式区别
就地升级:升级期间需停止业务进行,一次性升级所有节点。
灰度升级:灰度升级支持全业务操作,也是一次性升级所有节点。
指定节点升级:基于灰度升级,支持升级指定节点,支持部分节点升级。
注:升级前先备份一次数据,避免升级异常导致数据丢失
方式一:就地升级
1、检查版本及状态
# 检查系统状态
[root@keep-gbase8c-primary ~]# cd /data/install_pkgb24/script
[root@keep-gbase8c-primary script]# ./gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Warning
A6. [ System control parameters status ] : Warning
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:13. Abnormal numbers:0. Warning numbers:4.
[root@keep-gbase8c-primary script]#
# 检查数据库版本和状态
# 现版本为GBase8cV5 S5.0.0B10
[gbase@keep-gbase8c-primary ~]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B10 build 933ae03f) compiled at 2023-07-01 17:04:08 commit 0 last mr 206
[gbase@keep-gbase8c-primary ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 keep-gbase8c-primary 192.168.122.45 1 /data/gbase/install/cm/cm_server Primary
2 keep-gbase8c-standby 192.168.122.44 2 /data/gbase/install/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
------------------------------------------------------------------------------------------
1 keep-gbase8c-primary 192.168.122.45 6001 /data/gbase/install/data/dn P Primary Normal
2 keep-gbase8c-standby 192.168.122.44 6002 /data/gbase/install/data/dn S Standby Normal
2、上传新包,并解压
[gbase@keep-gbase8c-primary ~]$ cd /data/install_pkgb24/
[gbase@keep-gbase8c-primary install_pkgb24]$ tar -zxvf GBase8cV5_S5.0.0B24_centos7.8_x86_64.tar.gz
[gbase@keep-gbase8c-primary install_pkgb24]$ tar -zxvf GBase8cV5_S5.0.0B24_CentOS_x86_64_om.tar.gz
3、拷贝旧的安装模板,重新预安装
# 拷贝安装模板
[gbase@keep-gbase8c-primary install_pkgb24]$ cp /data/install_pkg/gbase.xml ./
[gbase@keep-gbase8c-primary install_pkgb24]$ more gbase.xml
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- 整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="GBase_8c" />
<!-- 数据库节点主机名(hostname) -->
<PARAM name="nodeNames" value="keep-gbase8c-primary,keep-gbase8c-standby" />
<!-- 数据库安装目录-->
<PARAM name="gaussdbAppPath" value="/data/gbase/install/app" />
<!-- 日志目录-->
<PARAM name="gaussdbLogPath" value="/data/gbase/log/om" />
<!-- 临时文件目录-->
<PARAM name="tmpMppdbPath" value="/data/gbase/tmp"/>
<!--数据库工具目录-->
<PARAM name="gaussdbToolPath" value="/data/gbase/install/tool" />
<!--数据库core文件目录-->
<PARAM name="corePath" value="/data/gbase/corefile"/>
<!-- 节点IP,与nodeNames一一对应 -->
<PARAM name="backIp1s" value="192.168.122.45,192.168.122.44"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的节点部署信息,sn:主机名 -->
<DEVICE sn="keep-gbase8c-primary">
<!-- 节点1 的主机名-->
<PARAM name="name" value="keep-gbase8c-primary"/>
<!-- 节点1 所在的AZ 及AZ优先级-->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.122.45"/>
<PARAM name="sshIp1" value="192.168.122.45"/>
<!-- cm主 -->
<PARAM name="cmsNum" value="1"/>
<!-- cm主: CM 安装目录 -->
<PARAM name="cmDir" value="/data/gbase/install/cm"/>
<PARAM name="cmServerPortBase" value="15300"/>
<PARAM name="cmServerListenIp1" value="192.168.122.45,192.168.122.44"/>
<PARAM name="cmServerHaIp1" value="192.168.122.45,192.168.122.44"/>
<!-- cmServerlevel目前只支持1 -->
<PARAM name="cmServerlevel" value="1"/>
<!-- cms主及所有备的hostname -->
<PARAM name="cmServerRelation" value="keep-gbase8c-primary,keep-gbase8c-standby"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/data/gbase/install/data/dn,keep-gbase8c-standby,/data/gbase/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- node2上的节点部署信息,其中“name”的值配置为主机名 -->
<DEVICE sn="keep-gbase8c-standby">
<!-- 节点 2 的主机名-->
<PARAM name="name" value="keep-gbase8c-standby"/>
<!-- 节点2 所在的AZ 及AZ优先级-->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.122.44"/>
<PARAM name="sshIp1" value="192.168.122.44"/>
<!-- cm目录 -->
<PARAM name="cmDir" value="/data/gbase/install/cm"/>
</DEVICE>
</DEVICELIST>
</ROOT>
# 执行预安装
[root@keep-gbase8c-primary install_pkgb24]# script/gs_preinstall -U gbase -G gbase -X gbase.xml
4、执行升级,会自动停数据库(auto-upgrade就地升级)
# 执行升级
[root@keep-gbase8c-primary install_pkgb24]# su - gbase
[gbase@keep-gbase8c-primary ~]$ cd /data/install_pkgb24/
[gbase@keep-gbase8c-primary install_pkgb24]$ gs_upgradectl -t auto-upgrade -X gbase.xml
Static configuration matched with old static configuration files.
Performing inplace rollback.
Rollback succeeded.
Checking upgrade environment.
Successfully checked upgrade environment.
Wait for the cluster status normal or degrade.
Start check CMS parameter.
Old cluster version number less than 92574.
Start to do health check.
Successfully checked cluster status.
Backing up current application and configurations.
Successfully backed up current application and configurations.
Stop cluster with gs_om successfully.
Backing up cluster configuration.
Successfully backup hotpatch config file.
Successfully backed up cluster configuration.
Installing new binary.
Restoring cluster configuration.
Successfully restored cluster configuration.
Stop cluster with gs_om successfully.
Modifying the socket path.
Successfully modified socket path.
copy certs from /data/gbase/install/app_933ae03f to /data/gbase/install/app_973db353.
Successfully copy certs from /data/gbase/install/app_933ae03f to /data/gbase/install/app_973db353.
Stop cluster with gs_om successfully.
Switch symbolic link to new binary directory.
Successfully switch symbolic link to new binary directory.
Stop cluster with gs_om successfully.
Waiting for the cluster status to become normal.
.
The cluster status is normal.
Start to do health check.
Successfully checked cluster status.
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 /data/install_pkgb24/gbase.xml
5、检查版本及状态
# 主节点
[gbase@keep-gbase8c-primary install_pkgb24]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B24 build 973db353) compiled at 2024-03-01 13:42:35 commit 0 last mr 484
[gbase@keep-gbase8c-primary install_pkgb24]$ gsql -p 15400 -d postgres
gsql ((single_node GBase8cV5 S5.0.0B24 build 973db353) compiled at 2024-03-01 13:42:35 commit 0 last mr 484 )
NOTICE : The password has been expired, please change the password.
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
# 备节点
[gbase@keep-gbase8c-standby ~]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B24 build 973db353) compiled at 2024-03-01 13:42:35 commit 0 last mr 484
[gbase@keep-gbase8c-standby ~]$ gsql -p 15400 -d postgres
gsql ((single_node GBase8cV5 S5.0.0B24 build 973db353) compiled at 2024-03-01 13:42:35 commit 0 last mr 484 )
NOTICE : The password has been expired, please change the password.
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
# 检查状态
6、执行命令提交升级
[gbase@keep-gbase8c-primary install_pkgb24]$ gs_upgradectl -t commit-upgrade -X /data/install_pkgb24/gbase.xml
NOTICE: Start to commit binary upgrade.
Start to check whether can be committed.
Can be committed.
Start to set commit flag.
Set commit flag succeeded.
Start to do operations that cannot be rollback.
Wait for the cluster status normal or degrade.
Cancel the upgrade status succeeded.
Start to clean temp files for upgrade.
Start check CMS parameter.
Old cluster version number less than 92574.
Clean up backup catalog files.
Successfully cleaned old install path.
Stop cluster with gs_om successfully.
Clean temp files for upgrade succeeded.
NOTICE: Commit binary upgrade succeeded.
------------------------------------------- 分割线 -------------------------------------------
方式二:灰度升级
注:测试过程中发现先把备节点升级,后把主节点升级。
1、检查版本及状态
# 检查系统状态
[root@keep-gbase8c-primary ~]# cd /data/install_pkgb26/script/
[root@keep-gbase8c-primary script]# ./gs_checkos -i A
Checking items:
A1. [ OS version status ] : Normal
A2. [ Kernel version status ] : Normal
A3. [ Unicode status ] : Normal
A4. [ Time zone status ] : Normal
A5. [ Swap memory status ] : Warning
A6. [ System control parameters status ] : Warning
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:13. Abnormal numbers:0. Warning numbers:4.
# 检查数据库版本和状态
# 现版本为GBase8cV5 S5.0.0B24
[gbase@keep-gbase8c-primary ~]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B24 build 973db353) compiled at 2024-03-01 13:42:35 commit 0 last mr 484
[gbase@keep-gbase8c-primary ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
-------------------------------------------------------------------------------------
1 keep-gbase8c-primary 192.168.122.45 1 /data/gbase/install/cm/cm_server Primary
2 keep-gbase8c-standby 192.168.122.44 2 /data/gbase/install/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
------------------------------------------------------------------------------------------
1 keep-gbase8c-primary 192.168.122.45 6001 /data/gbase/install/data/dn P Primary Normal
2 keep-gbase8c-standby 192.168.122.44 6002 /data/gbase/install/data/dn S Standby Normal
2、上传新包,并解压
[gbase@keep-gbase8c-primary ~]$ cd /data/install_pkgb26/
[gbase@keep-gbase8c-primary install_pkgb26]$ tar -zxvf GBase8cV5_S5.0.0B26_centos7.8_x86_64.tar.gz
[gbase@keep-gbase8c-primary install_pkgb26]$ tar -zxvf GBase8cV5_S5.0.0B26_CentOS_x86_64_om.tar.gz
3、拷贝旧的安装模板,重新预安装
# 拷贝安装模板
[gbase@keep-gbase8c-primary ~]$ cd /data/install_pkgb26/
[gbase@keep-gbase8c-primary install_pkgb26]$ cp /data/install_pkg/gbase.xml ./
[gbase@keep-gbase8c-primary install_pkgb26]$ cat gbase.xml
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- 整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="GBase_8c" />
<!-- 数据库节点主机名(hostname) -->
<PARAM name="nodeNames" value="keep-gbase8c-primary,keep-gbase8c-standby" />
<!-- 数据库安装目录-->
<PARAM name="gaussdbAppPath" value="/data/gbase/install/app" />
<!-- 日志目录-->
<PARAM name="gaussdbLogPath" value="/data/gbase/log/om" />
<!-- 临时文件目录-->
<PARAM name="tmpMppdbPath" value="/data/gbase/tmp"/>
<!--数据库工具目录-->
<PARAM name="gaussdbToolPath" value="/data/gbase/install/tool" />
<!--数据库core文件目录-->
<PARAM name="corePath" value="/data/gbase/corefile"/>
<!-- 节点IP,与nodeNames一一对应 -->
<PARAM name="backIp1s" value="192.168.122.45,192.168.122.44"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的节点部署信息,sn:主机名 -->
<DEVICE sn="keep-gbase8c-primary">
<!-- 节点1 的主机名-->
<PARAM name="name" value="keep-gbase8c-primary"/>
<!-- 节点1 所在的AZ 及AZ优先级-->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.122.45"/>
<PARAM name="sshIp1" value="192.168.122.45"/>
<!-- cm主 -->
<PARAM name="cmsNum" value="1"/>
<!-- cm主: CM 安装目录 -->
<PARAM name="cmDir" value="/data/gbase/install/cm"/>
<PARAM name="cmServerPortBase" value="15300"/>
<PARAM name="cmServerListenIp1" value="192.168.122.45,192.168.122.44"/>
<PARAM name="cmServerHaIp1" value="192.168.122.45,192.168.122.44"/>
<!-- cmServerlevel目前只支持1 -->
<PARAM name="cmServerlevel" value="1"/>
<!-- cms主及所有备的hostname -->
<PARAM name="cmServerRelation" value="keep-gbase8c-primary,keep-gbase8c-standby"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/data/gbase/install/data/dn,keep-gbase8c-standby,/data/gbase/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- node2上的节点部署信息,其中“name”的值配置为主机名 -->
<DEVICE sn="keep-gbase8c-standby">
<!-- 节点 2 的主机名-->
<PARAM name="name" value="keep-gbase8c-standby"/>
<!-- 节点2 所在的AZ 及AZ优先级-->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.122.44"/>
<PARAM name="sshIp1" value="192.168.122.44"/>
<!-- cm目录 -->
<PARAM name="cmDir" value="/data/gbase/install/cm"/>
</DEVICE>
</DEVICELIST>
</ROOT>
# 执行预安装
[root@keep-gbase8c-primary install_pkgb26]# script/gs_preinstall -U gbase -G gbase -X gbase.xml
4、执行灰度升级
# 执行升级
[root@keep-gbase8c-primary install_pkgb26]# su - gbase
[gbase@keep-gbase8c-primary ~]$ cd /data/install_pkgb26/
[gbase@keep-gbase8c-primary install_pkgb26]$ gs_upgradectl -t auto-upgrade -X gbase.xml --grey
# 如果想监控集群状态,可以重起一个终端,循环执行以下命令
# 检查数据库版本
gs_ssh -c "gsql -p 15400 -d postgres -c 'select version()'"
# 检查数据库状态
gs_om -t status --detail
5、检查版本及状态
# 主节点
[gbase@keep-gbase8c-primary ~]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B26 build aedab09d) compiled at 2024-04-16 15:03:11 commit 0 last mr 532
[gbase@keep-gbase8c-primary ~]$ gsql -p 15400 -d postgres
gsql ((single_node GBase8cV5 S5.0.0B26 build aedab09d) compiled at 2024-04-16 15:03:11 commit 0 last mr 532 )
NOTICE : The password has been expired, please change the password.
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
# 备节点
[gbase@keep-gbase8c-standby ~]$ gsql -V
gsql (single_node GBase8cV5 S5.0.0B26 build aedab09d) compiled at 2024-04-16 15:03:11 commit 0 last mr 532
[gbase@keep-gbase8c-standby ~]$ gsql -p 15400 -d postgres
gsql ((single_node GBase8cV5 S5.0.0B26 build aedab09d) compiled at 2024-04-16 15:03:11 commit 0 last mr 532 )
NOTICE : The password has been expired, please change the password.
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
# 检查状态
6、执行命令提交升级
[gbase@keep-gbase8c-primary install_pkgb26]$ gs_upgradectl -t commit-upgrade -X /data/install_pkgb26/gbase.xml
Wait for the cluster status normal or degrade.
Start check CMS parameter.
Old cluster version number less than 92574.
Start to do health check.
Successfully checked cluster status.
Start check CMS parameter.
Old cluster version number less than 92574.
Successfully cleaned old install path.
Commit upgrade succeeded.
Start check CMS parameter.
Old cluster version number less than 92574.
------------------------------------------- 分割线 -------------------------------------------
方式三:指定节点升级
----------待更新