首页 > 其他分享 >MogDB/openGauss 3.0 扩容及缩容

MogDB/openGauss 3.0 扩容及缩容

时间:2024-03-25 11:13:12浏览次数:20  
标签:缩容 gs MogDB 备机 dropnode Start xx file openGauss

MogDB/openGauss 3.0 扩容及缩容
本文出处:https://www.modb.pro/db/452139

一、概述
背景信息
gs_expansion 工具对数据库的备机进行扩容,支持从单机或者一主多备最多扩容到一主八备,本文从一主一备扩容到一主两备。

gs_dropnode 工具从一主多备的数据库中移除不需要的备机,最多可以删除到只剩下单机,本文从一主两备缩容到一主一备。

扩容注意事项
扩容后不会自动更新 synchronous_standby_names 参数。如果需要为该参数增加扩容的机器,请在扩容完成后手动更新。
扩容级联备之前要确保原集群中有处于同一 AZ(Available Zone)且状态正常的备机,或扩容级联备的同时也扩容了处于同 AZ 的备机。
对数据库集群进行扩容前,需要关注主机及新扩容节点 CPU、IO、网络等情况,不建议在硬件压力较大时执行扩容,否则可能导致扩容耗时较长甚至扩容失败。
当原集群数据量较大时,在进行扩容操作前应当在主机上先执行 checkpoint,否则可能导致扩容耗时较长甚至扩容失败。
在单节点扩容时,如果节点 hot_standby 被关闭过,则需要在每个备节点上也按照如下流程修改
备节点需要先修改 wal_level 大于等于 hot_standby 后重启
然后再修改 hot_standby 为 on 重启,之后主机扩容才能成功。否则扩容时备机会启动失败
扩容前提条件
数据库主机上存在 MogDB 镜像包,解压镜像包后,在 script 目录下执行./gs_expansion 命令进行扩容。
在新增的扩容备机上创建好与主机上相同的用户和用户组。
已存在的数据库节点和新增的扩容节点之间需要建立好 root 用户互信以及数据库管理用户(如 omm)的互信。
正确配置 xml 文件,在已安装数据库配置文件的基础上,添加需要扩容的备机信息。
只能使用 root 用户执行 gs_expansion 命令。
不允许同时在主节点上执行 gs_dropnode 命令删除其他备机。
执行扩容命令前需要通过 source 命令导入主机数据库的环境变量。如果当前数据库是分离环境变量方式安装,则 source 导入分离的环境变量。如果未进行分离,则需要 source 导入子用户的.bashrc 配置文件。一般该文件路径为:/home/[user]/.bashrc。
扩容备机的操作系统与主机保持一致。
操作过程中不允许同时在其他备节点上执行主备倒换或者故障倒换的操作。
不允许同时执行 2 次相同的 gs_expansion 命令。
扩容备节点的操作只能在主节点上执行。
缩容注意事项
从主备数据库实例中移除当前仍可连通的备机时,会自动停止目标备机上正在运行的数据库服务,并删除备机上的 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_uninstall -delete-data -L 命令单点卸载,请注意务必添加-L 选项。
当目标备机被移除后,如果需要以单机方式使用目标备机且保留原数据,请在目标备机上先执行 gs_guc set -D /gaussdb/data/dbnode -c “replconninfoX”,其中/gaussdb/data/dbnode 表示数据目录,replconninfoX 表示主备集群中的除本节点外的其他节点,比如一主一备则需要配置 replconninfo1, 一主两备需要配置 replconninfo1 和 replconninfo2, 以此类推;如果无需保留原数据,请先执行 gs_uninstall -delete-data -L 命令卸载后重新安装。
当目标备机被移除后,如果需要以备机方式使用目标备机,请参考 gs_expansion 命令重新将目标备机添加到集群中。
缩容前提条件
删除备节点的操作只能在主节点上执行。
操作过程中不允许同时在其他备节点上执行主备倒换或者故障倒换的操作。
不允许同时在主节点上执行 gs_expansion 命令进行扩容。
不允许同时执行 2 次相同的 gs_dropnode 命令。
执行删除操作前,需要确保主节点和备节点之间建立好 omm 用户(数据库管理用户)的互信。
需要使用数据库管理用户(比如 omm)执行该命令。
执行命令前需要通过 source 命令导入主机数据库的环境变量。如果当前数据库是分离环境变量方式安装,则 source 导入分离的环境变量。如果未进行分离,则需要 source 导入子用户的.bashrc 配置文件。一般该文件路径为:/home/[user]/.bashrc.
在新节点进行相关配置

