{"kind": "tool", "major": "18", "item": {"slug": "pg-rewind", "name": "pg_rewind", "name_zh": "", "category": "\u670d\u52a1\u7aef\u7a0b\u5e8f", "summary": "pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65", "aliases": ["pg_rewind"], "content_hash": "d0eaa753205974be5a3a949dadfba08a002abb250d558a6226c309767271da7b", "versions": {"10": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "10.23"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "8"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u5177\u6709\u8d85\u7ea7\u7528\u6237\u6743\u9650\u7684\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "--debug"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/10/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/10/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/10/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with superuser access. This option requires the source server to be running and not in recovery mode.", "signature": "--source-server= connstr", "source_url": "/docs/10/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with superuser access. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/10/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/10/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/10/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/10/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/10/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/10/postgresql-10-A4.pdf", "bytes": 12631706, "pages": 2591, "sha256": "34497ab9efb45c5bdf1bd11b9016b5451354feb462fa029cf74557a5fa5fbbc1", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/10/postgresql-10-US.pdf", "bytes": 12531684, "pages": 2724, "sha256": "429cc7133ddf4f97c560aa466dc9caea4b718721a8321e293357037cf0af4733", "built_at": "2026-09-26"}}, "tree": "10", "index": "index.html", "major": "10", "pages": 1085, "release": "10.23", "source_url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea", "evidence_kind": "English manual and source declarations", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "sources": [{"url": "https://pg.center/docs/10/app-pgrewind.html", "file": "app-pgrewind.html", "label": "10.23 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "c4cd0b0186e43941690458e578d637cd6be90805bfe55db4b07ed509c6ff7a28", "language": "en", "original_url": "/docs/10/app-pgrewind.html"}, {"url": "https://pg.center/docs/10/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "2a6043b88501763a31348758a370a42cd7f9a179c7fdf3ef0e353c82e95b33e9", "language": "en", "original_url": "/docs/10/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00PostgreSQL\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u5176\u7ed3\u679c\u76f8\u5f53\u4e8e\u7528\u6e90\u6570\u636e\u76ee\u5f55\u66ff\u6362\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5bf9\u4e8e\u5173\u7cfb\u6587\u4ef6\uff0c\u53ea\u590d\u5236\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4ed6\u6240\u6709\u6587\u4ef6\uff08\u5305\u62ec\u914d\u7f6e\u6587\u4ef6\uff09\u90fd\u6574\u4f53\u590d\u5236\u3002<span class=\"application\">pg_rewind</span>\u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e<span class=\"application\">pg_rewind</span>\u65e0\u9700\u901a\u8bfb\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\u5f53\u6570\u636e\u5e93\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u8fd9\u4f7f\u5b83\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\u9996\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u6062\u590d\u6a21\u5f0f\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u5728\u5206\u53c9\u70b9\u4e4b\u540e\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.conf</code>\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684<code class=\"varname\">restore_command</code>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/10/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/10/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u5177\u6709\u8d85\u7ea7\u7528\u6237\u6743\u9650\u7684\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/10/libpq-envars.html\" title=\"33.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a033.14\u00a0\u8282</a>\uff09\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u4f7f\u7528\u6700\u8fd1\u521a\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6765\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u5fc5\u987b\u5728\u63d0\u5347\u540e\u6267\u884c<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\u3002<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u68c0\u67e5\u80fd\u5426\u5229\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.8.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u4f8b\u5982<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff08\u5173\u7cfb\u6587\u4ef6\u9664\u5916\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u5e94\u7528\u6e90\u96c6\u7c07\u7684 WAL\u3002\uff08\u4e25\u683c\u6765\u8bf4\uff0c<span class=\"application\">pg_rewind</span>\u5e76\u4e0d\u5e94\u7528 WAL\uff0c\u5b83\u53ea\u662f\u521b\u5efa\u4e00\u4e2a\u5907\u4efd\u6807\u7b7e\u6587\u4ef6\uff0c\u8ba9<span class=\"productname\">PostgreSQL</span>\u5728\u542f\u52a8\u65f6\u91cd\u653e\u4ece\u8be5\u68c0\u67e5\u70b9\u8d77\u7684\u5168\u90e8 WAL\u3002\uff09</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/10/app-pgrewind.html", "method": "same-major semantic node", "sha256": "c10c32c750d088503e8abaf5d58d93ed1fb739b82767e5a4db4d2d0224b467c2", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[15]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[7]/div[2]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[2]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[2]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[2]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[2]/h3[0]", "#APP-PGREWIND/div[7]/div[2]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/10/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/10/facts/0/label": "Documented executable", "/versions/10/facts/1/label": "Executable version", "/versions/10/facts/2/label": "Reference inventory", "/versions/10/facts/2/value": "Server applications", "/versions/10/facts/3/label": "Option definition groups", "/versions/10/tables/0/title": "Documented options", "/versions/10/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/10/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/10/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with superuser access. This option requires the source server to be running and not in recovery mode.", "/versions/10/tables/0/rows/3/summary": "Do everything except actually modifying the target directory.", "/versions/10/tables/0/rows/4/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/10/tables/0/rows/5/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/10/tables/0/rows/6/summary": "Display version information, then exit.", "/versions/10/tables/0/rows/7/summary": "Show help, then exit.", "/versions/10/tables/0/columns/0/label": "Option and arguments", "/versions/10/tables/0/columns/1/label": "Description"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "a9d3965e9edc07b62ceb67afa35d5a94328488afe2784a3866d9128225fa62d5"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with superuser access. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "96b5183f2b390e61e852c65532a9411aa43692006bddfabbd5856dd42b08e8f4", "manual_language": "zh"}, "11": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "11.22"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "8"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "--debug"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/11/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/11/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/11/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "signature": "--source-server= connstr", "source_url": "/docs/11/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/11/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/11/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/11/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/11/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/11/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/11/postgresql-11-A4.pdf", "bytes": 13057499, "pages": 2732, "sha256": "41d75855e610d0d9b8802b87dc5b080bef8d7e91c7cf69401fbf8d3cf801b4b5", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/11/postgresql-11-US.pdf", "bytes": 12961189, "pages": 2883, "sha256": "6a8899ef36935a5b7ed2b436207564a567a4ef1eb1c2200195876b8de4d4fa30", "built_at": "2026-09-26"}}, "tree": "11", "index": "index.html", "major": "11", "pages": 1125, "release": "11.22", "source_url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f", "evidence_kind": "English manual and source declarations", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "sources": [{"url": "https://pg.center/docs/11/app-pgrewind.html", "file": "app-pgrewind.html", "label": "11.22 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "59e6b61d8848111c710f8973305e3a2b04482bc683f1196d1b91c3bc12671f60", "language": "en", "original_url": "/docs/11/app-pgrewind.html"}, {"url": "https://pg.center/docs/11/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e940a8505b6742c717a1683d19bf8f759aad245633a59db9e83a345ae7c5709a", "language": "en", "original_url": "/docs/11/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00PostgreSQL\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u5176\u7ed3\u679c\u76f8\u5f53\u4e8e\u7528\u6e90\u6570\u636e\u76ee\u5f55\u66ff\u6362\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5bf9\u4e8e\u5173\u7cfb\u6587\u4ef6\uff0c\u53ea\u590d\u5236\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4ed6\u6240\u6709\u6587\u4ef6\uff08\u5305\u62ec\u914d\u7f6e\u6587\u4ef6\uff09\u90fd\u6574\u4f53\u590d\u5236\u3002<span class=\"application\">pg_rewind</span>\u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e<span class=\"application\">pg_rewind</span>\u65e0\u9700\u901a\u8bfb\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\u5f53\u6570\u636e\u5e93\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u8fd9\u4f7f\u5b83\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\u9996\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u6062\u590d\u6a21\u5f0f\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u5728\u5206\u53c9\u70b9\u4e4b\u540e\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.conf</code>\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684<code class=\"varname\">restore_command</code>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/11/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/11/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/11/libpq-envars.html\" title=\"34.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a034.14\u00a0\u8282</a>\uff09\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<p lang=\"zh\">\u4f7f\u7528\u6700\u8fd1\u521a\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6765\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u5fc5\u987b\u5728\u63d0\u5347\u540e\u6267\u884c<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\u3002<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u68c0\u67e5\u80fd\u5426\u5229\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.8.8.4\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u4f8b\u5982<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff08\u5173\u7cfb\u6587\u4ef6\u9664\u5916\uff09\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u90fd\u4f1a\u88ab\u7701\u7565\uff0c<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u548c<code class=\"filename\">postmaster.pid</code>\u4e5f\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u5e94\u7528\u6e90\u96c6\u7c07\u7684 WAL\u3002\uff08\u4e25\u683c\u6765\u8bf4\uff0c<span class=\"application\">pg_rewind</span>\u5e76\u4e0d\u5e94\u7528 WAL\uff0c\u5b83\u53ea\u662f\u521b\u5efa\u4e00\u4e2a\u5907\u4efd\u6807\u7b7e\u6587\u4ef6\uff0c\u8ba9<span class=\"productname\">PostgreSQL</span>\u5728\u542f\u52a8\u65f6\u91cd\u653e\u4ece\u8be5\u68c0\u67e5\u70b9\u8d77\u7684\u5168\u90e8 WAL\u3002\uff09</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/11/app-pgrewind.html", "method": "same-major semantic node", "sha256": "6f4eff8048019f8b010b55bd111de0b95e6b6019df709dccf65c9b8fbb0e111d", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[15]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[4]/h3[0]", "#APP-PGREWIND/div[7]/div[4]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]", "#APP-PGREWIND/div[7]/p[3]"]}], "language": "zh", "original_text": {"/versions/11/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/11/facts/0/label": "Documented executable", "/versions/11/facts/1/label": "Executable version", "/versions/11/facts/2/label": "Reference inventory", "/versions/11/facts/2/value": "Server applications", "/versions/11/facts/3/label": "Option definition groups", "/versions/11/tables/0/title": "Documented options", "/versions/11/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/11/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/11/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "/versions/11/tables/0/rows/3/summary": "Do everything except actually modifying the target directory.", "/versions/11/tables/0/rows/4/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/11/tables/0/rows/5/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/11/tables/0/rows/6/summary": "Display version information, then exit.", "/versions/11/tables/0/rows/7/summary": "Show help, then exit.", "/versions/11/tables/0/columns/0/label": "Option and arguments", "/versions/11/tables/0/columns/1/label": "Description"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "497cecb153b51d4fb943234129231ccc1175f24a2c876cb2015a91cdea2c3e07"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "092da9dcb834c249ec28f1d17f7622dbc7c0cd824f86be2b0853485eeeab35ea", "manual_language": "zh"}, "12": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "12.22"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "9"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "--debug"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/12/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/12/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/12/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "signature": "--source-server= connstr", "source_url": "/docs/12/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/12/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.", "signature": "-N --no-sync", "source_url": "/docs/12/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used when creating a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/12/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/12/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/12/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/12/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/12/postgresql-12-A4.pdf", "bytes": 13424351, "pages": 2803, "sha256": "7422cf53fd1939e7a3d2925231a88b0330e468afa5393627cac0ff86158a0621", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/12/postgresql-12-US.pdf", "bytes": 13322565, "pages": 2958, "sha256": "51f3b04e72907fc38512685946223452ea65f84419c60c66241dfa3396035e77", "built_at": "2026-09-26"}}, "tree": "12", "index": "index.html", "major": "12", "pages": 1131, "release": "12.22", "source_url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "svg_assets": 2, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4", "evidence_kind": "English manual and source declarations", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "sources": [{"url": "https://pg.center/docs/12/app-pgrewind.html", "file": "app-pgrewind.html", "label": "12.22 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "9c37a508ca2d478d748aebf470365424f39abcc001aee5dfb3bacd16edab5719", "language": "en", "original_url": "/docs/12/app-pgrewind.html"}, {"url": "https://pg.center/docs/12/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "7f6ae1fadc1b0bffa606551460e62aacdc2508a3fb66566ddae861928ca6080b", "language": "en", "original_url": "/docs/12/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00PostgreSQL\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u5176\u7ed3\u679c\u76f8\u5f53\u4e8e\u7528\u6e90\u6570\u636e\u76ee\u5f55\u66ff\u6362\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5bf9\u4e8e\u5173\u7cfb\u6587\u4ef6\uff0c\u53ea\u590d\u5236\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4ed6\u6240\u6709\u6587\u4ef6\uff08\u5305\u62ec\u914d\u7f6e\u6587\u4ef6\uff09\u90fd\u6574\u4f53\u590d\u5236\u3002<span class=\"application\">pg_rewind</span>\u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e<span class=\"application\">pg_rewind</span>\u65e0\u9700\u901a\u8bfb\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\u5f53\u6570\u636e\u5e93\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u8fd9\u4f7f\u5b83\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\u9996\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u6062\u590d\u6a21\u5f0f\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u5728\u5206\u53c9\u70b9\u4e4b\u540e\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/12/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\uff08\u4f4d\u4e8e<code class=\"filename\">postgresql.conf</code>\u4e2d\uff09\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/12/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/12/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/12/libpq-envars.html\" title=\"33.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a033.14\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<p lang=\"zh\">\u4f7f\u7528\u6700\u8fd1\u521a\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6765\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u5fc5\u987b\u5728\u63d0\u5347\u540e\u6267\u884c<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\u3002<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u68c0\u67e5\u80fd\u5426\u5229\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.9.8.4\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u4f8b\u5982<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff08\u5173\u7cfb\u6587\u4ef6\u9664\u5916\uff09\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u90fd\u4f1a\u88ab\u7701\u7565\uff0c<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u548c<code class=\"filename\">postmaster.pid</code>\u4e5f\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u5e94\u7528\u6e90\u96c6\u7c07\u7684 WAL\u3002\uff08\u4e25\u683c\u6765\u8bf4\uff0c<span class=\"application\">pg_rewind</span>\u5e76\u4e0d\u5e94\u7528 WAL\uff0c\u5b83\u53ea\u662f\u521b\u5efa\u4e00\u4e2a\u5907\u4efd\u6807\u7b7e\u6587\u4ef6\uff0c\u8ba9<span class=\"productname\">PostgreSQL</span>\u5728\u542f\u52a8\u65f6\u91cd\u653e\u4ece\u8be5\u68c0\u67e5\u70b9\u8d77\u7684\u5168\u90e8 WAL\u3002\uff09</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/12/app-pgrewind.html", "method": "same-major semantic node", "sha256": "e6c04d00c3ca8b823d671731a0efa50c3bcea15fbff52ae5e123cef5f4e7708a", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[15]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[17]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[4]/h3[0]", "#APP-PGREWIND/div[7]/div[4]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]", "#APP-PGREWIND/div[7]/p[3]"]}], "language": "zh", "original_text": {"/versions/12/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/12/facts/0/label": "Documented executable", "/versions/12/facts/1/label": "Executable version", "/versions/12/facts/2/label": "Reference inventory", "/versions/12/facts/2/value": "Server applications", "/versions/12/facts/3/label": "Option definition groups", "/versions/12/tables/0/title": "Documented options", "/versions/12/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/12/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/12/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "/versions/12/tables/0/rows/3/summary": "Do everything except actually modifying the target directory.", "/versions/12/tables/0/rows/4/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.", "/versions/12/tables/0/rows/5/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/12/tables/0/rows/6/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/12/tables/0/rows/7/summary": "Display version information, then exit.", "/versions/12/tables/0/rows/8/summary": "Show help, then exit.", "/versions/12/tables/0/columns/0/label": "Option and arguments", "/versions/12/tables/0/columns/1/label": "Description"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "0dafb49e2de1441342587909f165bb588d0f1d0fe3e25a8b0a045f4755269189"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used when creating a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "9d1017a212b05e2ae1aa412c9332ef1ba556d6c390ebdd79bd23343b584004fc", "manual_language": "zh"}, "13": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "13.23"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "12"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/13/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/13/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/13/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "signature": "--source-server= connstr", "source_url": "/docs/13/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/13/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/13/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/13/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/13/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/13/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/13/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/13/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/13/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/13/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/13/postgresql-13-A4.pdf", "bytes": 13843239, "pages": 2826, "sha256": "171cc09f90936dbc1cbd503a98ff07ae72ea58ab9771ff051313f1217737799c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/13/postgresql-13-US.pdf", "bytes": 13739572, "pages": 2984, "sha256": "48d09c6e197d9db4220f41afe83efe848a8661b1b168d3b89419751ecaf6c24d", "built_at": "2026-09-26"}}, "tree": "13", "index": "index.html", "major": "13", "pages": 1139, "release": "13.23", "source_url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6", "evidence_kind": "English manual and source declarations", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "sources": [{"url": "https://pg.center/docs/13/app-pgrewind.html", "file": "app-pgrewind.html", "label": "13.23 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "872413952b6c6f71ae9e8800961efa72be6e04c03cd117e301ebf4ac38a48d4e", "language": "en", "original_url": "/docs/13/app-pgrewind.html"}, {"url": "https://pg.center/docs/13/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "074ef8577fd368272a2360309e1226e2d0b1e570a3e1da62dfcca63ac9ee5539", "language": "en", "original_url": "/docs/13/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00PostgreSQL\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/13/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/13/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e14\u4e0d\u5904\u4e8e\u6062\u590d\u6a21\u5f0f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/13/libpq-envars.html\" title=\"33.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a033.14\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<p lang=\"zh\">\u4f7f\u7528\u6700\u8fd1\u521a\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6765\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u5fc5\u987b\u5728\u63d0\u5347\u540e\u6267\u884c<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\u3002<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u68c0\u67e5\u80fd\u5426\u5229\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.9.8.4\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\u5c06\u5176\u4ed6\u6240\u6709\u6587\u4ef6\u4ece\u6e90\u96c6\u7fa4\u590d\u5236\u5230\u76ee\u6807\u96c6\u7fa4\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001pg_xact \u548c\u914d\u7f6e\u6587\u4ef6\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u590d\u5236\u6e90\u96c6\u7fa4\u6570\u636e\u65f6\u4f1a\u7565\u8fc7 pg_dynshmem/\u3001pg_notify/\u3001pg_replslot/\u3001pg_serial/\u3001pg_snapshots/\u3001pg_stat_tmp/ \u548c pg_subtrans/ \u76ee\u5f55\u4e2d\u7684\u5185\u5bb9\u3002\u8fd8\u4f1a\u7565\u8fc7 backup_label\u3001tablespace_map\u3001pg_internal.init\u3001postmaster.opts \u548c postmaster.pid \u6587\u4ef6\uff0c\u4ee5\u53ca\u4efb\u4f55\u4ee5 pgsql_tmp \u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u3002</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/13/app-pgrewind.html", "method": "same-major semantic node", "sha256": "1322ceef7bd03768503e378694f2b685e49f24b83b05cae9bc3fea2071f041b5", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[17]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[4]/h3[0]", "#APP-PGREWIND/div[7]/div[4]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]", "#APP-PGREWIND/div[7]/p[3]"]}], "language": "zh", "original_text": {"/versions/13/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/13/facts/0/label": "Documented executable", "/versions/13/facts/1/label": "Executable version", "/versions/13/facts/2/label": "Reference inventory", "/versions/13/facts/2/value": "Server applications", "/versions/13/facts/3/label": "Option definition groups", "/versions/13/tables/0/title": "Documented options", "/versions/13/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/13/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/13/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode.", "/versions/13/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "/versions/13/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/13/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/13/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/13/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/13/tables/0/rows/8/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/13/tables/0/rows/9/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/13/tables/0/columns/0/label": "Option and arguments", "/versions/13/tables/0/columns/1/label": "Description", "/versions/13/tables/0/rows/10/summary": "Display version information, then exit.", "/versions/13/tables/0/rows/11/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "3468064df0881e55398c832415cddf0b4894f19bce42546393b49102e2b4fca7"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and not in recovery mode."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "6c7bbd834621ae8ce0bc3b5048f5c1e21016d03979db8199510aa413ee8d0be1", "manual_language": "zh"}, "14": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "14.24"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "12"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/14/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/14/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/14/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/14/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/14/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/14/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/14/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/14/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/14/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/14/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/14/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/14/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/14/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/14/postgresql-14-A4.pdf", "bytes": 14354704, "pages": 2944, "sha256": "8bc6b9dd7b246888bb77f0a5e8c39a2eae52e9926569832669c7d1600becb27c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/14/postgresql-14-US.pdf", "bytes": 14242178, "pages": 3102, "sha256": "b7ecb5a5f62d8b9f73a69e25a7d26ba285373bc53168a553bff7b77955506db4", "built_at": "2026-09-26"}}, "tree": "14", "index": "index.html", "major": "14", "pages": 1158, "release": "14.24", "source_url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae", "evidence_kind": "English manual and source declarations", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "sources": [{"url": "https://pg.center/docs/14/app-pgrewind.html", "file": "app-pgrewind.html", "label": "14.24 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "c39a3345fa1f6830b9fca6b7369a8b8331483b00bdd5999b180e0b492bf83b48", "language": "en", "original_url": "/docs/14/app-pgrewind.html"}, {"url": "https://pg.center/docs/14/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "db0cdccaa8d3c65ad3b2a07d4956eb5a783a18505bfa0f9d9626eef4ab94fe44", "language": "en", "original_url": "/docs/14/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/14/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\u3002\u8fd9\u4e24\u9879\u76ee\u524d\u9ed8\u8ba4\u90fd\u6ca1\u6709\u542f\u7528\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/14/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/14/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/14/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a034.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u6700\u8fd1\u521a\u88ab\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u9700\u8981\u5728\u63d0\u5347\u4e4b\u540e\u6267\u884c\u4e00\u6b21<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\uff1b<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u6765\u68c0\u67e5\u662f\u5426\u53ef\u4ee5\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.9.8.4\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\u5c06\u5176\u4ed6\u6240\u6709\u6587\u4ef6\u4ece\u6e90\u96c6\u7fa4\u590d\u5236\u5230\u76ee\u6807\u96c6\u7fa4\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001pg_xact \u548c\u914d\u7f6e\u6587\u4ef6\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u590d\u5236\u6e90\u96c6\u7fa4\u6570\u636e\u65f6\u4f1a\u7565\u8fc7 pg_dynshmem/\u3001pg_notify/\u3001pg_replslot/\u3001pg_serial/\u3001pg_snapshots/\u3001pg_stat_tmp/ \u548c pg_subtrans/ \u76ee\u5f55\u4e2d\u7684\u5185\u5bb9\u3002\u8fd8\u4f1a\u7565\u8fc7 backup_label\u3001tablespace_map\u3001pg_internal.init\u3001postmaster.opts \u548c postmaster.pid \u6587\u4ef6\uff0c\u4ee5\u53ca\u4efb\u4f55\u4ee5 pgsql_tmp \u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u3002</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/14/app-pgrewind.html", "method": "same-major semantic node", "sha256": "e74c7f9e2153562c38548ccea5fa5107b8e450f90d184f51054e6c2666c8c6ea", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[17]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[4]/h3[0]", "#APP-PGREWIND/div[7]/div[4]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]", "#APP-PGREWIND/div[7]/p[3]"]}], "language": "zh", "original_text": {"/versions/14/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/14/facts/0/label": "Documented executable", "/versions/14/facts/1/label": "Executable version", "/versions/14/facts/2/label": "Reference inventory", "/versions/14/facts/2/value": "Server applications", "/versions/14/facts/3/label": "Option definition groups", "/versions/14/tables/0/title": "Documented options", "/versions/14/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/14/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/14/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/14/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "/versions/14/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/14/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/14/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/14/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/14/tables/0/rows/8/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/14/tables/0/rows/9/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/14/tables/0/columns/0/label": "Option and arguments", "/versions/14/tables/0/columns/1/label": "Description", "/versions/14/tables/0/rows/10/summary": "Display version information, then exit.", "/versions/14/tables/0/rows/11/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "0f532b248ed89d204575cf834cbc53210d049e5ec9d85dc053f23e23ff40358b"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "b3eb33077ff8ca1f2ef6abd13d7ef8e6a4f283b603a3c2d90805bcad7f7f9a8f", "manual_language": "zh"}, "15": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "15.19"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/15/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/15/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/15/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/15/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/15/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/15/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/15/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/15/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/15/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/15/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/15/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/15/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/15/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/15/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/15/postgresql-15-A4.pdf", "bytes": 14609140, "pages": 2987, "sha256": "66228564a4d16efb47d6a914085716ecfe22ca1566db56bc7c3d82f790646d72", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/15/postgresql-15-US.pdf", "bytes": 14495690, "pages": 3153, "sha256": "645a498c2390d47a6223ec74770631185807a19c484edb0fc5a295d9f460bc02", "built_at": "2026-09-26"}}, "tree": "15", "index": "index.html", "major": "15", "pages": 1168, "release": "15.19", "source_url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545", "evidence_kind": "English manual and source declarations", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "sources": [{"url": "https://pg.center/docs/15/app-pgrewind.html", "file": "app-pgrewind.html", "label": "15.19 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "dda1f5f230ff9ad8bb72961bcf86367ce739afb3b91c5f62d5b349867a43e7ab", "language": "en", "original_url": "/docs/15/app-pgrewind.html"}, {"url": "https://pg.center/docs/15/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1240cfbb13ebfd22aac8d5ae40c62a9015b246f7774bcf0bce97355ce06350a0", "language": "en", "original_url": "/docs/15/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/15/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\u3002\u8fd9\u4e24\u9879\u76ee\u524d\u9ed8\u8ba4\u90fd\u6ca1\u6709\u542f\u7528\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/15/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/15/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/15/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a034.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u6700\u8fd1\u521a\u88ab\u63d0\u5347\u7684\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u9700\u8981\u5728\u63d0\u5347\u4e4b\u540e\u6267\u884c\u4e00\u6b21<code class=\"command\">CHECKPOINT</code>\uff0c\u4f7f\u5176\u63a7\u5236\u6587\u4ef6\u53cd\u6620\u6700\u65b0\u7684\u65f6\u95f4\u7ebf\u4fe1\u606f\uff1b<span class=\"application\">pg_rewind</span>\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u6765\u68c0\u67e5\u662f\u5426\u53ef\u4ee5\u7528\u6307\u5b9a\u7684\u6e90\u96c6\u7c07\u56de\u5377\u76ee\u6807\u96c6\u7c07\u3002</p>\n<div class=\"refsect2\" id=\"id-1.9.5.9.8.4\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/15/app-pgrewind.html", "method": "same-major semantic node", "sha256": "21bac634ecd7783ae894aa0dc19b76f0365c12f709ff2c3211b3d131f9990e40", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[4]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[4]/h3[0]", "#APP-PGREWIND/div[7]/div[4]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]", "#APP-PGREWIND/div[7]/p[3]"]}], "language": "zh", "original_text": {"/versions/15/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/15/facts/0/label": "Documented executable", "/versions/15/facts/1/label": "Executable version", "/versions/15/facts/2/label": "Reference inventory", "/versions/15/facts/2/value": "Server applications", "/versions/15/facts/3/label": "Option definition groups", "/versions/15/tables/0/title": "Documented options", "/versions/15/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/15/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/15/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/15/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "/versions/15/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/15/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/15/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/15/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/15/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/15/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/15/tables/0/columns/0/label": "Option and arguments", "/versions/15/tables/0/columns/1/label": "Description", "/versions/15/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/15/tables/0/rows/11/summary": "Display version information, then exit.", "/versions/15/tables/0/rows/12/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "4f9bc608b5597fd5126f2bbbdc29a178f734c36a212c546df88658eb8427723d"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "f912a281dbc53bb5c56ffa693dfd803e6e1f643eb7d467ea448bc9f4cf3e087e", "manual_language": "zh"}, "16": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "16.15"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "13"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/16/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/16/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/16/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/16/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/16/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/16/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/16/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/16/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/16/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/16/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/16/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/16/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/16/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/16/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/16/postgresql-16-A4.pdf", "bytes": 15282337, "pages": 3055, "sha256": "4bb6c1f63deedac98736d8c4c7bc0fad0ac24e85b07e21ee10411872f06afd06", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/16/postgresql-16-US.pdf", "bytes": 15164148, "pages": 3220, "sha256": "5b6b6166c89991199e144bb0ae34c17a5f29826251dbf19db1abc0df3a3e771b", "built_at": "2026-09-26"}}, "tree": "16", "index": "index.html", "major": "16", "pages": 1169, "release": "16.15", "source_url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef", "evidence_kind": "English manual and source declarations", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "sources": [{"url": "https://pg.center/docs/16/app-pgrewind.html", "file": "app-pgrewind.html", "label": "16.15 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "947029346e76c330f2142fe2912ec7929bd4a0c5655eade70139d8398b055eda", "language": "en", "original_url": "/docs/16/app-pgrewind.html"}, {"url": "https://pg.center/docs/16/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "8aaa4422eece8f26d84715f855d9d0f7f87b200f8b82898c73c865ee42c2c70f", "language": "en", "original_url": "/docs/16/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.9.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/16/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\u3002\u8fd9\u4e24\u9879\u76ee\u524d\u9ed8\u8ba4\u90fd\u6ca1\u6709\u542f\u7528\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/16/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/16/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/16/libpq-envars.html\" title=\"34.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a034.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.9.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.9.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/16/app-pgrewind.html", "method": "same-major semantic node", "sha256": "a4287929147ae07d79da8523a89b42fe91117859d1310cfe371ba0558b867b2c", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/16/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/16/facts/0/label": "Documented executable", "/versions/16/facts/1/label": "Executable version", "/versions/16/facts/2/label": "Reference inventory", "/versions/16/facts/2/value": "Server applications", "/versions/16/facts/3/label": "Option definition groups", "/versions/16/tables/0/title": "Documented options", "/versions/16/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/16/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/16/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/16/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "/versions/16/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/16/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/16/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/16/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/16/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/16/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/16/tables/0/columns/0/label": "Option and arguments", "/versions/16/tables/0/columns/1/label": "Description", "/versions/16/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/16/tables/0/rows/11/summary": "Display version information, then exit.", "/versions/16/tables/0/rows/12/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "34867129935c85d2cdb850f2b901c15d3e754a5f1caf324a670c8b9874c81468"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "f912a281dbc53bb5c56ffa693dfd803e6e1f643eb7d467ea448bc9f4cf3e087e", "manual_language": "zh"}, "17": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "17.11"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u8bbe\u4e3a fsync \uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c pg_rewind \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/17/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/17/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/17/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/17/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/17/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/17/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/17/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/17/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/17/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/17/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/17/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/17/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "signature": "--sync-method= method", "source_url": "/docs/17/app-pgrewind.html", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/17/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/17/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/17/postgresql-17-A4.pdf", "bytes": 15521293, "pages": 3099, "sha256": "1991354df0dc89e70ec39328c28988ef8b19c6a93671dab3893650b63e9f4e36", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/17/postgresql-17-US.pdf", "bytes": 15398150, "pages": 3270, "sha256": "07696c8f38abf31babf22d2db337093936e7c472d2af36d050b000c49bbcf52c", "built_at": "2026-09-26"}}, "tree": "17", "index": "index.html", "major": "17", "pages": 1143, "release": "17.11", "source_url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487", "evidence_kind": "English manual and source declarations", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "sources": [{"url": "https://pg.center/docs/17/app-pgrewind.html", "file": "app-pgrewind.html", "label": "17.11 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "96988c7be34a3d3715b61d80b5421a3cb7d156bf4cf70f9590f4bf035adc64d1", "language": "en", "original_url": "/docs/17/app-pgrewind.html"}, {"url": "https://pg.center/docs/17/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "01f07993ff020684f4c290d17cdafa26fb17ea5c1d476bc3a5efc68bf8ddd9b9", "language": "en", "original_url": "/docs/17/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.10.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/17/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\u3002\u8fd9\u4e24\u9879\u76ee\u524d\u9ed8\u8ba4\u90fd\u6ca1\u6709\u542f\u7528\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/17/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/17/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u4e3a<code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528<code class=\"literal\">syncfs</code>\uff0c\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u6570\u636e\u76ee\u5f55\u3001WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u5173\u4e8e\u4f7f\u7528<code class=\"literal\">syncfs</code>\u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002</p>\n<p lang=\"zh\">\u4f7f\u7528<code class=\"option\">--no-sync</code>\u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/17/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a032.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.10.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/17/app-pgrewind.html", "method": "same-major semantic node", "sha256": "620a874c2f5947a63a29422e726cd62becc8c7f258fb49d9e544b9f30fc7ff18", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[0]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[2]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[27]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/17/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/17/facts/0/label": "Documented executable", "/versions/17/facts/1/label": "Executable version", "/versions/17/facts/2/label": "Reference inventory", "/versions/17/facts/2/value": "Server applications", "/versions/17/facts/3/label": "Option definition groups", "/versions/17/tables/0/title": "Documented options", "/versions/17/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/17/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/17/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/17/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.", "/versions/17/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/17/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/17/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/17/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/17/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/17/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/17/tables/0/columns/0/label": "Option and arguments", "/versions/17/tables/0/columns/1/label": "Description", "/versions/17/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/17/tables/0/rows/11/summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/17/tables/0/rows/12/summary": "Display version information, then exit.", "/versions/17/tables/0/rows/13/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "516e31506b646d9915d2fa41bcfbc9b3f2a5be9e9f53665ddc8952c194aad79d"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "f13b20dd32c6f912b385ec025e611a3df4c9b924fe06a2effd6ad38d0f13f295", "manual_language": "zh"}, "18": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "18.6"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u8bbe\u4e3a fsync \uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c pg_rewind \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/18/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/18/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/18/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/18/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/18/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/18/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/18/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/18/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/18/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/18/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/18/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "signature": "--sync-method= method", "source_url": "/docs/18/app-pgrewind.html", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "https://pg.center/docs/18/app-pgrewind.html", "file": "app-pgrewind.html", "label": "18.6 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "2d8a13348838dfc44e3733f7e269f3fb35643d705686198ab09cc5bada9a1330", "language": "en", "original_url": "/docs/18/app-pgrewind.html"}, {"url": "https://pg.center/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3", "language": "en", "original_url": "/docs/18/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.10.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u4e3a<code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528<code class=\"literal\">syncfs</code>\uff0c\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u6570\u636e\u76ee\u5f55\u3001WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u5173\u4e8e\u4f7f\u7528<code class=\"literal\">syncfs</code>\u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002</p>\n<p lang=\"zh\">\u4f7f\u7528<code class=\"option\">--no-sync</code>\u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a032.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.10.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/18/app-pgrewind.html", "method": "same-major semantic node", "sha256": "80e4a62370bb8e7376955de9521d97f4b77c20f596dac6030452334d02555985", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[0]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[2]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[27]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/18/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/18/facts/0/label": "Documented executable", "/versions/18/facts/1/label": "Executable version", "/versions/18/facts/2/label": "Reference inventory", "/versions/18/facts/2/value": "Server applications", "/versions/18/facts/3/label": "Option definition groups", "/versions/18/tables/0/title": "Documented options", "/versions/18/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/18/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/18/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/18/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "/versions/18/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/18/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/18/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/18/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/18/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/18/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/18/tables/0/columns/0/label": "Option and arguments", "/versions/18/tables/0/columns/1/label": "Description", "/versions/18/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/18/tables/0/rows/11/summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/18/tables/0/rows/12/summary": "Display version information, then exit.", "/versions/18/tables/0/rows/13/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "1f2989db941a42e32677e6718b242947808a615755fe16f895b69fa3c7456d83"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "65184284b9b782562c5b09cffbc1b933ebbf723a803dbe3a7320b5b328307823", "manual_language": "zh"}, "19": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "19beta4"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-D datadir --target-pgdata= datadir"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--source-pgdata= datadir"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u8bbe\u4e3a fsync \uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c pg_rewind \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/19/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D datadir", "--target-pgdata= datadir"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D datadir --target-pgdata= datadir", "source_url": "/docs/19/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= datadir"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= datadir", "source_url": "/docs/19/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/19/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/19/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/19/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/19/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/19/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/19/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/19/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/19/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/19/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "signature": "--sync-method= method", "source_url": "/docs/19/app-pgrewind.html", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/19/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/19/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/19/postgresql-19-A4.pdf", "bytes": 16064841, "pages": 3052, "sha256": "4dd099e4125c591128fc5f3ebd02178dc24781f9e5ae629f96d67c4c8547427b", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/19/postgresql-19-US.pdf", "bytes": 15974616, "pages": 3225, "sha256": "61971fa857f0956d47341a0388fa6af9ae10acf691d4b2fc009007d384b0342b", "built_at": "2026-09-26"}}, "tree": "19", "index": "index.html", "major": "19", "pages": 1155, "release": "19beta4", "source_url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "svg_assets": 5, "source_mode": "en SGML built with pinned official archive", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833", "evidence_kind": "English manual and source declarations", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "sources": [{"url": "https://pg.center/docs/19/app-pgrewind.html", "file": "app-pgrewind.html", "label": "19beta4 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "ca761d5bf03354c4f9acbd76e533a6d7a64e1cca918720496321f6c8bbd99fdc", "language": "en", "original_url": "/docs/19/app-pgrewind.html"}, {"url": "https://pg.center/docs/19/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "425b070323b448b5516d2cb4e9e4ac77efb5d19dd4e8005d0ae1c61db9ec78e6", "language": "en", "original_url": "/docs/19/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.10.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>datadir</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5728\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5206\u53c9\u70b9\u4e4b\u524d\u751f\u6210\u7684 WAL \u6bb5\u4e0d\u4f1a\u88ab\u590d\u5236\u3002\u5728\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5206\u53c9\u4e4b\u540e\u751f\u6210\u7684 WAL \u6bb5\u4f1a\u6574\u4f53\u590d\u5236\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002</p>\n</li>\n</ul>\n</div>\n<p lang=\"zh\">\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/19/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/19/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/19/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u4e3a<code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528<code class=\"literal\">syncfs</code>\uff0c\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u6570\u636e\u76ee\u5f55\u3001WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u5173\u4e8e\u4f7f\u7528<code class=\"literal\">syncfs</code>\u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002</p>\n<p lang=\"zh\">\u4f7f\u7528<code class=\"option\">--no-sync</code>\u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/19/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a032.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.10.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/19/app-pgrewind.html", "method": "same-major semantic node", "sha256": "b59b083a65281c73d8167bf3ecebe7bea6927002e635c5c7ed2b6f9e428ac5eb", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[0]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[1]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[2]", "#APP-PGREWIND/div[4]/div[8]/h3[0]", "#APP-PGREWIND/div[4]/div[8]/p[1]", "#APP-PGREWIND/div[4]/div[8]/p[2]", "#APP-PGREWIND/div[4]/div[8]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[4]/p[6]", "#APP-PGREWIND/div[4]/p[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[0]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[2]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[27]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/19/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/19/facts/0/label": "Documented executable", "/versions/19/facts/1/label": "Executable version", "/versions/19/facts/2/label": "Reference inventory", "/versions/19/facts/2/value": "Server applications", "/versions/19/facts/3/label": "Option definition groups", "/versions/19/tables/0/title": "Documented options", "/versions/19/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/19/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/19/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/19/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "/versions/19/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/19/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/19/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/19/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/19/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/19/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/19/tables/0/columns/0/label": "Option and arguments", "/versions/19/tables/0/columns/1/label": "Description", "/versions/19/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/19/tables/0/rows/11/summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/19/tables/0/rows/12/summary": "Display version information, then exit.", "/versions/19/tables/0/rows/13/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "0410282a9f58e1855b4b37977a55fdceb61fa9c7c2de4995ee814c08b55817bd"}, "comparison_data": {"options": [{"names": ["-D datadir", "--target-pgdata= datadir"], "signature": "-D datadir --target-pgdata= datadir", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= datadir"], "signature": "--source-pgdata= datadir", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "environment": []}, "comparison_hash": "d59f36cd646493e88683607ce3c98ba98a53b8f84a354a45ec215e8d5f78c8b7", "manual_language": "zh"}, "20": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "20devel"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-D datadir --target-pgdata= datadir"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--source-pgdata= datadir"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u8bbe\u4e3a fsync \uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c pg_rewind \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/devel/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D datadir", "--target-pgdata= datadir"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D datadir --target-pgdata= datadir", "source_url": "/docs/devel/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= datadir"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= datadir", "source_url": "/docs/devel/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/devel/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/devel/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/devel/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/devel/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/devel/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/devel/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/devel/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/devel/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/devel/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "signature": "--sync-method= method", "source_url": "/docs/devel/app-pgrewind.html", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/devel/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/devel/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/20/postgresql-20-A4.pdf", "bytes": 16030631, "pages": 3052, "sha256": "bd5d82c0ce38fc18f92a0447818a91a193a261776bca1c37564bf9a683e177d0", "built_at": "2026-09-28"}, "US": {"url": "/files/documentation/pdf/20/postgresql-20-US.pdf", "bytes": 15936613, "pages": 3223, "sha256": "d97d9e0db479a02f4234b175f50fcad70c3661619afc8d6df9b9437882e3c299", "built_at": "2026-09-28"}}, "tree": "0", "index": "index.html", "major": "20", "pages": 1156, "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "svg_assets": 6, "source_mode": "en SGML built with pinned official archive", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_snapshot_utc": "26-Sep-2026 20:22"}, "revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918", "evidence_kind": "English manual and source declarations", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, "sources": [{"url": "https://pg.center/docs/devel/app-pgrewind.html", "file": "app-pgrewind.html", "label": "20devel English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "8ed7c9616716f2d04d81b1459495c14ec047920831a073729fcdf1144cb6fdb9", "language": "en", "original_url": "/docs/devel/app-pgrewind.html"}, {"url": "https://pg.center/docs/devel/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "5532c1ebfb8c6f310301be63a28daf0ae212e2a78025bea61a1bdca99e02c43d", "language": "en", "original_url": "/docs/devel/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.10.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>datadir</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5728\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5206\u53c9\u70b9\u4e4b\u524d\u751f\u6210\u7684 WAL \u6bb5\u4e0d\u4f1a\u88ab\u590d\u5236\u3002\u5728\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5206\u53c9\u4e4b\u540e\u751f\u6210\u7684 WAL \u6bb5\u4f1a\u6574\u4f53\u590d\u5236\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002</p>\n</li>\n</ul>\n</div>\n<p lang=\"zh\">\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/devel/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/devel/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<p lang=\"zh\">\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u7684\u6570\u636e\u6821\u9a8c\u548c\u72b6\u6001\u5fc5\u987b\u517c\u5bb9\u3002\u5982\u679c\u4efb\u4e00\u670d\u52a1\u5668\u4e0a\u7684\u5728\u7ebf\u6821\u9a8c\u548c\u72b6\u6001\u8f6c\u6362\u88ab\u4e2d\u65ad\uff0c\u6216\u8005\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u6216\u5728\u5206\u53c9\u70b9\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff09\uff0c\u800c\u6e90\u670d\u52a1\u5668\u672a\u542f\u7528\uff0c<span class=\"application\">pg_rewind</span>\u90fd\u4f1a\u62d2\u7edd\u8fd0\u884c\uff1a\u56de\u5377\u540e\u7684\u670d\u52a1\u5668\u4f1a\u5728\u4ece\u6e90\u590d\u5236\u7684\u5757\u4e0a\u65e0\u6cd5\u901a\u8fc7\u6821\u9a8c\u548c\u9a8c\u8bc1\u3002\u76f8\u53cd\u7684\u7ec4\u5408\u5219\u5141\u8bb8\u4f7f\u7528\uff0c\u4f46\u4f1a\u53d1\u51fa\u8b66\u544a\uff1b\u9664\u975e\u6e90\u670d\u52a1\u5668\u5728\u5206\u53c9\u70b9\u4e4b\u540e\u5728\u7ebf\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff0c\u5426\u5219\u56de\u5377\u540e\u7684\u670d\u52a1\u5668\u4fdd\u6301\u6570\u636e\u6821\u9a8c\u548c\u7981\u7528\u3002\u6709\u5173\u5982\u4f55\u5728\u590d\u5236\u73af\u5883\u4e2d\u4e00\u81f4\u5730\u66f4\u6539\u72b6\u6001\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/devel/app-pgchecksums.html\" title=\"pg_checksums\"><span class=\"refentrytitle\"><span class=\"application\">pg_checksums</span></span></a>\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/devel/libpq-envars.html\" title=\"32.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u4e3a<code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528<code class=\"literal\">syncfs</code>\uff0c\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u6570\u636e\u76ee\u5f55\u3001WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u5173\u4e8e\u4f7f\u7528<code class=\"literal\">syncfs</code>\u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002</p>\n<p lang=\"zh\">\u4f7f\u7528<code class=\"option\">--no-sync</code>\u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/devel/libpq-envars.html\" title=\"32.14.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a032.14\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON FUNCTION pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.10.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/devel/app-pgrewind.html", "method": "same-major semantic node", "sha256": "6da193f12ade9c1a16eb05d4b0836afb8cccd42afa36d6e3a037d07eb323b450", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[0]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[1]", "#APP-PGREWIND/div[4]/div[3]/ul[0]/li[2]", "#APP-PGREWIND/div[4]/div[9]/h3[0]", "#APP-PGREWIND/div[4]/div[9]/p[1]", "#APP-PGREWIND/div[4]/div[9]/p[2]", "#APP-PGREWIND/div[4]/div[9]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[4]/p[6]", "#APP-PGREWIND/div[4]/p[7]", "#APP-PGREWIND/div[4]/p[8]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[0]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[2]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[27]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/summary": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/category": "Server applications", "/versions/20/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/20/facts/0/label": "Documented executable", "/versions/20/facts/1/label": "Executable version", "/versions/20/facts/2/label": "Reference inventory", "/versions/20/facts/2/value": "Server applications", "/versions/20/facts/3/label": "Option definition groups", "/versions/20/tables/0/title": "Documented options", "/versions/20/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/20/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/20/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/20/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "/versions/20/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/20/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/20/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/20/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/20/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/20/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/20/tables/0/columns/0/label": "Option and arguments", "/versions/20/tables/0/columns/1/label": "Description", "/versions/20/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/20/tables/0/rows/11/summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/20/tables/0/rows/12/summary": "Display version information, then exit.", "/versions/20/tables/0/rows/13/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "659f7da050d3cb93e1f8f765b30ef3d32b46ad0fa2511f2f1d770296eb69f44a"}, "comparison_data": {"options": [{"names": ["-D datadir", "--target-pgdata= datadir"], "signature": "-D datadir --target-pgdata= datadir", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= datadir"], "signature": "--source-pgdata= datadir", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "environment": []}, "comparison_hash": "d59f36cd646493e88683607ce3c98ba98a53b8f84a354a45ec215e8d5f78c8b7", "manual_language": "zh"}}}, "snapshot": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "18.6"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "tables": [{"key": "options", "rows": [{"summary": "\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c pg_rewind \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-D directory --target-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--source-pgdata= directory"}}, {"summary": "\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 PostgreSQL \u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c pg_rewind \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--source-server= connstr"}}, {"summary": "\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa standby.signal \uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 postgresql.auto.conf \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216 \u73af\u5883\u53d8\u91cf \u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a --source-server \u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-R --write-recovery-conf"}}, {"summary": "\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-n --dry-run"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_rewind \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f pg_rewind \u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-N --no-sync"}}, {"summary": "\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-P --progress"}}, {"summary": "\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-c --restore-target-wal"}}, {"summary": "\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--config-file= filename"}}, {"summary": "\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 pg_rewind \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--debug"}}, {"summary": "pg_rewind \u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c pg_rewind \u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c pg_rewind \u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--no-ensure-shutdown"}}, {"summary": "\u8bbe\u4e3a fsync \uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c pg_rewind \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002", "signature": {"url": "/docs/18/app-pgrewind.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}], "options": [{"names": ["-D directory", "--target-pgdata= directory"], "summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "signature": "-D directory --target-pgdata= directory", "source_url": "/docs/18/app-pgrewind.html", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "signature": "--source-pgdata= directory", "source_url": "/docs/18/app-pgrewind.html", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "signature": "--source-server= connstr", "source_url": "/docs/18/app-pgrewind.html", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "signature": "-R --write-recovery-conf", "source_url": "/docs/18/app-pgrewind.html", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "summary": "Do everything except actually modifying the target directory.", "signature": "-n --dry-run", "source_url": "/docs/18/app-pgrewind.html", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "signature": "-N --no-sync", "source_url": "/docs/18/app-pgrewind.html", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "signature": "-P --progress", "source_url": "/docs/18/app-pgrewind.html", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "signature": "-c --restore-target-wal", "source_url": "/docs/18/app-pgrewind.html", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "signature": "--config-file= filename", "source_url": "/docs/18/app-pgrewind.html", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "signature": "--debug", "source_url": "/docs/18/app-pgrewind.html", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "signature": "--no-ensure-shutdown", "source_url": "/docs/18/app-pgrewind.html", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "signature": "--sync-method= method", "source_url": "/docs/18/app-pgrewind.html", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "summary": "Display version information, then exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgrewind.html", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "summary": "Show help, then exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgrewind.html", "description": "Show help, then exit."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "https://pg.center/docs/18/app-pgrewind.html", "file": "app-pgrewind.html", "label": "18.6 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "2d8a13348838dfc44e3733f7e269f3fb35643d705686198ab09cc5bada9a1330", "language": "en", "original_url": "/docs/18/app-pgrewind.html"}, {"url": "https://pg.center/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3", "language": "en", "original_url": "/docs/18/reference-server.html"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "description": ["pg_rewind \u2014 \u5c06\u4e00\u4e2a PostgreSQL \u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGREWIND\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_rewind</span></span></h2>\n<p lang=\"zh\">pg_rewind \u2014 \u5c06\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u6570\u636e\u76ee\u5f55\u4e0e\u53e6\u4e00\u4e2a\u4ece\u5176\u5206\u53c9\u800c\u6765\u7684\u6570\u636e\u76ee\u5f55\u540c\u6b65</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.10.4.1\"><code class=\"command\">pg_rewind</code> [<em class=\"replaceable\"><code>option</code></em>...] { <code class=\"option\">-D</code> | <code class=\"option\">--target-pgdata</code> } <em class=\"replaceable\"><code>directory</code></em> { <code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code> | <code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code> }</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00<span class=\"productname\">PostgreSQL</span>\u96c6\u7c07\u7684\u4e24\u4efd\u526f\u672c\u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u540e\uff0c\u5c06\u5176\u4e2d\u4e00\u4efd\u91cd\u65b0\u540c\u6b65\u5230\u53e6\u4e00\u4efd\u3002\u5178\u578b\u573a\u666f\u662f\u6545\u969c\u5207\u6362\u540e\uff0c\u8ba9\u65e7\u4e3b\u5e93\u91cd\u65b0\u4e0a\u7ebf\uff0c\u4f5c\u4e3a\u8ddf\u968f\u65b0\u4e3b\u5e93\u7684\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u6210\u529f\u5b8c\u6210\u56de\u5377\u540e\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u7684\u72b6\u6001\u76f8\u5f53\u4e8e\u6e90\u6570\u636e\u76ee\u5f55\u7684\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u3002\u4e0e\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528<span class=\"application\">rsync</span>\u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span class=\"application\">pg_rewind</span>\u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\u3002\u5b83\u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\uff1b\u5176\u4f59\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001\u914d\u7f6e\u6587\u4ef6\u4ee5\u53ca WAL \u6bb5\uff0c\u90fd\u4f1a\u6574\u4f53\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5f53\u6570\u636e\u5e93\u89c4\u6a21\u5f88\u5927\u800c\u4e24\u4e2a\u96c6\u7c07\u4e4b\u95f4\u53ea\u6709\u5c11\u91cf\u5757\u4e0d\u540c\u65f6\uff0c\u56de\u5377\u64cd\u4f5c\u4f1a\u6bd4\u5176\u4ed6\u65b9\u6cd5\u5feb\u5f97\u591a\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u4f1a\u68c0\u67e5\u6e90\u96c6\u7c07\u548c\u76ee\u6807\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\uff0c\u4ee5\u786e\u5b9a\u5b83\u4eec\u53d1\u751f\u5206\u53c9\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8981\u6c42\u5728\u76ee\u6807\u96c6\u7c07\u7684<code class=\"filename\">pg_wal</code>\u76ee\u5f55\u4e2d\u80fd\u591f\u627e\u5230\u4e00\u76f4\u8ffd\u6eaf\u5230\u8be5\u5206\u53c9\u70b9\u7684 WAL\u3002\u5206\u53c9\u70b9\u53ef\u80fd\u4f4d\u4e8e\u76ee\u6807\u65f6\u95f4\u7ebf\u3001\u6e90\u65f6\u95f4\u7ebf\uff0c\u6216\u8005\u4e8c\u8005\u5171\u540c\u7684\u7956\u5148\u65f6\u95f4\u7ebf\u4e0a\u3002\u5728\u5178\u578b\u7684\u6545\u969c\u5207\u6362\u573a\u666f\u4e2d\uff0c\u76ee\u6807\u96c6\u7c07\u4f1a\u5728\u5206\u53c9\u540e\u4e0d\u4e45\u5173\u95ed\uff0c\u56e0\u6b64\u8fd9\u901a\u5e38\u4e0d\u662f\u95ee\u9898\uff1b\u4f46\u5982\u679c\u76ee\u6807\u96c6\u7c07\u5728\u5206\u53c9\u540e\u53c8\u8fd0\u884c\u4e86\u5f88\u957f\u65f6\u95f4\uff0c\u65e7\u7684 WAL \u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4e0d\u5b58\u5728\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u628a\u5b83\u4eec\u4ece WAL \u5f52\u6863\u590d\u5236\u5230<code class=\"filename\">pg_wal</code>\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code class=\"literal\">-c</code>\u9009\u9879\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span class=\"application\">pg_rewind</span>\u7684\u7528\u9014\u5e76\u4e0d\u9650\u4e8e\u6545\u969c\u5207\u6362\uff0c\u4f8b\u5982\uff0c\u5907\u5e93\u53ef\u4ee5\u88ab\u63d0\u5347\uff0c\u8fd0\u884c\u4e00\u4e9b\u5199\u4e8b\u52a1\uff0c\u7136\u540e\u518d\u56de\u5377\uff0c\u91cd\u65b0\u6210\u4e3a\u5907\u5e93\u3002</p>\n<p lang=\"zh\">\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5b8c\u6210 WAL \u91cd\u653e\uff0c\u6570\u636e\u76ee\u5f55\u624d\u80fd\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\u3002\u5f53\u518d\u6b21\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\uff0c\u5b83\u4f1a\u8fdb\u5165\u5f52\u6863\u6062\u590d\uff0c\u5e76\u91cd\u653e\u6e90\u670d\u52a1\u5668\u4e0a\u81ea\u5206\u53c9\u70b9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u4ee5\u6765\u751f\u6210\u7684\u5168\u90e8 WAL\u3002\u5982\u679c\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531<span class=\"application\">pg_rewind</span>\u4f1a\u8bdd\u590d\u5236\uff0c\u90a3\u4e48\u5728\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u65f6\u5fc5\u987b\u80fd\u591f\u83b7\u53d6\u8fd9\u4e9b WAL\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u76ee\u6807\u6570\u636e\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">recovery.signal</code>\u6587\u4ef6\uff0c\u5e76\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u914d\u7f6e\u5408\u9002\u7684<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a>\u6765\u5b9e\u73b0\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728<code class=\"filename\">postgresql.conf</code>\u4e2d\u542f\u7528\u4e86<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a>\u9009\u9879\uff0c\u8981\u4e48\u5728\u7528<span class=\"application\">initdb</span>\u521d\u59cb\u5316\u96c6\u7c07\u65f6\u542f\u7528\u4e86\u6570\u636e\u6821\u9a8c\u548c\uff08\u9ed8\u8ba4\u5373\u5982\u6b64\uff09\u3002\u6b64\u5916\uff0c<a class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a>\u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a<code class=\"literal\">on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\u5931\u8d25\uff0c\u76ee\u6807\u6570\u636e\u76ee\u5f55\u5f88\u53ef\u80fd\u5df2\u7ecf\u5904\u4e8e\u65e0\u6cd5\u6062\u590d\u7684\u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5efa\u8bae\u91cd\u65b0\u83b7\u53d6\u4e00\u4efd\u5168\u65b0\u7684\u5907\u4efd\u3002</p>\n<p lang=\"zh\">\u7531\u4e8e<span class=\"application\">pg_rewind</span>\u4f1a\u628a\u914d\u7f6e\u6587\u4ef6\u5b8c\u6574\u5730\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u56e0\u6b64\u5728\u91cd\u65b0\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6b63\u6062\u590d\u6240\u7528\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u5728\u5c06\u76ee\u6807\u91cd\u65b0\u5f15\u5165\u4e3a\u6e90\u7684\u5907\u5e93\u65f6\u3002\u5982\u679c\u56de\u5377\u64cd\u4f5c\u5b8c\u6210\u540e\u91cd\u542f\u670d\u52a1\u5668\uff0c\u5374\u6ca1\u6709\u914d\u7f6e\u6062\u590d\uff0c\u76ee\u6807\u53ef\u80fd\u4f1a\u518d\u6b21\u4e0e\u4e3b\u5e93\u5206\u53c9\u3002</p>\n<p lang=\"zh\">\u5982\u679c<span class=\"application\">pg_rewind</span>\u53d1\u73b0\u67d0\u4e9b\u6587\u4ef6\u65e0\u6cd5\u76f4\u63a5\u5199\u5165\uff0c\u5b83\u5c31\u4f1a\u7acb\u5373\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u5f53\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u5bf9\u53ea\u8bfb SSL \u5bc6\u94a5\u548c\u8bc1\u4e66\u4f7f\u7528\u76f8\u540c\u7684\u6587\u4ef6\u6620\u5c04\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5b58\u5728\u8fd9\u7c7b\u6587\u4ef6\uff0c\u5efa\u8bae\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\u5c06\u5176\u79fb\u9664\u3002\u56de\u5377\u5b8c\u6210\u540e\uff0c\u5176\u4e2d\u4e00\u4e9b\u6587\u4ef6\u53ef\u80fd\u5df2\u7ecf\u4ece\u6e90\u590d\u5236\u8fc7\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u80fd\u9700\u8981\u5220\u9664\u590d\u5236\u8fc7\u6765\u7684\u6570\u636e\uff0c\u5e76\u6062\u590d\u56de\u5377\u524d\u4f7f\u7528\u7684\u90a3\u7ec4\u94fe\u63a5\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_rewind</span>\u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c<span class=\"application\">pg_rewind</span>\u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u6e90\u670d\u52a1\u5668\u6570\u636e\u76ee\u5f55\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5c06\u76ee\u6807\u4e0e\u4e4b\u540c\u6b65\u3002\u8be5\u8fde\u63a5\u5fc5\u987b\u662f\u666e\u901a\u8fde\u63a5\uff08\u975e\u590d\u5236\u8fde\u63a5\uff09\uff0c\u6240\u7528\u89d2\u8272\u8981\u4e48\u62e5\u6709\u8db3\u591f\u7684\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u7684\u51fd\u6570\uff08\u8be6\u89c1\u6ce8\u89e3\u90e8\u5206\uff09\uff0c\u8981\u4e48\u662f\u8d85\u7ea7\u7528\u6237\u89d2\u8272\u3002\u6b64\u9009\u9879\u8981\u6c42\u6e90\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u63a5\u53d7\u8fde\u63a5\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa<code class=\"filename\">standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230<code class=\"filename\">postgresql.auto.conf</code>\u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a class=\"link\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u73af\u5883\u53d8\u91cf</a>\u4e2d\u663e\u5f0f\u6307\u5b9a\u4e86 dbname \u65f6\uff0c\u624d\u4f1a\u8bb0\u5f55 dbname\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a<code class=\"literal\">--source-server</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f<code class=\"command\">pg_rewind</code>\u4e0d\u7b49\u5f85\u5c31\u8fd4\u56de\uff0c\u8fd9\u6837\u867d\u7136\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u5982\u679c\u968f\u540e\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u5408\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8fdb\u5ea6\u62a5\u544a\u3002\u6253\u5f00\u8be5\u9009\u9879\u540e\uff0c\u5728\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u6570\u636e\u65f6\u4f1a\u7ed9\u51fa\u5927\u81f4\u7684\u8fdb\u5ea6\u4fe1\u606f\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5982\u679c WAL \u6587\u4ef6\u5728 pg_wal \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7fa4\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 restore_command \u4ece WAL \u5f52\u6863\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u6587\u4ef6\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u4e3a\u76ee\u6807\u96c6\u7fa4\u4f7f\u7528\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 pg_rewind \u4e3a\u56de\u9000\u64cd\u4f5c\u5728\u5185\u90e8\u8c03\u7528 postgres \u547d\u4ee4\u5904\u7406\u6b64\u96c6\u7fa4\u65f6\uff08\u5305\u62ec\u4f7f\u7528 -c/--restore-target-wal \u9009\u9879\u83b7\u53d6 restore_command\uff0c\u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff09\uff0c\u6b64\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u8fd9\u4e9b\u8c03\u7528\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5<span class=\"application\">pg_rewind</span>\u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p><span class=\"application\">pg_rewind</span>\u8981\u6c42\u5728\u56de\u5377\u524d\u76ee\u6807\u670d\u52a1\u5668\u5df2\u6b63\u5e38\u5173\u95ed\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u76ee\u6807\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u5148\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8\u76ee\u6807\u670d\u52a1\u5668\u4ee5\u5b8c\u6210\u5d29\u6e83\u6062\u590d\uff0c\u7136\u540e\u518d\u5c06\u5176\u505c\u6b62\u3002\u6307\u5b9a\u6b64\u9009\u9879\u540e\uff0c<span class=\"application\">pg_rewind</span>\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\uff1b\u5982\u679c\u670d\u52a1\u5668\u672a\u6b63\u5e38\u5173\u95ed\uff0c\u5b83\u4f1a\u7acb\u5373\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5e94\u81ea\u884c\u5904\u7406\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u4e3a<code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code class=\"command\">pg_rewind</code>\u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u641c\u7d22\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u53ca\u6bcf\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528<code class=\"literal\">syncfs</code>\uff0c\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u6570\u636e\u76ee\u5f55\u3001WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u5173\u4e8e\u4f7f\u7528<code class=\"literal\">syncfs</code>\u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1<a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002</p>\n<p lang=\"zh\">\u4f7f\u7528<code class=\"option\">--no-sync</code>\u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.7\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u5728\u4f7f\u7528<code class=\"option\">--source-server</code>\u9009\u9879\u65f6\uff0c<span class=\"application\">pg_rewind</span>\u4e5f\u4f1a\u4f7f\u7528<span class=\"application\">libpq</span>\u652f\u6301\u7684\u73af\u5883\u53d8\u91cf\uff08\u89c1<a class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0\u73af\u5883\u53d8\u91cf\">\u7b2c\u00a032.15\u00a0\u8282</a>\uff09\u3002</p>\n<p lang=\"zh\">\u73af\u5883\u53d8\u91cf<code class=\"envar\">PG_COLOR</code>\u6307\u5b9a\u662f\u5426\u5728\u8bca\u65ad\u6d88\u606f\u4e2d\u4f7f\u7528\u989c\u8272\u3002\u53ef\u80fd\u7684\u503c\u4e3a<code class=\"literal\">always</code>\u3001<code class=\"literal\">auto</code>\u548c<code class=\"literal\">never</code>\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.10.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\">\u5f53\u4f7f\u7528\u5728\u7ebf\u96c6\u7c07\u4f5c\u4e3a\u6e90\u6267\u884c<span class=\"application\">pg_rewind</span>\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5177\u5907\u8db3\u591f\u6743\u9650\u4ee5\u6267\u884c<span class=\"application\">pg_rewind</span>\u5728\u6e90\u96c6\u7c07\u4e0a\u6240\u7528\u51fd\u6570\u7684\u89d2\u8272\uff0c\u800c\u65e0\u9700\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u3002\u4e0b\u9762\u8bf4\u660e\u5982\u4f55\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u89d2\u8272\uff0c\u8fd9\u91cc\u5c06\u5176\u547d\u540d\u4e3a<code class=\"literal\">rewind_user</code>\uff1a</p>\n<pre class=\"programlisting\">CREATE USER rewind_user LOGIN;\nGRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;\nGRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;\n</pre>\n<div class=\"refsect2\" id=\"id-1.9.5.10.8.3\">\n<h3 lang=\"zh\">\u5de5\u4f5c\u539f\u7406</h3>\n<p lang=\"zh\">\u57fa\u672c\u601d\u8def\u662f\u5c06\u6e90\u96c6\u7c07\u4e2d\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u7684\u66f4\u6539\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p>\u4ece\u6e90\u96c6\u7c07\u7684\u65f6\u95f4\u7ebf\u5386\u53f2\u4e0e\u76ee\u6807\u96c6\u7c07\u5206\u53c9\u8fd9\u4e00\u70b9\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u5f00\u59cb\uff0c\u626b\u63cf\u76ee\u6807\u96c6\u7c07\u7684 WAL \u65e5\u5fd7\u3002\u5bf9\u4e8e\u6bcf\u6761 WAL \u8bb0\u5f55\uff0c\u8bb0\u5f55\u5b83\u6240\u89e6\u53ca\u7684\u6bcf\u4e2a\u6570\u636e\u5757\u3002\u8fd9\u6837\u5c31\u80fd\u5f97\u5230\u4e00\u4efd\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6e90\u96c6\u7c07\u5206\u53c9\u51fa\u53bb\u4e4b\u540e\uff0c\u76ee\u6807\u96c6\u7c07\u4e2d\u6240\u6709\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u6570\u636e\u5757\u3002\u5982\u679c\u67d0\u4e9b WAL \u6587\u4ef6\u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u8bf7\u5c1d\u8bd5\u4f7f\u7528<code class=\"option\">-c</code>\u9009\u9879\u91cd\u65b0\u8fd0\u884c<span class=\"application\">pg_rewind</span>\uff0c\u4ee5\u4fbf\u5728 WAL \u5f52\u6863\u4e2d\u67e5\u627e\u7f3a\u5931\u7684\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u8fd9\u4e9b\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u5757\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f4\u63a5\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\uff08<code class=\"option\">--source-pgdata</code>\uff09\u6216 SQL\uff08<code class=\"option\">--source-server</code>\uff09\u3002\u6b64\u65f6\uff0c\u5173\u7cfb\u6587\u4ef6\u7684\u72b6\u6001\u7b49\u4ef7\u4e8e\u6e90\u548c\u76ee\u6807\u7684 WAL \u65f6\u95f4\u7ebf\u53d1\u751f\u5206\u53c9\u4e4b\u524d\u6700\u540e\u4e00\u4e2a\u5df2\u5b8c\u6210\u68c0\u67e5\u70b9\u65f6\u7684\u72b6\u6001\uff0c\u518d\u52a0\u4e0a\u5206\u53c9\u4e4b\u540e\u76ee\u6807\u4e0a\u53d1\u751f\u8fc7\u66f4\u6539\u7684\u90a3\u4e9b\u5757\u5728\u6e90\u4e0a\u7684\u5f53\u524d\u72b6\u6001\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u5c06\u6240\u6709\u5176\u4ed6\u6587\u4ef6\uff0c\u5305\u62ec\u65b0\u7684\u5173\u7cfb\u6587\u4ef6\u3001WAL \u6bb5\u3001<code class=\"filename\">pg_xact</code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u5230\u76ee\u6807\u96c6\u7c07\u3002\u4e0e\u57fa\u7840\u5907\u4efd\u7c7b\u4f3c\uff0c\u76ee\u5f55<code class=\"filename\">pg_dynshmem/</code>\u3001<code class=\"filename\">pg_notify/</code>\u3001<code class=\"filename\">pg_replslot/</code>\u3001<code class=\"filename\">pg_serial/</code>\u3001<code class=\"filename\">pg_snapshots/</code>\u3001<code class=\"filename\">pg_stat_tmp/</code>\u548c<code class=\"filename\">pg_subtrans/</code>\u4e2d\u7684\u5185\u5bb9\u4e0d\u4f1a\u4ece\u6e90\u96c6\u7c07\u590d\u5236\u3002\u6587\u4ef6<code class=\"filename\">backup_label</code>\u3001<code class=\"filename\">tablespace_map</code>\u3001<code class=\"filename\">pg_internal.init</code>\u3001<code class=\"filename\">postmaster.opts</code>\u3001<code class=\"filename\">postmaster.pid</code>\u3001<code class=\"filename\">.DS_Store</code>\u4ee5\u53ca\u4efb\u4f55\u4ee5<code class=\"filename\">pgsql_tmp</code>\u5f00\u5934\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e5f\u90fd\u4f1a\u88ab\u7701\u7565\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u521b\u5efa\u4e00\u4e2a<code class=\"filename\">backup_label</code>\u6587\u4ef6\uff0c\u4f7f WAL \u91cd\u653e\u4ece\u6545\u969c\u5207\u6362\u65f6\u521b\u5efa\u7684\u68c0\u67e5\u70b9\u5f00\u59cb\uff1b\u540c\u65f6\u914d\u7f6e<code class=\"filename\">pg_control</code>\u6587\u4ef6\uff0c\u5c06\u6700\u5c0f\u4e00\u81f4\u6027 LSN \u8bbe\u5b9a\u4e3a\uff1a\u5982\u679c\u4ece\u8fd0\u884c\u4e2d\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528<code class=\"literal\">pg_current_wal_insert_lsn()</code>\u7684\u7ed3\u679c\uff1b\u5982\u679c\u4ece\u5df2\u505c\u6b62\u7684\u6e90\u6267\u884c\u56de\u5377\uff0c\u5219\u4f7f\u7528\u6700\u540e\u4e00\u4e2a\u68c0\u67e5\u70b9\u7684 LSN\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p>\u542f\u52a8\u76ee\u6807\u65f6\uff0c<span class=\"productname\">PostgreSQL</span>\u4f1a\u91cd\u653e\u6240\u6709\u5fc5\u9700\u7684 WAL\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u76ee\u5f55\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n</div></div>", "manual_path": "app-pgrewind.html", "localization": {"status": "complete", "sources": [{"url": "/docs/18/app-pgrewind.html", "method": "same-major semantic node", "sha256": "80e4a62370bb8e7376955de9521d97f4b77c20f596dac6030452334d02555985", "language": "zh", "matched_nodes": ["#APP-PGREWIND/div[2]/p[1]", "#APP-PGREWIND/div[3]/h2[0]", "#APP-PGREWIND/div[4]/div[6]/h3[0]", "#APP-PGREWIND/div[4]/div[6]/p[1]", "#APP-PGREWIND/div[4]/div[6]/p[2]", "#APP-PGREWIND/div[4]/div[6]/p[3]", "#APP-PGREWIND/div[4]/p[1]", "#APP-PGREWIND/div[4]/p[2]", "#APP-PGREWIND/div[4]/p[3]", "#APP-PGREWIND/div[4]/p[4]", "#APP-PGREWIND/div[4]/p[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[11]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[13]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[19]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[21]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[0]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[1]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[23]/p[2]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[25]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[27]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[3]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[5]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[7]", "#APP-PGREWIND/div[5]/div[2]/dl[0]/dd[9]", "#APP-PGREWIND/div[5]/p[1]", "#APP-PGREWIND/div[6]/h2[0]", "#APP-PGREWIND/div[6]/p[1]", "#APP-PGREWIND/div[6]/p[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[0]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[1]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[2]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[3]", "#APP-PGREWIND/div[7]/div[3]/div[2]/ol[0]/li[4]", "#APP-PGREWIND/div[7]/div[3]/h3[0]", "#APP-PGREWIND/div[7]/div[3]/p[1]", "#APP-PGREWIND/div[7]/h2[0]", "#APP-PGREWIND/div[7]/p[1]"]}], "language": "zh", "original_text": {"/versions/18/description/0": "pg_rewind \u2014 synchronize a PostgreSQL data directory with another data directory that was forked from it", "/versions/18/facts/0/label": "Documented executable", "/versions/18/facts/1/label": "Executable version", "/versions/18/facts/2/label": "Reference inventory", "/versions/18/facts/2/value": "Server applications", "/versions/18/facts/3/label": "Option definition groups", "/versions/18/tables/0/title": "Documented options", "/versions/18/tables/0/rows/0/summary": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind", "/versions/18/tables/0/rows/1/summary": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down.", "/versions/18/tables/0/rows/2/summary": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections.", "/versions/18/tables/0/rows/3/summary": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option.", "/versions/18/tables/0/rows/4/summary": "Do everything except actually modifying the target directory.", "/versions/18/tables/0/rows/5/summary": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.", "/versions/18/tables/0/rows/6/summary": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster.", "/versions/18/tables/0/rows/7/summary": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.", "/versions/18/tables/0/rows/8/summary": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery).", "/versions/18/tables/0/rows/9/summary": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind .", "/versions/18/tables/0/columns/0/label": "Option and arguments", "/versions/18/tables/0/columns/1/label": "Description", "/versions/18/tables/0/rows/10/summary": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.", "/versions/18/tables/0/rows/11/summary": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/18/tables/0/rows/12/summary": "Display version information, then exit.", "/versions/18/tables/0/rows/13/summary": "Show help, then exit."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "1f2989db941a42e32677e6718b242947808a615755fe16f895b69fa3c7456d83"}, "comparison_data": {"options": [{"names": ["-D directory", "--target-pgdata= directory"], "signature": "-D directory --target-pgdata= directory", "description": "This option specifies the target data directory that is synchronized with the source. The target server must be shut down cleanly before running pg_rewind"}, {"names": ["--source-pgdata= directory"], "signature": "--source-pgdata= directory", "description": "Specifies the file system path to the data directory of the source server to synchronize the target with. This option requires the source server to be cleanly shut down."}, {"names": ["--source-server= connstr"], "signature": "--source-server= connstr", "description": "Specifies a libpq connection string to connect to the source PostgreSQL server to synchronize the target with. The connection must be a normal (non-replication) connection with a role having sufficient permissions to execute the functions used by pg_rewind on the source server (see Notes section for details) or a superuser role. This option requires the source server to be running and accepting connections."}, {"names": ["-R", "--write-recovery-conf"], "signature": "-R --write-recovery-conf", "description": "Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable . --source-server is mandatory with this option."}, {"names": ["-n", "--dry-run"], "signature": "-n --dry-run", "description": "Do everything except actually modifying the target directory."}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation."}, {"names": ["-P", "--progress"], "signature": "-P --progress", "description": "Enables progress reporting. Turning this on will deliver an approximate progress report while copying data from the source cluster."}, {"names": ["-c", "--restore-target-wal"], "signature": "-c --restore-target-wal", "description": "Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory."}, {"names": ["--config-file= filename"], "signature": "--config-file= filename", "description": "Use the specified main server configuration file for the target cluster. This affects pg_rewind when it uses internally the postgres command for the rewind operation on this cluster (when retrieving restore_command with the option -c/--restore-target-wal and when forcing a completion of crash recovery)."}, {"names": ["--debug"], "signature": "--debug", "description": "Print verbose debugging output that is mostly useful for developers debugging pg_rewind ."}, {"names": ["--no-ensure-shutdown"], "signature": "--no-ensure-shutdown", "description": "pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_rewind will recursively open and synchronize all files in the data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Display version information, then exit."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help, then exit."}], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "environment": []}, "comparison_hash": "65184284b9b782562c5b09cffbc1b933ebbf723a803dbe3a7320b5b328307823", "manual_language": "zh"}, "comparison": {"left": "12", "right": "13", "status": "changed", "diff": "--- PostgreSQL 12\n+++ PostgreSQL 13\n@@ -24,6 +24,14 @@\n       \"signature\": \"--source-server= connstr\"\n     },\n     {\n+      \"description\": \"Create standby.signal and append connection settings to postgresql.auto.conf in the output directory. --source-server is mandatory with this option.\",\n+      \"names\": [\n+        \"-R\",\n+        \"--write-recovery-conf\"\n+      ],\n+      \"signature\": \"-R --write-recovery-conf\"\n+    },\n+    {\n       \"description\": \"Do everything except actually modifying the target directory.\",\n       \"names\": [\n         \"-n\",\n@@ -32,7 +40,7 @@\n       \"signature\": \"-n --dry-run\"\n     },\n     {\n-      \"description\": \"By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.\",\n+      \"description\": \"By default, pg_rewind will wait for all files to be written safely to disk. This option causes pg_rewind to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation.\",\n       \"names\": [\n         \"-N\",\n         \"--no-sync\"\n@@ -48,11 +56,26 @@\n       \"signature\": \"-P --progress\"\n     },\n     {\n+      \"description\": \"Use restore_command defined in the target cluster configuration to retrieve WAL files from the WAL archive if these files are no longer available in the pg_wal directory.\",\n+      \"names\": [\n+        \"-c\",\n+        \"--restore-target-wal\"\n+      ],\n+      \"signature\": \"-c --restore-target-wal\"\n+    },\n+    {\n       \"description\": \"Print verbose debugging output that is mostly useful for developers debugging pg_rewind .\",\n       \"names\": [\n         \"--debug\"\n       ],\n       \"signature\": \"--debug\"\n+    },\n+    {\n+      \"description\": \"pg_rewind requires that the target server is cleanly shut down before rewinding. By default, if the target server is not shut down cleanly, pg_rewind starts the target server in single-user mode to complete crash recovery first, and stops it. By passing this option, pg_rewind skips this and errors out immediately if the server is not cleanly shut down. Users are expected to handle the situation themselves in that case.\",\n+      \"names\": [\n+        \"--no-ensure-shutdown\"\n+      ],\n+      \"signature\": \"--no-ensure-shutdown\"\n     },\n     {\n       \"description\": \"Display version information, then exit.\","}}