首页 > 其他分享 >openGauss的扩容缩容和问题处理

openGauss的扩容缩容和问题处理

时间:2024-03-18 16:15:45浏览次数:14  
标签:缩容 扩容 gs kvm node dropnode nodes openGauss 节点

openGauss 的扩容缩容和问题处理

openGauss 提供了优秀的集群管理工具 gs_om,集群管理信息写在二进制文件中,从而牺牲了增加节点和摘除节点的便利性(相对 PG 而言)。好在 openGauss-1.1.0 提供了节点扩容和缩容的工具,gs_dropnode 和 gs_expansion。

生产主库服务器出现硬件故障,无法启动,所以需要摘除故障老主节点和新增一台备机,以恢复集群架构。

集群状态:主库无法访问,gs_om 显示主库 unknow,备机显示连接中。

操作:先将主节点切换至同步备机,使集群恢复正常。

在需要切换为新主库的节点执行命令:

gs_ctl failover -D /home/omm/dn1/

其中:/home/omm/dn1/为新主库的数据目录。

切换完成之后查看数据库状态是否正常。

gs_om -t status --detail

后续处理:

执行以下下命令清除坏死节点,避免对依赖 gs_om 的工具产生影响。

gs_dropnode -U omm -G dbgrp -h ***.***.***.***

说明:

  • -U 指定集群的安装的用户
  • -G 指定集群的安装用户的用户组
  • -h 需要摘除的节点的 IP

摘除节点过程中产生的问题处理:目前社区官方 1.1.0 版本中的 gs_dropnode 执行时需要 gs_om 在每台机器上查询状态,服务器无法连接时会等待机器响应,导致超时,造成摘除节点卡死现象。与开发者沟通后,开发者会缩短等待无响应机器的时间为 10s,超时后不再等待坏死节点响应,直接更新正常节点的集群管理信息存储文件。需要在 gitee 里下载新的 gs_dropnode 脚本替换原脚本再执行。

新版本链接地址:https://gitee.com/struggle_hw/openGauss-OM/blob/c0212048050453c57955b342dada5b6de6803622/script/gs_dropnode

gs_dropnode -U omm -G dbgrp -h ***.***.***.***

如下图所示,摘除节点日志如下,成功。

[omm@kvm-yl1 ~]$ gs_dropnode -U omm -G dbgrp -h ***.***.***.***
The target node to be dropped is (['kvm-yl2'])
Do you want to continue to drop the target node (yes/no)? yes
The cluster will have only one standalone node left after the operation!
Do you want to continue to drop the target node (yes/no)? yes
[gs_dropnode]Start to drop nodes of the cluster.
[gs_dropnode]Start to stop the target node kvm-yl2.
[gs_dropnode]End of stop the target node kvm-yl2.
[gs_dropnode]Start to backup parameter config file on kvm-yl1.
[gs_dropnode]End to backup parameter config file on kvm-yl1.
[gs_dropnode]The backup file of kvm-yl1 is /tmp/gs_dropnode_backup20210223085218/parameter_kvm-yl1.tar
[gs_dropnode]Start to parse parameter config file on kvm-yl1.
[gs_dropnode]End to parse parameter config file on kvm-yl1.
[gs_dropnode]Start to parse backup parameter config file on kvm-yl1.
[gs_dropnode]End to parse backup parameter config file kvm-yl1.
[gs_dropnode]Start to set postgresql config file on kvm-yl1.
[gs_dropnode]End of set postgresql config file on kvm-yl1.
[gs_dropnode]Start to get repl slot on primary node.
[gs_dropnode]Start to set repl slot on primary node.
[gs_dropnode]End of set repl slot on primary node.
[gs_dropnode]Start of set pg_hba config file on kvm-yl1.
[gs_dropnode]End of set pg_hba config file on kvm-yl1.
[gs_dropnode]Start to modify the cluster static conf.
[gs_dropnode]End of modify the cluster static conf.
[gs_dropnode]Remove the dynamic conf.
Only one primary node is left.It is recommended to restart the node.
Do you want to restart the primary node now (yes/no)? yes
[gs_dropnode]Start to stop the target node kvm-yl1.
[gs_dropnode]End of stop the target node kvm-yl1.
[gs_dropnode]Start to start the target node.
[gs_dropnode]End of start the target node.
[gs_dropnode]Success to drop the target nodes.

tips:节点摘除之后,为了保证数据安全,被摘除节点的数据不会被清理,如果确定不需要,可以手动清理节点,执行清理本地数据命令并清理环境变量。

gs_uninstall --delete-data -L

扩容一台机器,以便于恢复集群原有架构。

  1. 新节点创建 omm 用户和用户组 dbgrp。
  2. 检查新节点环境变量,清理和 openGauss 相关的环境变量配置。主要检查/etc/profile 和/home/omm/.bashrc 两个文件。如果清理不干净,会导致扩容不成功。或者提示待扩容备机节点已经安装。
  3. 创建互信,包括 root 和 omm 用户,这里使用 opengauss 提供的工具创建互信。
  4. 如果是同一台机器恢复后再加入集群,需要清理 root 用户和 omm 用户的~/.ssh/know_host 和~/.ssh/authorized_keys 里的相关信息,都则创建互信会失败。
  5. 分别在 root 用户和 omm 用户下执行,各节点密码需要一致,后期可以再修改。
  6. 全新的机器需要安装 python3。