二、关闭防火墙 selinux
[root@test3 ~]# setenforce 0
[root@test3 ~]# sed -i '/^SELINUX=/c'SELINUX=disabled /etc/selinux/config
[root@test3 ~]# systemctl disable firewalld.service
[root@test3 ~]# systemctl stop firewalld.service
三、创建用户和组
[root@test3 ~]# groupadd -g 1001 dbgrp
[root@test3 ~]# useradd -g dbgrp omm
[root@test3 ~]# passwd omm
四、配置三个节点的互信
[root@test3 ~]# ssh-keygen
[root@test3 ~]# ssh-copy-id xx.xxx.xx.xx
[root@test3 ~]# ssh-copy-id xx.xxx.xx.xx
其余两机器一样

五、安装 Python3 及依赖包
[root@test3 ~]# yum install -y libaio-devel gcc gcc-c++ zlib-devel expect
[root@test3 ~]# mkdir -p /usr/local/python3
[root@test3 ~]# tar -zxvf Python-3.6.5.tgz
[root@test3 ~]# cd Python-3.6.5
[root@test3 ~]# ./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC && make && make install
[root@test3 ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@test3 ~]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@test3 ~]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /lib64/
在主库进行相关配置

六、编写 clusterconfig.xml
添加新节点信息
[omm@test1 script]$ cat clusterconfig.xml

  <!--dn-->
        <PARAM name="dataNum" value="1"/>
  <PARAM name="dataPortBase" value="26000"/>
  <PARAM name="dataNode1" value="/dbdata/data,test2,/dbdata/data/,test3,/dbdata/data/"/>
  <!--数据库主节点上的xlog目录,及备机xlog目录-->
   <PARAM name="dataNodeXlogPath1" value="/dbdata/xlog,/dbdata/xlog,/dbdata/xlog "/>
        <PARAM name="dataNode1_syncNum" value="0"/>
    </DEVICE>

    <!-- 节点2上的节点部署信息,其中“name”的值配置为主机名称 -->
    <DEVICE sn="test2">
        <!-- 节点2的主机名称 -->
        <PARAM name="name" value="test2"/>
        <!-- 节点2所在的AZ及AZ优先级 -->
        <PARAM name="azName" value="AZ1"/>
        <PARAM name="azPriority" value="1"/>
        <!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
        <PARAM name="backIp1" value="xx.xxx.xx.xx"/>
        <PARAM name="sshIp1" value="xx.xxx.xx.xx"/>
    <!-- 节点3上的节点部署信息,其中“name”的值配置为主机名称 -->
    <DEVICE sn="test3">
        <!-- 节点3的主机名称 -->
        <PARAM name="name" value="test3"/>
        <!-- 节点3所在的AZ及AZ优先级 -->
        <PARAM name="azName" value="AZ1"/>
        <PARAM name="azPriority" value="1"/>
        <!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
        <PARAM name="backIp1" value="xx.xxx.xx.xx"/>
        <PARAM name="sshIp1" value="xx.xxx.xx.xx"/>
七、扩容 [root@test1 script]# ./gs_expansion -U omm -G dbgrp -X clusterconfig.xml -h xx.xxx.xx.xx Start expansion without cluster manager component. Start to preinstall database on new nodes. Start to send soft to each standby nodes. End to send soft to each standby nodes. Start to preinstall database step. Preinstall xx.xxx.xx.xx success End to preinstall database step. End to preinstall database on new nodes.

