目录
一、概述
二、注意事项
扩容注意事项
扩容前提条件
缩容注意事项
缩容前提条件
三、规划
四、缩容
五、扩容
gs_expansion工具对数据库的备机进行扩容,支持从单机或者一主多备最多扩容到一主八备。
gs_dropnode工具从一主多备的数据库中移除不需要的备机,最多可以删除到只剩下单机。
本文计划从一主两备先缩容到一主一备,再扩容回一主两备。
从主备数据库实例中移除当前仍可连通的备机时,会自动停止目标备机上正在运行的数据库服务,并删除备机上的GRPC证书(证书位置:$GAUSSHOME/share/sslcert/grpc/),但是不会删除备机上的应用。
如果删除后数据库实例中只剩下一个主机时,会提示建议重启当前主机,此时建议用户根据当前业务运行环境重启主机。
如果目标备机在执行操作前处于不可连通的状态,需要用户在目标备机恢复后手动停止或删除目标备机的数据库服务,并删除备机上的GRPC证书(证书位置:$GAUSSHOME/share/sslcert/grpc/)。
仅支持使用om方式安装的主备数据库实例中移除备机,不支持使用编译方式安装组建的主备数据库。
当移除的备机处于同步复制模式时,如果执行删除命令的同时主机上存在事务操作,事务提交时会出现短暂卡顿,删除完成后事务处理可继续。
当目标备机被移除后,如果暂时不确定是否需要目标备机,可以选择如下方法拒绝从目标备机的远程ssh连接,避免在目标备机上的误操作。
方式一:在当前主机上使用root用户修改/etc/ssh/sshd_config文件,添加如下记录(如果已存在DenyUsers记录,请在后面追加)DenyUsers [email protected],修改后需要重启ssh服务使其生效,修改后限制从目标备机不能使用omm用户远程到该主机。
方式二:在当前主机上将目标备机加入到/etc/hosts.deny文件中(例如:sshd:10.11.12.13:deny),拒绝从目标备机的远程ssh连接(对所有用户生效),此方法需要系统sshd服务绑定到libwrap库。
当目标备机被移除后,如果需要以备机方式使用目标备机,请参考gs_expansion命令重新将目标备机添加到集群中。
当前为一主两备,计划以node6为例进行缩容、扩容
序号 | 节点 | IP | 节点 |
1 | node4 | 192.168.5.7 | Primary |
2 | node5 | 192.168.5.8 | Standby |
3 | node6 | 192.168.5.9 | Standby |
1、当前节点状态查看
gs_om -t status --detail
2、执行缩容
主节点执行
gs_dropnode -U omm -G dbgrp -h 192.168.5.9
[omm@node4 dn]$ gs_dropnode -U omm -G dbgrp -h 192.168.5.9
The target node to be dropped is (['node6'])
Do you want to continue to drop the target node (yes/no)?yes
Drop node start with CM node.
Drop node with CM node is running.
[gs_dropnode]Start to drop nodes of the cluster.
[gs_dropnode]Start to stop the target node node6.
[gs_dropnode]End of stop the target node node6.
[gs_dropnode]Start to backup parameter config file on node4.
[gs_dropnode]End to backup parameter config file on node4.
[gs_dropnode]The backup file of node4 is /opt/opengauss/tmp/gs_dropnode_backup20230518232958/parameter_node4.tar
[gs_dropnode]Start to parse parameter config file on node4.
Command for Checking VIP mode: cm_ctl res --list | awk -F "|" '{print $2}' | grep -w ***
The current cluster does not support VIP.
[gs_dropnode]End to parse parameter config file on node4.
[gs_dropnode]Start to parse backup parameter config file on node4.
[gs_dropnode]End to parse backup parameter config file node4.
[gs_dropnode]Start to set openGauss config file on node4.
[gs_dropnode]End of set openGauss config file on node4.
[gs_dropnode]Start to backup parameter config file on node5.
[gs_dropnode]End to backup parameter config file on node5.
[gs_dropnode]The backup file of node5 is /opt/opengauss/tmp/gs_dropnode_backup20230518232959/parameter_node5.tar
[gs_dropnode]Start to parse parameter config file on node5.
Command for Checking VIP mode: cm_ctl res --list | awk -F "|" '{print $2}' | grep -w ***
The current cluster does not support VIP.
[gs_dropnode]End to parse parameter config file on node5.
[gs_dropnode]Start to parse backup parameter config file on node5.
[gs_dropnode]End to parse backup parameter config file node5.
[gs_dropnode]Start to set openGauss config file on node5.
[gs_dropnode]End of set openGauss config file on node5.
[gs_dropnode]Start of set pg_hba config file on node4.
[gs_dropnode]End of set pg_hba config file on node4.
[gs_dropnode]Start of set pg_hba config file on node5.
[gs_dropnode]End of set pg_hba config file on node5.
[gs_dropnode]Start to set repl slot on node4.
[gs_dropnode]Start to get repl slot on node4.
[gs_dropnode]End of set repl slot on node4.
Command for Checking VIP mode: cm_ctl res --list | awk -F "|" '{print $2}' | grep -w ***
The current cluster does not support VIP.
Stopping node.
=========================================
Successfully stopped node.
=========================================
End stop node.
Generate drop flag file on drop node node6 successfully.
[gs_dropnode]Start to modify the cluster static conf.
[gs_dropnode]End of modify the cluster static conf.
Restarting cm_server cluster ...
Remove dynamic_config_file and CM metadata directory on all nodes.
[gs_dropnode] Success to drop the target nodes.
3、验证
gs_om -t status --detail
4、删除备机上的数据
gs_uninstall --delete-data -L
扩容前需要将待扩容环境的配置及环境准备好,主节点需要修改好xml文件,由于本文中是直接缩容过来的,所以xml可以不用修改
1、xml配置文件
2、执行扩容
root用户执行
cd /opt/software/openGauss
./script/gs_expansion -U omm -G dbgrp -X cluster_config.xml -h 192.168.5.9
[root@node4 openGauss]# ./script/gs_expansion -U omm -G dbgrp -X cluster_config.xml -h 192.168.5.9
Start expansion with cluster manager component.
Start to send soft to each standby nodes.
End to send soft to each standby nodes.
Success to send XML to new nodes
Start to perform perinstall on nodes: ['node6']
Preinstall command is: /tmp/gs_expansion_2023-05-18_23_47_48_445377/pkg/script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml -L --non-interactive 2>&1
Success to perform perinstall on nodes ['node6']
Success to change user to [omm]
Installing applications on all new nodes.
Install on new node output: [SUCCESS] node6:
Using omm:dbgrp to install database.
Using installation program path : /opt/opengauss/app
Command for creating symbolic link: ln -snf /opt/opengauss/app_a07d57c3 /opt/opengauss/app.
Decompressing bin file.
Decompress CM package command: export LD_LIBRARY_PATH=$GPHOME/script/gspylib/clib:$LD_LIBRARY_PATH && tar -zxf "/opt/opengauss/om/script/os_platform/./../../openGauss-5.0.0-CentOS-64bit-cm.tar.gz" -C "/opt/opengauss/app"
Decompress CM package successfully.
Successfully decompressed bin file.
Modifying Alarm configuration.
Modifying user's environmental variable $GAUSS_ENV.
Successfully modified user's environmental variable $GAUSS_ENV.
Fixing file permission.
Set Cgroup config file to appPath.
Successfully Set Cgroup.
Successfully installed APP on nodes ['node6'].
success to send all CA file.
Success to change user to [omm]
Success to init instance on nodes ['node6']
Start to generate and send cluster static file.
End to generate and send cluster static file.
The current cluster does not support VIP.
Ready to perform command on node [node6]. Command is : source /home/omm/.bashrc;gs_guc set -D /opt/opengauss/data/dn -h 'host all omm 192.168.5.9/32 trust' -h 'host all all 192.168.5.9/32 sha256'
Successfully set hba on all nodes.
Success to change user to [omm]
Remove dynamic_config_file and CM metadata directory on all nodes.
Expansion results:
192.168.5.9: Success
异常1:
[GAUSS-51802] : Failed to obtain the environment variable "GPHOME", please import environment variable.
因root用户没有配置环境变量,将omm用户~/.bashrc文件中openGauss相关的环境变量拷贝过来即可
3、验证
gs_om -t status --detail
参考文章:MogDB/openGauss 3.0 扩容及缩容 - 墨天轮