当前位置: 首页 > news >正文

repmgr集群故障修复

文章目录

  • 环境
  • 症状
  • 问题原因
  • 解决方案

环境

系统平台:Linux x86-64 Red Hat Enterprise Linux 7
版本:5.6.5

症状

repmgr集群无法连接。

问题原因

数据库无法分配内存,出现宕机。

解决方案

1、查看集群状态,判断主备节点及节点运行情况

[root@slave ~]# repmgr cluster show ID | Name          | Role    | Status    | Upstream      | Location | Priority | Replication lag | Last replayed LSN----+---------------+---------+-----------+---------------+----------+----------+-----------------+-------------------1  | x.x.0.121 | primary | -failed |               | default  | 100      | n/a             | none             2  | x.x.0.122 | standby |   ?unreachable | x.x.0.121 | default  | 100      | 5232GB         | 0/0

通过查看集群状态发现主备节点皆出现问题。

[root@slave ~]# ps -ef | grep postroot      1091     1  0 Apr15 ?        00:00:00 /usr/libexec/postfix/master -wpostfix   1094  1091  0 Apr15 ?        00:00:00 qmgr -l -t unix -upostfix   4743  1091  0 08:37 ?        00:00:00 pickup -l -t unix -uroot      4953  4821  0 09:41 pts/0    00:00:00 grep --color=auto post

通过查看post进程发现主备节点皆无数据库进程,代表数据库节点皆出现宕机情况。

2、查看两节点数据库时间线

[root@slave ~]# pg_controldata |grep TimeLineID
Latest checkpoint's TimeLineID:       11Latest checkpoint's PrevTimeLineID:   11

两个数据库节点时间线皆为11,说明两个节点出现问题之前并未发生主备切换,我们以原主库为主库进行集群恢复,同时备节点做好数据备份。

3、查看数据库日志,判断节点出现问题原因。

find / -iname hgdb_log -printcat highgodb_11.log 

提示无法分配内存,free -h查看服务器内存使用情况,发现服务器内存共14gb,且内存使用量过高,查看数据库参数配置正常,shared_buffers=4GB;建议客户增加内存。

4、启动主节点,并注册为主库

pg_ctl startrepmgr  primary register -F 

5、查看主库是否出现vip

ip a

6、备份备节点,重做备节点,注册为备库

cd /highgomv data data_bak20240323pg_basebackup -h 主库ip  -U highgo -D /highgo/data -Fp -P -Xs -R -vpg_ctl startrepmgr  standby register -F 

7、检查集群状态

[root@slave ~]# repmgr cluster show ID | Name          | Role    | Status    | Upstream      | Location | Priority | Replication lag | Last replayed LSN----+---------------+---------+-----------+---------------+----------+----------+-----------------+-------------------1  | x.x.0.121 | primary | * running |               | default  | 100      | n/a             | none             2  | x.x.0.122 | standby |   running | x.x.0.121 | default  | 100      | 0 bytes         | 0/70007D0

主备节点集群状态都为running正常,且Replication lag为0 bytes

[root@hs02 ~]# ps -ef|grep postgroot      20568      1  0 17:37 ?        00:00:00 /highgo/database/4.5/bin/postgres -D /highgo/database/4.5/dataroot      20569  20568  0 17:37 ?        00:00:00 postgres: logger process   root      20570  20568  0 17:37 ?        00:00:00 postgres: startup process   recovering 000000010000000000000007root      20571  20568  0 17:37 ?        00:00:00 postgres: checkpointer process   root      20572  20568  0 17:37 ?        00:00:00 postgres: writer process   root      20573  20568  0 17:37 ?        00:00:00 postgres: stats collector process   root      20574  20568  0 17:37 ?        00:00:00 postgres: wal receiver process   streaming 0/70006F0root      20585  20568  0 17:37 ?        00:00:00 postgres: sysdba highgo x.x.0.122(13382) idle

查看流复制信息,主备节点皆出现数据库进程,且备节点有wal receiver进程,代表接收主节点的数据流。

8、查看守护进程

ps -ef | grep repmgrd

9、没有守护进程执行如下命令

repmgrd -d

10、程序检查日志表,数据正常。

http://www.xdnf.cn/news/463735.html

相关文章:

  • 基于DWT的音频水印算法
  • 2025长三角杯数学建模B题教学思路分析:空气源热泵供暖的温度预测
  • Java转Go日记(三十六):简单的分布式
  • 【PmHub后端篇】PmHub中Seata分布式事务保障任务审批状态一致性
  • 【油藏地球物理正演软件ColchisFM】基于数据驱动的油藏参数叠前地震反演研究进展
  • Scrapy框架下地图爬虫的进度监控与优化策略
  • 智能化招标采购新基建:基于DeepSeek大模型+RAG技术的智能知识服务中枢
  • MinerU安装(pdf转markdown、json)
  • uniapp在APP上如何使用websocket--详解
  • 每日算法刷题计划Day7 5.15:leetcode滑动窗口4道题,用时1h
  • 《数字藏品社交化破局:React Native与Flutter的创新实践指南》
  • 游戏引擎学习第283天:“让‘Standing-on’成为一个更严谨的概念
  • 进程替换讲解
  • uniapp微信小程序一键授权登录
  • 牛客网NC218480统计正负数个数
  • SiFli-SDK 编译
  • 【Ubuntu】安装BitComet种子下载器
  • 语音识别-3,添加ai问答
  • IT系统的基础设施:流量治理、服务治理、资源治理,还有数据治理。
  • 工作实战之关于数据库表的备份
  • 『已解决』Python virtualenv_ error_ unrecognized arguments_--wheel-bundle
  • 浏览器验证证书
  • 【AI News | 20250515】每日AI进展
  • 蓝牙BLE协议之——LL层
  • 【LeetCode 热题 100】56. 合并区间 —— 一文弄懂排序+遍历经典解法(附Python代码)
  • 使用Mathematica绘制Clifford奇异吸引子
  • 香港科技大学广州|智能制造学域硕博招生宣讲会-西北工业大学
  • Windows AD 域客户端电脑时间不准解决方案
  • 解决xxx.jar中没有主清单属性的问题
  • Linux文件操作系统接口介绍,以及文件描述符的本质