Start to install database on new nodes.
Installing database on node xx.xxx.xx.xx:
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /dbdata/app/mogdb/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.
end deploy..
xx.xxx.xx.xx install success.
Finish to install database on all nodes.
Database on standby nodes installed finished.

Checking mogdb and gs_om version.
End to check mogdb and gs_om version.

Start to establish the relationship.
Start to build standby xx.xxx.xx.xx.
Build standby xx.xxx.xx.xx success.
Start to generate and send cluster static file.
End to generate and send cluster static file.

Expansion results:
xx.xxx.xx.xx: Success
Expansion Finish.
[omm@test1 ~]$ gs_om -t status --detail
[ Cluster State ]

cluster_state : Normal
redistributing : No
current_az : AZ_ALL

[ Datanode State ]

node          node_ip         port      instance             state

1 test1 xx.xxx.xx.xx 26000 6001 /dbdata/data P Primary Normal
2 test2 xx.xxx.xx.xx 26000 6002 /dbdata/data S Standby Normal
3 test3 xx.xxx.xx.xx 26000 6003 /dbdata/data S Standby Normal
八、缩容
[omm@test1 ~]$ gs_dropnode -U omm -G dbgrp -h xx.xxx.xx.xx
The target node to be dropped is (['sticmesdbtest3'])
Do you want to continue to drop the target node (yes/no)?yes
Drop node start without CM node.
[gs_dropnode]Start to drop nodes of the cluster.
[gs_dropnode]Start to stop the target node sticmesdbtest3.
[gs_dropnode]End of stop the target node sticmesdbtest3.
[gs_dropnode]Start to backup parameter config file on test1.
[gs_dropnode]End to backup parameter config file on test1.
[gs_dropnode]The backup file of test1 is /dbdata/mogdb/tmp/gs_dropnode_backup20220804104024/parameter_test1.tar
[gs_dropnode]Start to parse parameter config file on test1.
[gs_dropnode]End to parse parameter config file on test1.
[gs_dropnode]Start to parse backup parameter config file on test1.
[gs_dropnode]End to parse backup parameter config file test1.
[gs_dropnode]Start to set openGauss config file on test1.
[gs_dropnode]End of set openGauss config file on test1.
[gs_dropnode]Start to backup parameter config file on test2.
[gs_dropnode]End to backup parameter config file on test2.
[gs_dropnode]The backup file of test2 is /dbdata/mogdb/tmp/gs_dropnode_backup20220804104026/parameter_test2.tar
[gs_dropnode]Start to parse parameter config file on test2.
[gs_dropnode]End to parse parameter config file on test2.
[gs_dropnode]Start to parse backup parameter config file on test2.
[gs_dropnode]End to parse backup parameter config file test2.
[gs_dropnode]Start to set openGauss config file on test2.
[gs_dropnode]End of set openGauss config file on test2.
[gs_dropnode]Start of set pg_hba config file on test1.
[gs_dropnode]End of set pg_hba config file on test1.
[gs_dropnode]Start of set pg_hba config file on test2.
[gs_dropnode]End of set pg_hba config file on test2.
[gs_dropnode]Start to set repl slot on test1.
[gs_dropnode]Start to get repl slot on test1.
[gs_dropnode]End of set repl slot on test1.
[gs_dropnode]Start to modify the cluster static conf.
[gs_dropnode]End of modify the cluster static conf.
[gs_dropnode]Success to drop the target nodes.
[omm@test1 ~]$ gs_om -t status --detail
[ Cluster State ]

cluster_state : Normal
redistributing : No
current_az : AZ_ALL

[ Datanode State ]

node          node_ip         port      instance             state

1 test1 xx.xxx.xx.xx 26000 6001 /dbdata/data P Primary Normal
2 test2 xx.xxx.xx.xx 26000 6002 /dbdata/data S Standby Normal

标签:缩容,gs,MogDB,备机,dropnode,Start,xx,file,openGauss
From: https://www.cnblogs.com/helloopenGauss/p/18093961

