pg_roast

覆盖模式设计、安全配置、运行健康与查询行为的数据库审计器

概览

扩展包名版本分类许可证语言
pg_roast1.0SECPostgreSQLC
ID扩展名BinLibLoadCreateTrustReloc模式
7120pg_roastroast
相关扩展pglinter pg_profile pg_stat_statements

Upstream has no release tag; package pins main commit ccbf012. Manual audits work normally; the periodic background worker requires shared_preload_libraries=pg_roast.

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY1.01817161514pg_roast-
RPMPIGSTY1.01817161514pg_roast_$v-
DEBPIGSTY1.01817161514postgresql-$v-pg-roast-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u26.x86_64
u26.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0

构建

您可以使用 pig build 命令构建 pg_roast 扩展的 RPM / DEB 包:

pig build pkg pg_roast         # 构建 RPM / DEB 包

安装

您可以直接安装 pg_roast 扩展包的预置二进制包,首先确保 PGDGPIGSTY 仓库已经添加并启用:

pig repo add pgsql -u          # 添加仓库并更新缓存

使用 pig 或者是 apt/yum/dnf 安装扩展:

pig install pg_roast;          # 当前活跃 PG 版本安装
pig ext install -y pg_roast -v 18  # PG 18
pig ext install -y pg_roast -v 17  # PG 17
pig ext install -y pg_roast -v 16  # PG 16
pig ext install -y pg_roast -v 15  # PG 15
pig ext install -y pg_roast -v 14  # PG 14
dnf install -y pg_roast_18       # PG 18
dnf install -y pg_roast_17       # PG 17
dnf install -y pg_roast_16       # PG 16
dnf install -y pg_roast_15       # PG 15
dnf install -y pg_roast_14       # PG 14
apt install -y postgresql-18-pg-roast   # PG 18
apt install -y postgresql-17-pg-roast   # PG 17
apt install -y postgresql-16-pg-roast   # PG 16
apt install -y postgresql-15-pg-roast   # PG 15
apt install -y postgresql-14-pg-roast   # PG 14

预加载配置

shared_preload_libraries = 'pg_roast';

创建扩展

CREATE EXTENSION pg_roast;

用法

来源:

pg_roast 运行一组带有明确观点的 PostgreSQL 健康检查,并将发现存入其固定的 roast 模式。它检查配置、模式设计、索引、清理与膨胀指标、安全状态、复制、连接和负载信号。1.0 版面向 PostgreSQL 14 及更高版本。

手动审计

手动模式不需要预加载:

CREATE EXTENSION pg_roast;

SELECT * FROM roast.run();
SELECT severity, check_name, object_name, roast
FROM roast.latest
ORDER BY severity, check_name;

SELECT * FROM roast.summary;

每次运行都会持久化审计历史与发现。使用 latest 视图查看最新一次运行,使用 summary 视图查看分组结果。

定时审计

可选的后台工作进程需要预加载配置与重启:

shared_preload_libraries = 'pg_roast'
pg_roast.database = 'mydb'
pg_roast.interval = 3600

数据库设置在服务器启动时固定。在生产负载上启用自动审计前,应审查上游设置。

注意事项

  • 发现是启发式建议,并不自动证明存在缺陷。应在应用任何建议前,审查工作负载背景、维护窗口和 PostgreSQL 文档。
  • 审计会执行系统目录与统计查询,并写入历史表。应在大型系统目录上测量开销,并防止不可信用户访问 roast 模式。
  • 结果可能暴露对象名、配置、安全发现和查询相关运维细节。应实施最小权限与明确的保留策略。
  • 手动运行无需预加载,但后台工作进程必须预加载;修改仅启动时设置需要重启。