pg12新特性-新增 pg_promote() 函数用于激活备库

瀚高数据库
目录
文档用途
详细信息
相关文档
文档用途
pg12新特性,新增 pg_promote() 函数用于激活备库

详细信息

  1. 官方文档说明
[官方文档](https://www.postgresql.org/docs/12/release-12.html)

Add function pg_promote() to promote standbys to primaries (Laurenz Albe, Michaël Paquier)
Previously, this operation was only possible by using pg_ctl or creating a trigger file.
  1. 函数说明
pg_promote(wait boolean DEFAULT true, wait_seconds integer DEFAULT 60)

Description

Promotes a physical standby server. With wait set to true (the default), the function waits until promotion is completed or wait_seconds seconds have passed, and returns true if promotion is successful and false otherwise. If wait is set to false, the function returns true immediately after sending SIGUSR1 to the postmaster to trigger the promotion. This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.

wait这只为true表示是否等待备库的 promotion 完成或者 wait_seconds 秒之后返回成功,默认值为 true。wait_seconds默认 60s。只有超级用户才有执行 pg_promote() 函数的权限,也可以单独将此函数的执行权限赋给其它用户。

  1. 示例

现在,备库promote可以使用以下两种方式

$ pg_ctl promote

or

postgres=# SELECT pg_promote(true,60);
 pg_promote
------------
 t

可在操作系统层或数据库层执行操作

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值