gooderp18绿色标准版
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

94 lines
9.2KB

  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_archivecleanup</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 V1.79.1" /><link rel="prev" href="app-initdb.html" title="initdb" /><link rel="next" href="app-pgchecksums.html" title="pg_checksums" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span xmlns="http://www.w3.org/1999/xhtml" class="application">pg_archivecleanup</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-initdb.html" title="initdb">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 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgchecksums.html" title="pg_checksums">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="PGARCHIVECLEANUP"><div class="titlepage"></div><a id="id-1.9.5.4.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_archivecleanup</span></span></h2><p>pg_archivecleanup — clean up <span class="productname">PostgreSQL</span> WAL archive files</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.4.4.1"><code class="command">pg_archivecleanup</code> [<em class="replaceable"><code>option</code></em>...] <em class="replaceable"><code>archivelocation</code></em> <em class="replaceable"><code>oldestkeptwalfile</code></em> </p></div></div><div class="refsect1" id="id-1.9.5.4.5"><h2>Description</h2><p>
  3. <span class="application">pg_archivecleanup</span> is designed to be used as an
  4. <code class="literal">archive_cleanup_command</code> to clean up WAL file archives when
  5. running as a standby server (see <a class="xref" href="warm-standby.html" title="26.2. Log-Shipping Standby Servers">Section 26.2</a>).
  6. <span class="application">pg_archivecleanup</span> can also be used as a standalone program to
  7. clean WAL file archives.
  8. </p><p>
  9. To configure a standby
  10. server to use <span class="application">pg_archivecleanup</span>, put this into its
  11. <code class="filename">postgresql.conf</code> configuration file:
  12. </p><pre class="programlisting">
  13. archive_cleanup_command = 'pg_archivecleanup <em class="replaceable"><code>archivelocation</code></em> %r'
  14. </pre><p>
  15. where <em class="replaceable"><code>archivelocation</code></em> is the directory from which WAL segment
  16. files should be removed.
  17. </p><p>
  18. When used within <a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-CLEANUP-COMMAND">archive_cleanup_command</a>, all WAL files
  19. logically preceding the value of the <code class="literal">%r</code> argument will be removed
  20. from <em class="replaceable"><code>archivelocation</code></em>. This minimizes the number of files
  21. that need to be retained, while preserving crash-restart capability. Use of
  22. this parameter is appropriate if the <em class="replaceable"><code>archivelocation</code></em> is a
  23. transient staging area for this particular standby server, but
  24. <span class="emphasis"><em>not</em></span> when the <em class="replaceable"><code>archivelocation</code></em> is intended as a
  25. long-term WAL archive area, or when multiple standby servers are recovering
  26. from the same archive location.
  27. </p><p>
  28. When used as a standalone program all WAL files logically preceding the
  29. <em class="replaceable"><code>oldestkeptwalfile</code></em> will be removed from <em class="replaceable"><code>archivelocation</code></em>.
  30. In this mode, if you specify a <code class="filename">.partial</code> or <code class="filename">.backup</code>
  31. file name, then only the file prefix will be used as the
  32. <em class="replaceable"><code>oldestkeptwalfile</code></em>. This treatment of <code class="filename">.backup</code>
  33. file name allows you to remove
  34. all WAL files archived prior to a specific base backup without error.
  35. For example, the following example will remove all files older than
  36. WAL file name <code class="filename">000000010000003700000010</code>:
  37. </p><pre class="programlisting">
  38. pg_archivecleanup -d archive 000000010000003700000010.00000020.backup
  39. pg_archivecleanup: keep WAL file "archive/000000010000003700000010" and later
  40. pg_archivecleanup: removing file "archive/00000001000000370000000F"
  41. pg_archivecleanup: removing file "archive/00000001000000370000000E"
  42. </pre><p>
  43. </p><p>
  44. <span class="application">pg_archivecleanup</span> assumes that
  45. <em class="replaceable"><code>archivelocation</code></em> is a directory readable and writable by the
  46. server-owning user.
  47. </p></div><div class="refsect1" id="id-1.9.5.4.6"><h2>Options</h2><p>
  48. <span class="application">pg_archivecleanup</span> accepts the following command-line arguments:
  49. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d</code></span></dt><dd><p>
  50. Print lots of debug logging output on <code class="filename">stderr</code>.
  51. </p></dd><dt><span class="term"><code class="option">-n</code></span></dt><dd><p>
  52. Print the names of the files that would have been removed on <code class="filename">stdout</code> (performs a dry run).
  53. </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>
  54. Print the <span class="application">pg_archivecleanup</span> version and exit.
  55. </p></dd><dt><span class="term"><code class="option">-x</code> <em class="replaceable"><code>extension</code></em></span></dt><dd><p>
  56. Provide an extension
  57. that will be stripped from all file names before deciding if they
  58. should be deleted. This is typically useful for cleaning up archives
  59. that have been compressed during storage, and therefore have had an
  60. extension added by the compression program. For example: <code class="literal">-x
  61. .gz</code>.
  62. </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
  63. Show help about <span class="application">pg_archivecleanup</span> command line
  64. arguments, and exit.
  65. </p></dd></dl></div><p>
  66. </p></div><div class="refsect1" id="id-1.9.5.4.7"><h2>Environment</h2><p>
  67. The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
  68. color in diagnostic messages. Possible values are
  69. <code class="literal">always</code>, <code class="literal">auto</code> and
  70. <code class="literal">never</code>.
  71. </p></div><div class="refsect1" id="id-1.9.5.4.8"><h2>Notes</h2><p>
  72. <span class="application">pg_archivecleanup</span> is designed to work with
  73. <span class="productname">PostgreSQL</span> 8.0 and later when used as a standalone utility,
  74. or with <span class="productname">PostgreSQL</span> 9.0 and later when used as an
  75. archive cleanup command.
  76. </p><p>
  77. <span class="application">pg_archivecleanup</span> is written in C and has an
  78. easy-to-modify source code, with specifically designated sections to modify
  79. for your own needs
  80. </p></div><div class="refsect1" id="id-1.9.5.4.9"><h2>Examples</h2><p>On Linux or Unix systems, you might use:
  81. </p><pre class="programlisting">
  82. archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2&gt;&gt;cleanup.log'
  83. </pre><p>
  84. where the archive directory is physically located on the standby server,
  85. so that the <code class="varname">archive_command</code> is accessing it across NFS,
  86. but the files are local to the standby.
  87. This will:
  88. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  89. produce debugging output in <code class="filename">cleanup.log</code>
  90. </p></li><li class="listitem"><p>
  91. remove no-longer-needed files from the archive directory
  92. </p></li></ul></div></div><div class="refsect1" id="id-1.9.5.4.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="pgstandby.html" title="pg_standby"><span class="refentrytitle"><span class="application">pg_standby</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-initdb.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgchecksums.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">initdb </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_checksums</span></td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1