codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_checksums</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgarchivecleanup.html" title="pg_archivecleanup" /><link rel="next" href="app-pgcontroldata.html" title="pg_controldata" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_checksums</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCHECKSUMS"><div class="titlepage"></div><a id="id-1.9.5.5.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_checksums</span></span></h2><p>pg_checksums — enable, disable or check data checksums in a <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.5.4.1"><code class="command">pg_checksums</code> [<em class="replaceable"><code>option</code></em>...] [[ <code class="option">-D</code> | <code class="option">--pgdata</code> ]<em class="replaceable"><code>datadir</code></em>]</p></div></div><div class="refsect1" id="R1-APP-PGCHECKSUMS-1"><h2>Description</h2><p>3 <span class="application">pg_checksums</span> checks, enables or disables data4 checksums in a <span class="productname">PostgreSQL</span> cluster. The server5 must be shut down cleanly before running6 <span class="application">pg_checksums</span>. When verifying checksums, the exit7 status is zero if there are no checksum errors, and nonzero if at least one8 checksum failure is detected. When enabling or disabling checksums, the9 exit status is nonzero if the operation failed.10 </p><p>11 When verifying checksums, every file in the cluster is scanned. When12 enabling checksums, each relation file block with a changed checksum is13 rewritten in-place.14 Disabling checksums only updates the file <code class="filename">pg_control</code>.15 </p></div><div class="refsect1" id="id-1.9.5.5.6"><h2>Options</h2><p>16 The following command-line options are available:17 18 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>19 Specifies the directory where the database cluster is stored.20 </p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--check</code></span></dt><dd><p>21 Checks checksums. This is the default mode if nothing else is22 specified.23 </p></dd><dt><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--disable</code></span></dt><dd><p>24 Disables checksums.25 </p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--enable</code></span></dt><dd><p>26 Enables checksums.27 </p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filenode</code></em></code><br /></span><span class="term"><code class="option">--filenode=<em class="replaceable"><code>filenode</code></em></code></span></dt><dd><p>28 Only validate checksums in the relation with filenode29 <em class="replaceable"><code>filenode</code></em>.30 </p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>31 By default, <code class="command">pg_checksums</code> will wait for all files32 to be written safely to disk. This option causes33 <code class="command">pg_checksums</code> to return without waiting, which is34 faster, but means that a subsequent operating system crash can leave35 the updated data directory corrupt. Generally, this option is useful36 for testing but should not be used on a production installation.37 This option has no effect when using <code class="literal">--check</code>.38 </p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>39 Enable progress reporting. Turning this on will deliver a progress40 report while checking or enabling checksums.41 </p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>42 Enable verbose output. Lists all checked files.43 </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>44 Print the <span class="application">pg_checksums</span> version and exit.45 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>46 Show help about <span class="application">pg_checksums</span> command line47 arguments, and exit.48 </p></dd></dl></div><p>49 </p></div><div class="refsect1" id="id-1.9.5.5.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>50 Specifies the directory where the database cluster is51 stored; can be overridden using the <code class="option">-D</code> option.52 </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>53 Specifies whether to use color in diagnostic messages. Possible values54 are <code class="literal">always</code>, <code class="literal">auto</code> and55 <code class="literal">never</code>.56 </p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.5.8"><h2>Notes</h2><p>57 Enabling checksums in a large cluster can potentially take a long time.58 During this operation, the cluster or other programs that write to the59 data directory must not be started or else data loss may occur.60 </p><p>61 When using a replication setup with tools which perform direct copies62 of relation file blocks (for example <a class="xref" href="app-pgrewind.html" title="pg_rewind"><span class="refentrytitle"><span class="application">pg_rewind</span></span></a>),63 enabling or disabling checksums can lead to page corruptions in the64 shape of incorrect checksums if the operation is not done consistently65 across all nodes. When enabling or disabling checksums in a replication66 setup, it is thus recommended to stop all the clusters before switching67 them all consistently. Destroying all standbys, performing the operation68 on the primary and finally recreating the standbys from scratch is also69 safe.70 </p><p>71 If <span class="application">pg_checksums</span> is aborted or killed while72 enabling or disabling checksums, the cluster's data checksum configuration73 remains unchanged, and <span class="application">pg_checksums</span> can be74 re-run to perform the same operation.75 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_archivecleanup</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_controldata</span></td></tr></table></div></body></html>