↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 命令行工具 / 服务端程序

pg_waldump

pg_waldump — 以人类可读形式显示 PostgreSQL 数据库集簇的预写式日志

当前查看 PostgreSQL 18.6。

说明

pg_waldump — 以人类可读形式显示 PostgreSQL 数据库集簇的预写式日志

手册中的可执行程序
pg_waldump
程序版本
18.6
参考清单
服务端程序
选项定义组
18

用法

pg_waldump [ option ...] [ startseg [ endseg ]]

手册中的选项

选项与参数说明
-b --bkp-details输出有关备份块的详细信息。
-B block --block= block只显示修改给定块的记录。还必须通过 --relation 或 -R 指定关系。
-e end --end= end在指定的 WAL 位置停止读取,而不是一直读取到日志流末尾。
-f --follow在到达有效 WAL 的末尾后,继续每秒轮询一次,等待新的 WAL 出现。
-F fork --fork= fork只显示修改给定分支中块的记录。有效值包括:主分支为 main ,空闲空间映射为 fsm ,可见性映射为 vm ,初始化分支为 init 。
-n limit --limit= limit显示指定数量的记录,然后停止。
-p path --path= path指定搜索 WAL 段文件的目录,或含有存放这些文件的 pg_wal 子目录的目录。默认搜索当前目录、当前目录的 pg_wal 子目录,以及 PGDATA 的 pg_wal 子目录。
-q --quiet除错误外不打印任何输出。如果只想知道一段 WAL 记录能否被成功解析,而不关心记录内容,则此选项会很有用。
-r rmgr --rmgr= rmgr仅显示由指定资源管理器生成的记录。可以多次指定该选项以选择多个资源管理器。如果名称指定为 list ,则会打印有效资源管理器名称列表并退出。
-R tblspc / db / rel --relation= tblspc / db / rel仅显示修改给定关系中块的记录。关系以表空间 OID、数据库 OID 和 relfilenode 的形式指定,中间用斜杠分隔,例如 1234/12345/12345 。这与程序输出中关系所使用的格式相同。
-s start --start= start从指定的 WAL 位置开始读取。默认会从找到的最早文件中的第一条有效 WAL 记录开始读取。
-t timeline --timeline= timeline读取 WAL 记录所使用的时间线。如果指定了 startseg,默认使用其中的值;否则默认为 1。此值可以用十进制或十六进制表示,例如 17 或 0x11。
-V --version打印 pg_waldump 的版本并退出。
-w --fullpage仅显示包含整页镜像的记录。
-x xid --xid= xid仅显示标记有给定事务 ID 的记录。
-z --stats[=record]显示摘要统计信息(记录和整页镜像的数量及大小),而不是显示单条记录。还可以选择按记录类型而不是按资源管理器生成统计信息。
--save-fullpage= save_path将 WAL 记录中找到的整页镜像保存到 save_path 目录。保存的镜像会遵循与所显示记录相同的过滤和限制条件。
-? --help显示 pg_waldump 命令行参数的帮助信息,并退出。

环境变量

变量含义
PGDATA数据目录;另请参阅 -p 选项。
PG_COLOR指定诊断消息是否使用颜色。可选值为 always 、 auto 和 never 。

手册定义

pg_waldump

pg_waldump — 以人类可读形式显示PostgreSQL数据库集簇的预写式日志

大纲

pg_waldump [option...] [startseg [endseg]]

说明

pg_waldump显示预写式日志(WAL),主要用于调试或教学。

该工具只能由安装服务器的用户运行,因为它要求对数据目录具有只读访问权限。

选项

以下命令行选项控制输出的位置和格式:

startseg

从指定的 WAL 段文件开始读取。这会隐式决定搜索文件时所使用的路径以及要使用的时间线。

endseg

读取完指定的 WAL 段文件后停止。

-b
--bkp-details

输出有关备份块的详细信息。

-B block
--block=block

只显示修改给定块的记录。还必须通过--relation或-R 指定关系。

-e end
--end=end

在指定的 WAL 位置停止读取,而不是一直读取到日志流末尾。

-f
--follow

在到达有效 WAL 的末尾后,继续每秒轮询一次,等待新的 WAL 出现。

-F fork
--fork=fork

只显示修改给定分支中块的记录。有效值包括:主分支为main,空闲空间映射为fsm,可见性映射为vm,初始化分支为init。

-n limit
--limit=limit

显示指定数量的记录,然后停止。

-p path
--path=path

指定搜索 WAL 段文件的目录,或含有存放这些文件的 pg_wal 子目录的目录。默认搜索当前目录、当前目录的 pg_wal 子目录,以及 PGDATA 的 pg_wal 子目录。

-q
--quiet

除错误外不打印任何输出。如果只想知道一段 WAL 记录能否被成功解析,而不关心记录内容,则此选项会很有用。

-r rmgr
--rmgr=rmgr

仅显示由指定资源管理器生成的记录。可以多次指定该选项以选择多个资源管理器。如果名称指定为list,则会打印有效资源管理器名称列表并退出。

扩展可以定义自定义资源管理器,但pg_waldump不会加载扩展模块,因此无法按名称识别自定义资源管理器。作为替代,可以将自定义资源管理器指定为 custom###,其中###是三位数的资源管理器 ID。这种形式的名称始终会被视为有效。

-R tblspc/db/rel
--relation=tblspc/db/rel

