openGauss 3.0.0升级到3.1.0一主一备一级联
主库:
192.168.6.201 ccf10
备库:
192.168.6.202 ccf11
级联备库:
192.168.6.203 ccf12
一、升级前准备及检查:
1.升级前尽可能保证数据库正常且主DN的数据完全同步到备DN。
可以通过gs_om -t status查询,查询结果的cluster_state为Normal代表数据库正常
[omm@ccf10 ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_state : Normal
redistributing : No
balanced : Yes
-----------------------------------------------------------------------
[omm@ccf10 ~]$ cm_ctl query -Cv
[ CMServer State ]
node instance state
-------------------------
1 ccf10 1 Primary
2 ccf11 2 Standby
3 ccf12 3 Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node instance state | node instance state | node instance state
---------------------------------------------------------------------------------------------------------------
1 ccf10 6001 P Primary Normal | 2 ccf11 6002 S Standby Normal | 3 ccf12 6003 C Cascade Standby Normal
[omm@ccf11 ~]$ gs_ctl query
[2022-11-09 09:31:49.461][11846][][gs_ctl]: gs_ctl query ,datadir is /data/openGauss
HA state:
local_role : Standby
static_connections : 2
db_state : Normal
detail_information : Normal
Senders info:
sender_pid : 3432
local_role : Standby
peer_role : Cascade Standby
peer_state : Normal
state : Streaming
sender_sent_location : 0/7011988
sender_write_location : 0/7011988
sender_flush_location : 0/7011988
sender_replay_location : 0/7011988
receiver_received_location : 0/7011988
receiver_write_location : 0/7011988
receiver_flush_location : 0/7011988
receiver_replay_location : 0/7011988
sync_percent : 100%
sync_state : Async
sync_priority : 0
sync_most_available : Off
channel : 192.168.6.202:15401-->192.168.6.203:35120
Receiver info:
receiver_pid : 3203
local_role : Standby
peer_role : Primary
peer_state : Normal
state : Normal
sender_sent_location : 0/7011988
sender_write_location : 0/7011988
sender_flush_location : 0/7011988
sender_replay_location : 0/7011988
receiver_received_location : 0/7011988
receiver_write_location : 0/7011988
receiver_flush_location : 0/7011988
receiver_replay_location : 0/7011988
sync_percent : 100%
channel : 192.168.6.202:43524<--192.168.6.201:15401
[omm@ccf11 ~]$
2.升级前要保证操作系统处于健康状态,通过gs_checkos工具可以完成操作系统状态检查。
[root@ccf10 ~]# 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 ] : Normal
A6. [ System control parameters status ] : Normal
A7. [ File system configuration status ] : Normal
A8. [ Disk configuration status ] : Normal
A9. [ Pre-read block size status ] : Normal
A10.[ IO scheduler status ] : Normal
BondMode Null
A11.[ Network card configuration status ] : Warning
A12.[ Time consistency status ] : Warning
A13.[ Firewall service status ] : Normal
A14.[ THP service status ] : Normal
Total numbers:14. Abnormal numbers:0. Warning numbers:2.
[root@ccf10 ~]#
3.升级需要guc参数enable_stream_replication=on,该参数为off时不允许升级。
检查该参数
[omm@ccf11 ~]$ gs_guc check -N all -I all -c "enable_stream_replication"
设置该参数
[omm@ccf11 ~]$ gs_guc set -N all -I all -c "enable_stream_replication=on"
4.opengauss共享存储模式不支持版本升级。
5.升级前保证数据库互信正常
6.PL/Java升级约束
从3.0.0及其之前版本升级到3.1.0及其后续版本时,如果业务使用PL/Java功能且数据库实例所在机器上不存在java环境时,升级前check检查将失败。因此需提前确认是否使用到PL/Java功能和当前的JAVA版本。检查方法为:
1)在数据库中使用初始化用户执行“select count(1) from pg_proc where prolang = 15;”命令。
如果结果> 0,说明数据库使用了PL/Java,参考2进一步检查是否有Java环境。
如果结果= 0,说明数据库没有使用PL/Java。则结束本校验,执行其他校验流程。
2)在操作系统中使用root用户执行“java -version”命令。
java -version
如果Java存在,且版本等于或高于JDK1.8,则结束本校验,执行其他校验流程。
如果Java不存在或版本低于JDK1.8,则需要参考3进行JDK的下载及Java环境变量的配置。
3)JDK的下载及Java环境变量的配置。
可从官网下载或者使用此链接下载:https://www.hikunpeng.com/zh/developer/devkit/compiler/jdk,并通过以下方式配置环境变量:
export JAVA_HOME=/xxx/jdk1.xxx
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
7.检查数据库节点磁盘使用率
建议数据库节点磁盘使用率低于80%时再执行升级操作
[omm@ccf10 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.3G 0 2.3G 0% /dev
tmpfs 2.3G 12K 2.3G 1% /dev/shm
tmpfs 2.3G 9.2M 2.3G 1% /run
tmpfs 2.3G 0 2.3G 0% /sys/fs/cgroup
/dev/mapper/klas-root 46G 12G 34G 26% /
tmpfs 2.3G 12K 2.3G 1% /tmp
/dev/sda1 1014M 211M 804M 21% /boot
tmpfs 468M 0 468M 0% /run/user/1000
tmpfs 468M 0 468M 0% /run/user/993
tmpfs 468M 0 468M 0% /run/user/0
[omm@ccf10 ~]$
8.备份数据
gs_backup -t backup --backup-dir=/data/backup --all
可在升级前自己先建个表,验证升级后是不是正常。
mydb=# select * from chen01;
id
-----
111
(1 row)
9.获取升级包openGauss-3.1.0-openEuler-64bit-all.tar.gz
https://www.opengauss.org/zh/download/
10.检查gsql版本
[omm@ccf10 ~]$ gsql --version
gsql (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:19 commit 0 last mr
[omm@ccf10 ~]$
二、就地升级或灰度升级操作步骤
以root身份登录节点。
创建新包目录。
mkdir -p /opt/software/gaussdb_upgrade
将需要更新的新包上传至目录“/opt/software/gaussdb_upgrade”并解压。
cd /opt/software/gaussdb_upgrade
tar -zxvf openGauss-3.1.0-openEuler-64bit-all.tar.gz
tar -zxvf openGauss-3.1.0-openEuler-64bit-om.tar.gz
chown -R omm:dbgrp /opt/software/gaussdb_upgrade/
进入安装包解压出的script目录下:
cd /opt/software/gaussdb_upgrade/script
在就地升级或灰度升级前执行前置脚本gs_preinstall
[root@ccf10 script]# ./gs_preinstall -U omm -G dbgrp -X /home/omm/cluster_config.xml
Warnging version of python doesnot meet the expection, maybe third-party libs need to be compiled by yourself
Warnging version of python doesnot meet the expection, maybe third-party libs need to be compiled by yourself
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Are you sure you want to create trust for root (yes/no)?yes
Please enter password for root
Password:
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
Distributing package.
Begin to distribute package to tool path.
Successfully distribute package to tool path.
Begin to distribute package to package path.
Successfully distribute package to package path.
Successfully distributed package.
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Preparing SSH service.
Successfully prepared SSH service.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Please enter password for current user[omm].
Password:
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [omm] user.
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 ccf10,ccf11,ccf12 --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.
chmod -R 755 /opt/software/gaussdb_upgrade/
chown -R omm:dbgrp /opt/software/gaussdb_upgrade/
切换至omm用户。此时gs_om -V查看已变成3.1.0,而 gs_ssh -c "gsql -V"查看还未发生变化依旧是3.0.0
灰度升级
就地升级没有--grey参数
[omm@ccf10 ~]$ /opt/software/gaussdb_upgrade/script/gs_upgradectl -t auto-upgrade -X /home/omm/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 all nodes.
NOTICE: The directory /opt/openGauss/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/openGauss/install/app_02c14696 will be deleted after commit-upgrade, please make sure there is no personal data.
Installing new binary.
Wait for the cluster status normal or degrade.
copy certs from /opt/openGauss/install/app_02c14696 to /opt/openGauss/install/app_4e931f9a.
Successfully copy certs from /opt/openGauss/install/app_02c14696 to /opt/openGauss/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 ccf10 192.168.6.201 15400 6001 P Primary Normal
2 ccf11 192.168.6.202 15400 6002 S Standby Normal
3 ccf12 192.168.6.203 15400 6003 C Cascade Normal
Wait for the cluster status normal or degrade.
Wait for the cluster status normal or degrade.
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 ['ccf10', 'ccf11', 'ccf12'] 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 /home/omm/cluster_config.xml
Successfully upgrade all nodes.
[omm@ccf10 ~]$
三、升级验证
版本查询
[omm@ccf10 ~]$ source .bashrc #所有节点
[omm@ccf10 ~]$ gs_ssh -c "gsql -V"
Successfully execute command on all nodes.
Output:
[SUCCESS] ccf10:
gsql (openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr
[SUCCESS] ccf11:
gsql (openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr
[SUCCESS] ccf12:
gsql (openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr
数据库状态查询
[omm@ccf10 ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_state : Normal
redistributing : No
balanced : Yes
-----------------------------------------------------------------------
[omm@ccf10 ~]$ cm_ctl query -Cv
[ CMServer State ]
node instance state
-------------------------
1 ccf10 1 Standby
2 ccf11 2 Primary
3 ccf12 3 Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node instance state | node instance state | node instance state
---------------------------------------------------------------------------------------------------------------
1 ccf10 6001 P Primary Normal | 2 ccf11 6002 S Standby Normal | 3 ccf12 6003 C Cascade Standby Normal
[omm@ccf10 ~]$
数据验证
[omm@ccf10 ~]$ gsql -d postgres -r
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# \c mydb
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "mydb" as user "omm".
mydb=# select * from chen01;
id
-----
111
(1 row)
mydb=#
四、提交升级
[omm@ccf10 ~]$ /opt/software/gaussdb_upgrade/script/gs_upgradectl -t commit-upgrade -X /home/omm/cluster_config.xml
Start to do health check.
Successfully checked cluster status.
Wait for the cluster status normal or degrade.
Wait for the cluster status normal or degrade.
Successfully cleaned old install path.
Commit upgrade succeeded.
[omm@ccf10 ~]$