pg_controldata
是一个 服务器实用程序,它显示存储在 global/pg_control
文件中的 数据库集群
的全局状态信息。这些信息包括在 initdb
过程中固定的集群特性(例如块大小),以及 WAL
/ 检查点
相关数据和 数据页校验和
。
pg_controldata
包含在 PostgreSQL 核心发行版中;在 PostgreSQL 7.3 之前,它是一个 contrib 模块。
SQL 替代方案
从 PostgreSQL 9.6 开始,可以使用以下函数直接查询 pg_control
的内容
pg_control_checkpoint()
(当前检查点状态信息)pg_control_system()
(当前控制文件状态信息)pg_control_init()
(集群初始化状态信息)pg_control_recovery()
(恢复状态信息)
更改历史记录
- PostgreSQL 11
- 添加了长选项 (提交 e22b27f0)
- PostgreSQL 9.5
- 添加了
-D
选项,以与其他实用程序在指定数据目录时保持一致 (提交 b0d81ade)
- 添加了
- PostgreSQL 7.3
- 更改为核心实用程序 (提交 6945ea34)
- PostgreSQL 7.2
- 添加为 contrib 模块 (提交 b25e60d8)
示例
示例输出
$ pg_controldata -D /path/to/pgdata pg_control version number: 1201 Catalog version number: 201909212 Database system identifier: 6872135480623396628 Database cluster state: in archive recovery pg_control last modified: Mon 14 Sep 2020 09:35:29 AM UTC Latest checkpoint location: 0/2000060 Latest checkpoint's REDO location: 0/2000028 Latest checkpoint's REDO WAL file: 000000010000000000000002 Latest checkpoint's TimeLineID: 1 Latest checkpoint's PrevTimeLineID: 1 Latest checkpoint's full_page_writes: on Latest checkpoint's NextXID: 0:495 Latest checkpoint's NextOID: 24576 Latest checkpoint's NextMultiXactId: 1 Latest checkpoint's NextMultiOffset: 0 Latest checkpoint's oldestXID: 479 Latest checkpoint's oldestXID's DB: 1 Latest checkpoint's oldestActiveXID: 495 Latest checkpoint's oldestMultiXid: 1 Latest checkpoint's oldestMulti's DB: 1 Latest checkpoint's oldestCommitTsXid:0 Latest checkpoint's newestCommitTsXid:0 Time of latest checkpoint: Mon 14 Sep 2020 09:35:28 AM UTC Fake LSN counter for unlogged rels: 0/3E8 Minimum recovery ending location: 0/2000100 Min recovery ending loc's timeline: 1 Backup start location: 0/0 Backup end location: 0/0 End-of-backup record required: no wal_level setting: replica wal_log_hints setting: on max_connections setting: 20 max_worker_processes setting: 8 max_wal_senders setting: 10 max_prepared_xacts setting: 10 max_locks_per_xact setting: 64 track_commit_timestamp setting: off Maximum data alignment: 8 Database block size: 8192 Blocks per segment of large relation: 131072 WAL block size: 8192 Bytes per WAL segment: 16777216 Maximum length of identifiers: 64 Maximum columns in an index: 32 Maximum size of a TOAST chunk: 1996 Size of a large-object chunk: 2048 Date/time type storage: 64-bit integers Float4 argument passing: by value Float8 argument passing: by value Data page checksum version: 1 Mock authentication nonce: f5f96b5d2aee1c18e95333fb089ac55415aa1aef63158456fdcd09044f00bb32
参考文献
- PostgreSQL 文档: pg_controldata
- PostgreSQL 文档: 控制数据函数