postgresql 如何检查热备是否提供只读查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28634971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:47:57  来源:igfitidea点击:

How to check if hot standby serves read-only queries

postgresqldatabase-replication

提问by Alexander

I have setup replication: master - slave. Slave server works as hot-standby, which means we can run read-only sql queries. How actually can I see that slave server is serving read-only queries?

我已经设置复制:主 - 从。从服务器作为热备工作,这意味着我们可以运行只读 sql 查询。我如何才能看到从服务器正在提供只读查询?

回答by yoloseem

You can use pg_is_in_recovery()which returns Trueif recovery is still in progress(so the server is running in standby mode). Check the System Administration Functionsfor further informations.

如果恢复仍在进行中pg_is_in_recovery(),您可以使用which 返回True(因此服务器在待机模式下运行)。检查系统管理功能以获取更多信息。

=# SELECT pg_is_in_recovery();
 pg_is_in_recovery
───────────────────
 f
(1 row)