gs_sshexkey -f /home/omm/hostfile

执行结果提示如下代表成功

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.

hostfile 如下:

集群内所有的 ip,每个 ip 一行:

cat hostfile
***.***.***.***
***.***.***.******.***.***.***```

创建新的 xml 文件,将老节点剔除,新节点加入。

./gs_expansion -U omm -G dbgrp -h ... -X ./clusterconfig.xml


扩容日志如下,代表扩容成功。

Start to preinstall database on the new standby nodes.
Successfully preinstall database on the new standby nodes.
Start to install database on the new standby nodes.
installing database on node ...:
Please enter the password of user [omm] on node [...]:
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 /data/opengauss/app/share/sslcert/om
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..
Successfully install database on node ['...']
Database on standby nodes installed finished. Start to establish the primary-standby relationship.
Success to expansion standby nodes.


问题处理:扩容后,gs_om 显示新备机状态异常的情况,可能有以下几种情况:

1.  集群数据目录比较大,导致扩容脚本超时后,备机执行 build 还未执行完毕,需要等待备机执行完。
2.  扩容过程中,主库配置文件更新失败,需要检查 postgresql.conf 文件的 replconninfo 和 hba 的集群内状态是否正常。

标签:缩容,扩容,gs,kvm,node,dropnode,nodes,openGauss,节点
From: https://www.cnblogs.com/renxyz/p/18080632

相关文章

  • openGauss数据库之Python驱动快速入门
    OpenGauss数据库之Python驱动openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核源自PostgreSQL,深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。可是目前针对于OpenGauss数据库的Python应用程序的开发少......
  • Step-by-Step之-openGauss1-0-1单机安装指南v1-2
    StepbyStep之:openGauss1.0.1单机安装指南v1.2在CentOS7.6上安装openGauss单机版配置操作系统满足安装要求硬件环境:虚拟机的内存8GB,4核心CPU,900G磁盘(非必须)软件环境:CentOS7.6关闭防火墙#停止firewallsystemctlstopfirewalld.service#禁止firewall开机启......
  • openGauss的索引组织表
    openGauss的索引组织表概述今天有位小伙伴问我,Oracle数据库可以通过索引组织表(IOT)将数据按照主键排序存储,有序的数据存储可以有效提高数据库缓冲区的命中率,减少SQL查询的IO消耗,提升查询效率。而openGauss的建表语句中并没有看到索引组织表的相关语法。openGauss目前......
  • step-by-step系列之-openGauss1-0-1-Docker版本单机安装指南
    stepbystep系列之:openGauss1.0.1Docker版本单机安装指南1.软硬件环境硬件环境:项目最低配置推荐配置测试配置硬盘用于安装openGauss的硬盘需最少满足如下要求:至少1GB用于安装openGauss的应用程序包。每个主机需大约300MB用于元数据存储。预留70%以上的磁盘剩......
  • step-by-step之-install-docker版本opengauss1-0-1主备机群
    stepbystep之:installdocker版本opengauss1.0.1主备机群实验环境说明:OS:2颗8核心8GB内存。1.流程:先安装docker软件,下载Docker镜像,在创建启动主备容器数据库,进入数据库,进行主备切换试验。2.安装docker软件[root@node1~]#yum-yinstalldocker#检查docke......
  • openGauss增量备份恢复
    openGauss增量备份恢复openGauss数据库自2020年6月30日发布以来,很多小伙伴都提到“openGauss数据库是否有增量备份工具?“这么一个问题。在openGauss1.0.0版本的时候,关于这个问题的回答往往是:“Sorry…”,openGauss数据库可以使用gs_basebackup工具对数据库进行物......
  • openGauss的WDR报告详细解读
    openGauss的WDR报告详细解读openGauss数据库自2020年6月30日开源至今已有10个月了,在这短短的10个月内,openGauss社区用户下载量已达13W+、issue合并2000+、发行商业版本6个。仅3月份就有11家企业完成CLA签署,包括虚谷伟业、云和恩墨、优炫软件、海量数据......
  • openGauss数据动态脱敏
    openGauss数据动态脱敏常见脱敏路线结果集解析:不改写发给数据库的语句,需要提前获悉数据表结构,待数据库返回结果后再根据表结构判断集合内哪些数据需要脱敏,并逐条改写结果数据。语句改写:将包含敏感字段查询的语句改写,对于查询中涉及的敏感字段(表列)通过外层嵌套函数的方式改写......
  • 浅聊openGauss体系架构
    浅聊openGauss体系架构2020年7月openGauss刚刚开源,我便开始对openGauss数据库的学习。根据以往学习数据库的经验,最先想了解的是openGauss数据库的架构,希望对即将使用的数据库各个模块有所了解。但鉴于时间有限,仅有的资料图是源码doc目录内的“openGauss逻辑结构图......
  • 浅聊openGauss逻辑架构
    浅聊openGauss逻辑架构概述openGauss数据库是一款由华为主导、各个生态合作伙伴共同建设的开源关系型数据库管理系统,开源发行协议遵从木兰宽松许可证v2。openGauss数据库源于PostgreSQL-XC项目,内核源于Postgres9.2.4,总代码量约120W行,其中内核代码约95W行。华为结......