仅显示修改给定关系中块的记录。关系以表空间 OID、数据库 OID 和 relfilenode 的形式指定,中间用斜杠分隔,例如1234/12345/12345。这与程序输出中关系所使用的格式相同。

-s start
--start=start

从指定的 WAL 位置开始读取。默认会从找到的最早文件中的第一条有效 WAL 记录开始读取。

-t timeline
--timeline=timeline

读取 WAL 记录所使用的时间线。如果指定了 startseg,默认使用其中的值;否则默认为 1。此值可以用十进制或十六进制表示,例如 17 或 0x11。

-V
--version

打印pg_waldump的版本并退出。

-w
--fullpage

仅显示包含整页镜像的记录。

-x xid
--xid=xid

仅显示标记有给定事务 ID 的记录。

-z
--stats[=record]

显示摘要统计信息(记录和整页镜像的数量及大小),而不是显示单条记录。还可以选择按记录类型而不是按资源管理器生成统计信息。

如果pg_waldump被信号SIGINT(Control+C)终止,则会显示截至终止点为止计算出的统计摘要。此操作在Windows 上不受支持。

--save-fullpage=save_path

将 WAL 记录中找到的整页镜像保存到save_path目录。保存的镜像会遵循与所显示记录相同的过滤和限制条件。

整页镜像按下列文件名格式保存:TIMELINE-LSN.RELTABLESPACE.DATOID.RELNODE.BLKNO_FORK 文件名由下列部分组成:

组成部分 说明
TIMELINE 记录所在 WAL 段文件的时间线,格式为一个 8 字符的十六进制数 %08X
LSN 带有该镜像的记录的LSN,格式为两个 8 字符的十六进制数 %08X-%08X
RELTABLESPACE 块的表空间 OID
DATOID 块的数据库 OID
RELNODE 块的文件节点
BLKNO 块的块号
FORK 该整页镜像来源的分支名称,例如 main、fsm、vm或init。
-?
--help

显示pg_waldump命令行参数的帮助信息,并退出。

环境

PGDATA

数据目录;另请参阅-p选项。

PG_COLOR

指定诊断消息是否使用颜色。可选值为 always、auto和 never。

注解

服务器运行时,可能给出错误的结果。

只显示指定的时间线(如果未指定,则使用默认时间线)。其他时间线中的记录会被忽略。

pg_waldump不能读取带有.partial后缀的 WAL 文件。如果需要读取这些文件,则必须从文件名中移除.partial 后缀。

文档与源码

来源构建
版本
18.6
构建
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
来源指纹
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8

版本比较

PostgreSQL 15 → 16: 属性变化。

以下差异保留原始字段名与英文源描述。

--- PostgreSQL 15
+++ PostgreSQL 16
@@ -59,7 +59,7 @@
       "signature": "-n limit --limit= limit"
     },
     {
-      "description": "Specifies a directory to search for log segment files or a directory with a pg_wal subdirectory that contains such files. The default is to search in the current directory, the pg_wal subdirectory of the current directory, and the pg_wal subdirectory of PGDATA .",
+      "description": "Specifies a directory to search for WAL segment files or a directory with a pg_wal subdirectory that contains such files. The default is to search in the current directory, the pg_wal subdirectory of the current directory, and the pg_wal subdirectory of PGDATA .",
       "names": [
         "-p path",
         "--path= path"
@@ -91,7 +91,7 @@
       "signature": "-R tblspc / db / rel --relation= tblspc / db / rel"
     },
     {
-      "description": "WAL location at which to start reading. The default is to start reading the first valid log record found in the earliest file found.",
+      "description": "WAL location at which to start reading. The default is to start reading the first valid WAL record found in the earliest file found.",
       "names": [
         "-s start",
         "--start= start"
@@ -99,7 +99,7 @@
       "signature": "-s start --start= start"
     },
     {
-      "description": "Timeline from which to read log records. The default is to use the value in startseg , if that is specified; otherwise, the default is 1.",
+      "description": "Timeline from which to read WAL records. The default is to use the value in startseg , if that is specified; otherwise, the default is 1. The value can be specified in decimal or hexadecimal, for example 17 or 0x11 .",
       "names": [
         "-t timeline",
         "--timeline= timeline"
@@ -139,6 +139,13 @@
       "signature": "-z --stats[=record]"
     },
     {
+      "description": "Save full page images found in the WAL records to the save_path directory. The images saved are subject to the same filtering and limiting criteria as the records displayed. The full page images are saved with the following file name format: TIMELINE - LSN . RELTABLESPACE . DATOID . RELNODE . BLKNO _ FORK The file names are composed of the following parts: Component Description TIMELINE The timeline of the WAL segment file where the record is located formatted as one 8-character hexadecimal number %08X LSN The LSN of the record with this image, formatted as two 8-character hexadecimal numbers %08X-%08X RELTABLESPACE tablespace OID of the block DATOID database OID of the block RELNODE filenode of the block BLKNO block number of the block FORK The name of the fork the full page image came from, such as main , fsm , vm , or init .",
+      "names": [
+        "--save-fullpage= save_path"
+      ],
+      "signature": "--save-fullpage= save_path"
+    },
+    {
       "description": "Show help about pg_waldump command line arguments, and exit.",
       "names": [
         "-?",

比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。

相关条目

导出 JSON · 返回命令行工具 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。