我有需要监控的流式复制。所以 Zabbix 有一个特殊的用户。我不想使用 pg_mongz 并决定将我自己的查询设置为 pg_catalog 模式的 View pg_stat_replication 以获取复制状态。
当我使用查询时:
select *
from pg_stat_replication;
它返回管理员的复制状态记录。但是当我以监控用户身份登录时,它只返回:
pid, usesysid, usename, application_name
所以client_addr、client_hostname、client_port、backend_start、state、sent_location、write_location等参数为空。
首先,我向我的用户授予了架构和表的权限:
grant usage on schema pg_catalog to usrmonitor;
grant select on all tables in schema pg_catalog to usrmonitor;
但是没有用。当我查看 View 时,我发现查询使用函数并授权执行:
grant execute on function pg_stat_get_wal_senders() to usrmonitor;
grant execute on function pg_stat_get_activity(integer) to usrmonitor;
但是选择查询仍然返回空列。可能是什么问题?
最佳答案
从 PostgreSQL 10 开始,它就这么简单:
GRANT pg_monitor TO monitoring_user;
(来源:https://pganalyze.com/blog/whats-new-in-postgres-10-monitoring-improvements)
关于postgresql - 无法访问 PostgreSQL 中的流复制统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32735805/