相关文章

  • MogDB/openGauss访问控制简介
    MogDB/openGauss访问控制简介SQL可以针对不同的数据库对象赋予不同的权限,这样就可以限制用户对数据的不必要访问,提高数据访问的安全性。常见的SQL权限如下:SELECT/UPDATE/DELETE/INSERT:访问、修改基本表或视图的权限REFERENCES:在基本表上创建外键约束的权限TRIGGER:在基本表......
  • openGauss/MogDB 学习笔记之 -- PITR恢复
    openGauss/MogDB学习笔记之--PITR恢复概念描述背景信息当数据库崩溃或希望回退到数据库之前的某一状态时,MogDB的即时恢复功能(Point-In-TimeRecovery,简称PITR)可以支持恢复到备份归档数据之后的任意时间点。说明PITR仅支持恢复到物理备份数据之后的某一时间点。仅主节......
  • openGauss Cluster Manager RTO Test
    一、环境介绍软件环境类别 版本 下载链接 备注OS openEuler20.03(LTS) https://repo.openeuler.org/openEuler-20.03-LTS/ISO/aarch64/openEuler-20.03-LTS-aarch64-dvd.iso 操作系统BenchmarkSQL 5.0 https://sourceforge.net/projects/benchmarksql/files/latest/downloa......
  • opengauss-jdbc问题整理
    opengauss-jdbc问题整理(更新中)问题1jdbc批量执行insert语句时返回结果不符合Springjpa预期问题描述:jdbc执行查询时,可以使用preparestatment.executeBatch()方法批量执行一组sql语句,该方法返回为int[]int型数组变量,含义是批量执行的每个sql语句更新的数据行数。......
  • 使用Python-psycopg访问postgres、openGauss、MogDB
    摘要Psycopg是一种用于执行SQL语句的PythonAPI,可以为PostgreSQL、GaussDB数据库提供统一访问接口,应用程序可基于它进行数据操作。Psycopg2是对libpq的封装,主要使用C语言实现,既高效又安全。它具有客户端游标和服务器端游标、异步通信和通知、支持“COPYTO/COPYFROM”......
  • openGauss资源池化开发者入门指南(二)
    openGauss资源池化开发者入门指南(二)一、内容简介openGauss资源池化是openGauss推出的一种新型的集群架构.通过DMS和DSS组件,实现集群中多个节点的底层存储数据共享和节点间的内存实时共享达到节省底层存储资源以及集群内部支持一写多读且可以实时一致性读的目的.本......
  • openGauss资源池化开发者入门指南(一)
    openGauss资源池化开发者入门指南(一)一、内容简介openGauss资源池化是openGauss推出的一种新型的集群架构.通过DMS和DSS组件,实现集群中多个节点的底层存储数据共享和节点间的内存实时共享达到节省底层存储资源以及集群内部支持一写多读且可以实时一致性读的目的.本系......
  • openGauss Copy接口支持容错机制
    Copy接口支持容错机制可获得性本特性自openGauss1.0.0版本开始引入。特性简介支持将Copy过程中的部分错误导入到指定的错误表中,并且保持Copy过程不被中断。客户价值提升Copy功能的可用性和易用性,提升对于源数据格式异常等常见错误的容忍性和鲁棒性。特性描述openGauss提......
  • openGauss DCF
    DCF可获得性本特性自openGauss2.0.0版本开始引入。特性简介DCF(DistributedConsensusFramework,分布式共识框架)基于Paxos算法实现数据同步强一致。DCF模式开关开启后,DN可以支持基于Paxos协议的复制与仲裁能力。客户价值DN基于Paxos的自选主及日志复制,复制过程中支持压缩及......
  • openGauss Anomaly_detection_数据库指标采集_预测与异常监控
    Anomaly-detection:数据库指标采集、预测与异常监控可获得性本特性自openGauss1.1.0版本开始引入。特性简介anomaly_detection是openGauss集成的、可以用于数据库指标采集、预测以及异常监控与诊断的AI工具,是dbmind套间中的一个组件。支持采集的信息包括IO_Read、IO_Write、CPU......