Postgresql 中文操作指南
pg_waldump
pg_waldump ——显示 PostgreSQL 数据库群集的预写日志的可读渲染内容
pg_waldump — display a human-readable rendering of the write-ahead log of a PostgreSQL database cluster
Description
pg_waldump 显示预写日志 (WAL),主要用于调试或教学目的。
pg_waldump displays the write-ahead log (WAL) and is mainly useful for debugging or educational purposes.
只有安装服务器的用户可以运行此实用程序,因为它需要对数据目录具有只读访问权。
This utility can only be run by the user who installed the server, because it requires read-only access to the data directory.
Options
以下命令行选项控制输出的位置和格式:
The following command-line options control the location and format of the output:
-
startseg
-
Start reading at the specified WAL segment file. This implicitly determines the path in which files will be searched for, and the timeline to use.
-
-
endseg
-
Stop after reading the specified WAL segment file.
-
-
-b_—bkp-details_
-
Output detailed information about backup blocks.
-
-
-B _block—block=_block
-
Only display records that modify the given block. The relation must also be provided with —relation or -R.
-
-
-e _end—end=_end
-
Stop reading at the specified WAL location, instead of reading to the end of the log stream.
-
-
-f_—follow_
-
After reaching the end of valid WAL, keep polling once per second for new WAL to appear.
-
-
-F _fork—fork=_fork
-
If provided, only display records that modify blocks in the given fork. The valid values are main for the main fork, fsm for the free space map, vm for the visibility map, and init for the init fork.
-
-
-n _limit—limit=_limit
-
Display the specified number of records, then stop.
-
-
-p _path—path=_path
-
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.
-
-
-q_—quiet_
-
Do not print any output, except for errors. This option can be useful when you want to know whether a range of WAL records can be successfully parsed but don’t care about the record contents.
-
-
-r _rmgr—rmgr=_rmgr
-
Only display records generated by the specified resource manager. You can specify the option multiple times to select multiple resource managers. If list is passed as name, print a list of valid resource manager names, and exit.
-
Extensions may define custom resource managers, but pg_waldump does not load the extension module and therefore does not recognize custom resource managers by name. Instead, you can specify the custom resource managers as custom where "" is the three-digit resource manager ID. Names of this form will always be considered valid.
-
-
-R _tblspc/db/rel—relation=_tblspc/db/rel
-
Only display records that modify blocks in the given relation. The relation is specified with tablespace OID, database OID, and relfilenode separated by slashes, for example 1234/12345/12345. This is the same format used for relations in the program’s output.
-
-
-s _start—start=_start
-
WAL location at which to start reading. The default is to start reading the first valid WAL record found in the earliest file found.
-
-
-t _timeline—timeline=_timeline
-
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.
-
-
-V_—version_
-
Print the pg_waldump version and exit.
-
-
-w_—fullpage_
-
Only display records that include full page images.
-
-
-x _xid—xid=_xid
-
Only display records marked with the given transaction ID.
-
-
-z_—stats[=record]_
-
Display summary statistics (number and size of records and full-page images) instead of individual records. Optionally generate statistics per-record instead of per-rmgr.
-
If pg_waldump is terminated by signal SIGINT (Control+C), the summary of the statistics computed is displayed up to the termination point. This operation is not supported on Windows.
-
-
—save-fullpage=_save_path_
-
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.BLKNOFORK_ The file names are composed of the following parts:
-
-
-?_—help_
-
Show help about pg_waldump command line arguments, and exit.
-
Environment
-
PGDATA
-
Data directory; see also the -p option.
-
-
PG_COLOR
-
Specifies whether to use color in diagnostic messages. Possible values are always, auto and never.
-
Notes
当服务器正在运行时可能会给错误的结果。
Can give wrong results when the server is running.
只会显示指定的 timeline(如果没有指定 timeline,则显示默认的)。会忽略其他 timeline 中的记录。
Only the specified timeline is displayed (or the default, if none is specified). Records in other timelines are ignored.
pg_waldump 无法读取后缀为 .partial 的 WAL 文件。如果需要读取这些文件,需要从文件名中删除 .partial 后缀。
pg_waldump cannot read WAL files with suffix .partial. If those files need to be read, .partial suffix needs to be removed from the file name.