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

HGDB集群(安全版)repmgr手动切换主备库

文章目录

  • 文档用途
  • 详细信息

文档用途

介绍HGDB集群(安全版)repmgr手动主备切换的方法,以及使用过程中的注意事项。

详细信息

repmgr集群主备切换使用的是repmgr standby switchover工具,它的作用是将备库提升为主库,所以该命令只能在备库上执行。
操作步骤;
①检查集群状态

 ID | Name          | Role    | Status    | Upstream      | Location | Priority | Replication lag | Last replayed LSN
----+---------------+---------+-----------+---------------+----------+----------+-----------------+-------------------1  | x.x.197.7 | standby |   running | x.x.197.8 | default  | 100      | 0 bytes         | 0/5007BD82  | x.x.197.8 | primary | * running |               | default  | 100      | n/a             | none

②在备库上执行repmgr standby switchover

[root@ha1 .ssh]# repmgr standby  switchover

注意:

-------------------------------------------
Login User: sysdba
Login time: 2020-08-18 17:01:08.779533+08
Login Address: ha1
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------
NOTICE: executing switchover on node "x.x.197.7" (ID: 1)

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:08.768112+08
Login Address: ha1
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:09.329686+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:09.36233+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:09.379521+08
Login Address: ha1
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:09.367691+08
Login Address: ha1
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08-------------------------------------------NOTICE: local node "x.x.197.7" (ID: 1) will be promoted to primary; current primary "x.x.197.8" (ID: 2) will be demoted to standby
NOTICE: stopping current primary node "x.x.197.8" (ID: 2)

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:09.525191+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08-------------------------------------------NOTICE: issuing CHECKPOINT
DETAIL: executing server command "/opt/HighGo4.3.4.9-see/bin/pg_ctl  -D '/opt/HighGo4.3.4.9-see/data' -W -m fast stop"
INFO: checking for primary shutdown; 1 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 2 of 60 attempts ("shutdown_check_timeout")
NOTICE: current primary has been cleanly shut down at location 0/5007D60
Warning: Executing wildcard deletion to stay compatible with old scripts.Explicitly specify the prefix length (x.x.197.110/32) to avoid this warning.This special behaviour is likely to disappear in further releases,fix your scripts!
NOTICE: promoting standby to primary
DETAIL: promoting server "x.x.197.7" (ID: 1) using "/opt/HighGo4.3.4.9-see/bin/pg_ctl  -w -D '/opt/HighGo4.3.4.9-see/data' promote"
waiting for server to promote.... 完成
server promoted
NOTICE: waiting up to 60 seconds (parameter "promote_check_timeout") for promotion to complete
NOTICE: STANDBY PROMOTE successful
DETAIL: server "x.x.197.7" (ID: 1) was successfully promoted to primary

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:11.342397+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08-------------------------------------------

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:11.369129+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08-------------------------------------------

注意:

-------------------------------------------
Login User: sysdba
Login time: 2020-08-18 17:01:11.383934+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------
INFO: local node 2 can attach to rejoin target node 1
DETAIL: local node's recovery point: 0/5007D60; rejoin target node's fork point: 0/5007DD0
NOTICE: setting node 2's upstream to node 1
WARNING: unable to ping "host=x.x.197.8 user=sysdba dbname=highgo password=4t65da7s port=5866 connect_timeout=2"
DETAIL: PQping() returned "PQPING_NO_RESPONSE"
NOTICE: starting server using "/opt/HighGo4.3.4.9-see/bin/pg_ctl  -w -D '/opt/HighGo4.3.4.9-see/data' start"

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:11.662335+08
Login Address: ha2
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------
NOTICE: NODE REJOIN successful
DETAIL: node 2 is now attached to node 1

注意:

-------------------------------------------Login User: sysdba
Login time: 2020-08-18 17:01:11.691733+08
Login Address: ha1
Last Login Status: SUCCESS
Login Failures: 0
Valied Until: 2020-08-25 14:03:03+08
-------------------------------------------
NOTICE: switchover was successful
DETAIL: node "x.x.197.7" is now primary and node "x.x.197.8" is attached as standby
NOTICE: STANDBY SWITCHOVER has completed successfully

③检查集群状态

 ID | Name          | Role    | Status    | Upstream      | Location | Priority | Replication lag | Last replayed LSN
----+---------------+---------+-----------+---------------+----------+----------+-----------------+-------------------1  | x.x.197.7 | primary | * running |               | default  | 100      | n/a             | none2  | x.x.197.8 | standby |   running | x.x.197.7 | default  | 100      | 0 bytes         | 0/5009640

可以发现数据库的主备已经切换完毕。

注意事项:
1.实现主备切换需要进行互信操作,不然会报错。

WARNING: unable to connect to remote host “x.x.197.8” via SSH
ERROR: unable to connect via SSH to host “x.x.197.8”, user “”
2.在切换时 repmgrd 不应该在 repmgr.conf中启用 failover=automatic或启动repmgrd,否则repmgrd守护进程可能尝试并自行提升备用数据库。

3.数据库的环境变量应该设置在.bashrc中否则会报错找不到repmgr。

ERROR: unable to execute “repmgr” on “x.x.197.8”
HINT: check “pg_bindir” is set to the correct path in “repmgr.conf”; current value: “/opt/HighGo4.3.4.9-see/bin”
4.建议在切换之前加上–dry-run,可以测试是否切换成功而不进行切换,测试成功后再进行正式切换。

http://www.dtcms.com/a/464815.html

相关文章:

  • 三维GIS数据转换指南:SHAPE文件到3DTiles的高效实现方案
  • K8S(三)—— 基于kubeadm 1.20版本部署Kubernetes集群与Harbor私有仓库实战
  • 宁波外贸网站制作公司手机网站建设哪家公司好
  • 【C语言实战(8)】C语言循环结构(do-while):解锁编程新境界
  • 面向Qt/C++开发工程师的Ai提示词(附Trae示例)
  • sqlite 使用: 01-源码编译与使用
  • Django视图进阶:快捷函数、装饰器与请求响应
  • 企业营销网站的建设网站开发响应式
  • 掌握DMA基于GD32F407VE的天空星的配置
  • 基于腾讯云的物联网导盲助手设计与实现(论文+源码)
  • Vue3打造高效前端埋点系统
  • 框架--Maven
  • 【Java集合】
  • 停止Conda开机自动运行方法
  • 湘潭市高新建设局施工报建网站wordpress 宕机
  • 复杂结构数据挖掘(二)关联规则挖掘 Association rule mining
  • Windows 上安装 PostgreSQL
  • 基于JETSON/x86+FPGA+AI的5G远程驾驶座舱时延验证方案
  • 支持向量机(SVM)完全解读
  • 单片机学习日记
  • 重庆网站制作多少钱app设计开发哪家好
  • AI大模型学习(17)python-flask AI大模型和图片处理工具的从一张图到多平台适配的简单方法
  • 如何通过 7 种解决方案将文件从PC无线传输到Android
  • Word 为每一页设置不同页边距(VBA 宏)
  • wordpiece、unigram、sentencepiece基本原理
  • css word-spacing属性
  • 使用 python-docx 库操作 word 文档(2):在word文档中插入各种内容
  • 中企动力销售工作内容白城网站seo
  • 从0死磕全栈之Next.js 企业级 `next.config.js` 配置详解:打造高性能、安全、可维护的中大型项目
  • 在JavaScript中,const和var的区别