Postgresql 中文操作指南

30.2. Data Checksums #

默认情况下,数据页面不受校验和保护,不过可以为此启用一个集群。在启用后,每个数据页面包含一个校验和,在页面写入时更新并在每次读取该页面时验证。只有数据页面受到校验和保护;内部数据结构和临时文件不受保护。

By default, data pages are not protected by checksums, but this can optionally be enabled for a cluster. When enabled, each data page includes a checksum that is updated when the page is written and verified each time the page is read. Only data pages are protected by checksums; internal data structures and temporary files are not.

当使用 initdb 来初始化集群时,通常启用校验和。它们也可以在稍后以脱机方式启用或禁用。数据校验和在整个集群级别启用或禁用,不能针对数据库或表分别指定。

Checksums are normally enabled when the cluster is initialized using initdb. They can also be enabled or disabled at a later time as an offline operation. Data checksums are enabled or disabled at the full cluster level, and cannot be specified individually for databases or tables.

可通过发出命令 _SHOW data_checksums_查看只读配置变量 data_checksums的当前状态来验证集群中校验和的当前状态。

The current state of checksums in the cluster can be verified by viewing the value of the read-only configuration variable data_checksums by issuing the command SHOW data_checksums.

在尝试从页面损坏中恢复时,可能需要绕过校验和保护。要执行此操作,请临时设置配置参数 ignore_checksum_failure

When attempting to recover from page corruptions, it may be necessary to bypass the checksum protection. To do this, temporarily set the configuration parameter ignore_checksum_failure.

30.2.1. Off-line Enabling of Checksums #

pg_checksums 应用程序可以用来针对脱机集群启用或禁用数据校验和,以及验证校验和。

The pg_checksums application can be used to enable or disable data checksums, as well as verify checksums, on an offline cluster.