postgresql之判断主备

本文介绍了多种判断PostgreSQL数据库为主库还是备库的方法:1) 查看pg_controldata的集群状态;2) 检视进程,wal sender标识为主,wal receiver为备;3) 使用pg_is_in_recovery函数;4) 利用pg_stat_replication表中的记录情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有几种方法:

1、通过pg_controldata输出,主库Database cluster state,为in production, 备库为in archive recovery。

主库:

#/u01/pgsql/bin/pg_controldata  -D/data
pg_control version number:            1100
Catalog version number:               201809051
Database system identifier:           6823651405425741880
Database cluster state:               in production
pg_control last modified:             Thu 07 May 2020 03:22:15 PM CST
Latest checkpoint location:           1/13001610
Latest checkpoint's REDO location:    1/130015D8
Latest checkpoint's REDO WAL file:    000000050000000100000013

备库:

#/u01/pgsql/bin/pg_controldata  -D/data
pg_control version number:            1100
Catalog version number:               201809051
Database system identifier:           6823651405425741880
Database cluster state:               in archive recovery
pg_control last modified: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值