{"kind": "tool", "major": "18", "item": {"slug": "pg-rewind", "name": "pg_rewind", "name_zh": "", "category": "\u670d\u52a1\u7aef\u7a0b\u5e8f", "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "aliases": ["pg_rewind"], "content_hash": "6c464525a01b2113ebd67861c71f4b5bad5e23017c77e54f7bf76d38fd88e08f", "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": "/docs/10/app-pgrewind.html", "file": "app-pgrewind.html", "label": "10.23 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "c4cd0b0186e43941690458e578d637cd6be90805bfe55db4b07ed509c6ff7a28"}, {"url": "/docs/10/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "2a6043b88501763a31348758a370a42cd7f9a179c7fdf3ef0e353c82e95b33e9"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/10/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "10", "build_id": 63, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "892e0f4bcf77b73ebad6a171e5558cd42fd078350c6437e058f78996442b9699", "fragment_sha256": "79e4d0843eb855b4dc3b8712af0756abc2a7e597c18c564b8d948042af7377b5", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:62997ea80516ad012fbf6359de33f3b016b54c47e2df76e75606116b4baaf8e5", "translated_from_revision": null}, "body_sha256": "4d0dcd0699fc45177af9479207463a36f6c48ab9c88c54c2feb014b9035b17ba", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "10", "text_hash": "83902c196cf7d96e5572bbae193a790fdd08abad977e67e550a42236cb08476e", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/10/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "10", "build_id": 63, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "892e0f4bcf77b73ebad6a171e5558cd42fd078350c6437e058f78996442b9699", "fragment_sha256": "79e4d0843eb855b4dc3b8712af0756abc2a7e597c18c564b8d948042af7377b5", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:62997ea80516ad012fbf6359de33f3b016b54c47e2df76e75606116b4baaf8e5", "translated_from_revision": null}, "body_sha256": "4d0dcd0699fc45177af9479207463a36f6c48ab9c88c54c2feb014b9035b17ba", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p> <span class=\"application\">pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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><p> <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\n  </p><p>\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><p> <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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>    \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\n   </p><p>    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p> <span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt><dd><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></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt><dd><p>        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt><dd><p>        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt><dd><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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/10/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "version": "10", "link_map": {"/zh/docs/10/app-pgrewind.html": "/docs/10/app-pgrewind.html", "/zh/docs/10/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/10/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/10/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/10/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p> <span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p> <span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.conf</code> \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 <code>restore_command</code> \u6765\u5b9e\u73b0\u3002</p><p> <span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/10/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/10/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>    \u5982\u679c <span>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\n   </p><p>    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p> <span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/10/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "0f6c42e2dfa9d81192d70513214ce23b8e3237cbc9a6f54b1d0ba14a34afb758", "content_hash": "83902c196cf7d96e5572bbae193a790fdd08abad977e67e550a42236cb08476e", "source_database": "center", "source_revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "83902c196cf7d96e5572bbae193a790fdd08abad977e67e550a42236cb08476e"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p> <span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p> <span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.conf</code> \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 <code>restore_command</code> \u6765\u5b9e\u73b0\u3002</p><p> <span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/10/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/10/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>    \u5982\u679c <span>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\n   </p><p>    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p> <span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/10/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/11/app-pgrewind.html", "file": "app-pgrewind.html", "label": "11.22 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "59e6b61d8848111c710f8973305e3a2b04482bc683f1196d1b91c3bc12671f60"}, {"url": "/docs/11/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e940a8505b6742c717a1683d19bf8f759aad245633a59db9e83a345ae7c5709a"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/11/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "11", "build_id": 64, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "4e441e7aa2ea5eaf74b001fe6027c730414f4618a155df6a007a8a870b9a99e1", "fragment_sha256": "d4912519f8beece1b84a767b951c472003cad6be0bf5f7761378027c4849d004", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:ef5c7bc074acae9795db16e6b7482aea3b222bd4bcce0f76831332b97a21e8a1", "translated_from_revision": null}, "body_sha256": "be25a0557dca937f8586b000f824ca7e1dbc3d4958da0b5686e0107cb487c24a", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "11", "text_hash": "3923560593e1ad236ce01b62f363f079e367d97ce667824379010f2a07a1b3ca", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/11/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "11", "build_id": 64, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "4e441e7aa2ea5eaf74b001fe6027c730414f4618a155df6a007a8a870b9a99e1", "fragment_sha256": "d4912519f8beece1b84a767b951c472003cad6be0bf5f7761378027c4849d004", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:ef5c7bc074acae9795db16e6b7482aea3b222bd4bcce0f76831332b97a21e8a1", "translated_from_revision": null}, "body_sha256": "be25a0557dca937f8586b000f824ca7e1dbc3d4958da0b5686e0107cb487c24a", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<span class=\"application\">pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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><p>\n<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\n  </p><p>\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><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/11/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "version": "11", "link_map": {"/zh/docs/11/app-pgrewind.html": "/docs/11/app-pgrewind.html", "/zh/docs/11/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/11/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/11/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/11/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.conf</code> \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 <code>restore_command</code> \u6765\u5b9e\u73b0\u3002</p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/11/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/11/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/11/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "df430723fb2d65837107a27a23702c27dc4d50fdf5292562fc6ee5db37525508", "content_hash": "3923560593e1ad236ce01b62f363f079e367d97ce667824379010f2a07a1b3ca", "source_database": "center", "source_revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "3923560593e1ad236ce01b62f363f079e367d97ce667824379010f2a07a1b3ca"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.conf \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 \u8b66\u544a \u5982\u679c pg_rewind \u5728\u5904\u7406\u8fc7\u7a0b", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.conf</code> \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8bbe\u7f6e\u5408\u9002\u7684 <code>restore_command</code> \u6765\u5b9e\u73b0\u3002</p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/11/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/11/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/11/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/12/app-pgrewind.html", "file": "app-pgrewind.html", "label": "12.22 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "9c37a508ca2d478d748aebf470365424f39abcc001aee5dfb3bacd16edab5719"}, {"url": "/docs/12/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "7f6ae1fadc1b0bffa606551460e62aacdc2508a3fb66566ddae861928ca6080b"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/12/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "12", "build_id": 65, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "1266bbd31c3b31e640f3dcfff584845d785488e13708393dc02393a1639237a5", "fragment_sha256": "4b60a5e765c10b69ca0fdda56a2e49407e10738bd0af6ba76991ca4e82d365bc", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:86d2ff781f93e1de17122ebc514d5e64fcb63fed15941f496d7e146c6dcc7a49", "translated_from_revision": null}, "body_sha256": "e6d2c13f12fd042eeddf6998b50a1377304a7c6a891d8a20a1934574044de5ba", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "12", "text_hash": "57c47ac390380291fd807983cec30a06b73cdf33235458eb527719cd826a38f4", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/12/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "12", "build_id": 65, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "1266bbd31c3b31e640f3dcfff584845d785488e13708393dc02393a1639237a5", "fragment_sha256": "4b60a5e765c10b69ca0fdda56a2e49407e10738bd0af6ba76991ca4e82d365bc", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:86d2ff781f93e1de17122ebc514d5e64fcb63fed15941f496d7e146c6dcc7a49", "translated_from_revision": null}, "body_sha256": "e6d2c13f12fd042eeddf6998b50a1377304a7c6a891d8a20a1934574044de5ba", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 restore_command \uff08\u4f4d\u4e8e postgresql.conf \u4e2d\uff09\u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 ", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<span class=\"application\">pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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><p>\n<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\n  </p><p>\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=\"/zh/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><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/12/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 restore_command \uff08\u4f4d\u4e8e postgresql.conf \u4e2d\uff09\u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 ", "version": "12", "link_map": {"/zh/docs/12/app-pgrewind.html": "/docs/12/app-pgrewind.html", "/zh/docs/12/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/12/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/12/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/12/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/12/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/12/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/12/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a>\uff08\u4f4d\u4e8e <code>postgresql.conf</code> \u4e2d\uff09\u6765\u5b9e\u73b0\u3002</p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/12/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/12/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span></dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/12/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "34ea69523e3a119d0600e8ad2b693bdcfa2df41df7816f58397fede1532a11cb", "content_hash": "57c47ac390380291fd807983cec30a06b73cdf33235458eb527719cd826a38f4", "source_database": "center", "source_revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 restore_command \uff08\u4f4d\u4e8e postgresql.conf \u4e2d\uff09\u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 "], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "57c47ac390380291fd807983cec30a06b73cdf33235458eb527719cd826a38f4"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 pg_rewind \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 rsync \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 restore_command \uff08\u4f4d\u4e8e postgresql.conf \u4e2d\uff09\u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 postgresql.conf \u4e2d\u542f\u7528\u4e86 wal_log_hints \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 initdb \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 full_page_writes \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a on \uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002 ", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\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>pg_rewind</span> \u76f8\u8f83\u4e8e\u83b7\u53d6\u65b0\u7684\u57fa\u7840\u5907\u4efd\u6216\u4f7f\u7528 <span>rsync</span> \u7b49\u5de5\u5177\uff0c\u5176\u4f18\u52bf\u5728\u4e8e <span>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><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\u3002<span>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\n  </p><p>\u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/12/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a>\uff08\u4f4d\u4e8e <code>postgresql.conf</code> \u4e2d\uff09\u6765\u5b9e\u73b0\u3002</p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/12/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/12/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span></dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/12/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/13/app-pgrewind.html", "file": "app-pgrewind.html", "label": "13.23 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "872413952b6c6f71ae9e8800961efa72be6e04c03cd117e301ebf4ac38a48d4e"}, {"url": "/docs/13/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "074ef8577fd368272a2360309e1226e2d0b1e570a3e1da62dfcca63ac9ee5539"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/13/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "13", "build_id": 66, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "db2d0c111441d1a751f82f57e830d0bb83c47b2388db74e917de3fdfb9681842", "fragment_sha256": "f14f4bcdc51c60a274743cb6470c7bf4f301fa5803407468a9e613e31d5bad55", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:a13a825c39f0268ef1cfe9137e283e38d0da73b2d7894f0733c7b26372a4f6a4", "translated_from_revision": null}, "body_sha256": "4aae9c6ec21679c45e2f52b55e67a5d2e098142502485ad98b1905e4c445fb31", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "13", "text_hash": "b9256d5dca2c188dbdd21f9dd129ebdd534e369e098b4e74e4296fe506a97d57", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/13/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "13", "build_id": 66, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "db2d0c111441d1a751f82f57e830d0bb83c47b2388db74e917de3fdfb9681842", "fragment_sha256": "f14f4bcdc51c60a274743cb6470c7bf4f301fa5803407468a9e613e31d5bad55", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "snapshot:sha256:a13a825c39f0268ef1cfe9137e283e38d0da73b2d7894f0733c7b26372a4f6a4", "translated_from_revision": null}, "body_sha256": "4aae9c6ec21679c45e2f52b55e67a5d2e098142502485ad98b1905e4c445fb31", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<span class=\"application\">pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span></dt><dd><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></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span></dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span></dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/13/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "13", "link_map": {"/zh/docs/13/app-pgrewind.html": "/docs/13/app-pgrewind.html", "/zh/docs/13/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/13/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/13/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/13/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/13/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/13/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span></dt><dd><p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a <code>--source-server</code>\u3002</p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span></dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span></dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span></dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/13/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "a1ac515f176c9638d3edbb8e7502f6e504f6468c65d7f3d0a78d2b58d6a030c6", "content_hash": "b9256d5dca2c188dbdd21f9dd129ebdd534e369e098b4e74e4296fe506a97d57", "source_database": "center", "source_revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "b9256d5dca2c188dbdd21f9dd129ebdd534e369e098b4e74e4296fe506a97d57"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/13/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/13/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/13/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span></dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span></dt><dd><p>\u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5fc5\u987b\u6307\u5b9a <code>--source-server</code>\u3002</p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span></dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span></dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span></dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span></dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--debug</code></span></dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span></dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span></dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span></dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/13/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/14/app-pgrewind.html", "file": "app-pgrewind.html", "label": "14.24 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "c39a3345fa1f6830b9fca6b7369a8b8331483b00bdd5999b180e0b492bf83b48"}, {"url": "/docs/14/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "db0cdccaa8d3c65ad3b2a07d4956eb5a783a18505bfa0f9d9626eef4ab94fe44"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/14/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "14", "build_id": 99, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "27ae392c728122d35e105a2221ac5b3aaf30b1fc9ba5ee7903ad7855a5365051", "fragment_sha256": "db5b4d670566ffcbcb758821091e596574aa2d3ba4cc5dc7588708ff77fc6da5", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:87e6aa4fd6e1ec85c5f4a6de4f5647cfd9e5de734ca2c266d32b6d6192c662ef", "translated_from_revision": null}, "body_sha256": "abc336ef68f84b2e430c720c2a4994f04210c398e8d605ce0df4782b35629568", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "14", "text_hash": "2d716104fbef45fd36ba14a4ededdc12e030f4547d2441096adf8c08d94dc3cc", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/14/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "14", "build_id": 99, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "27ae392c728122d35e105a2221ac5b3aaf30b1fc9ba5ee7903ad7855a5365051", "fragment_sha256": "db5b4d670566ffcbcb758821091e596574aa2d3ba4cc5dc7588708ff77fc6da5", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:87e6aa4fd6e1ec85c5f4a6de4f5647cfd9e5de734ca2c266d32b6d6192c662ef", "translated_from_revision": null}, "body_sha256": "abc336ef68f84b2e430c720c2a4994f04210c398e8d605ce0df4782b35629568", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/14/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/14/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "14", "link_map": {"/zh/docs/14/app-pgrewind.html": "/docs/14/app-pgrewind.html", "/zh/docs/14/libpq-envars.html": "/docs/14/libpq-envars.html", "/zh/docs/14/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/14/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/14/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/14/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/14/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/14/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/14/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/14/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "c6ebc48ed89a92d57546864ec2681e2be9d0e9c3dddb418bc9ba0c456ccd454c", "content_hash": "2d716104fbef45fd36ba14a4ededdc12e030f4547d2441096adf8c08d94dc3cc", "source_database": "center", "source_revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "2d716104fbef45fd36ba14a4ededdc12e030f4547d2441096adf8c08d94dc3cc"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/14/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/14/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/14/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/14/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/14/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/15/app-pgrewind.html", "file": "app-pgrewind.html", "label": "15.19 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "dda1f5f230ff9ad8bb72961bcf86367ce739afb3b91c5f62d5b349867a43e7ab"}, {"url": "/docs/15/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1240cfbb13ebfd22aac8d5ae40c62a9015b246f7774bcf0bce97355ce06350a0"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/15/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "15", "build_id": 101, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "2c6faa4476d92d7fe6e66a44e5a9b7190ed94e1b81f2d7930b212b079e61f3bf", "fragment_sha256": "dbb8c720e2bc72217e95baa9779c2a7b321df1cc6d92c1deaaf64c2ab9a2b9ad", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:6bce1a2df9170cb1146a1411c5547190856638221a6539e618ee1016c9f493ad", "translated_from_revision": null}, "body_sha256": "a3e69be7e3596647229baf07be4606a990c189fcb9b539cad9d94b6192d37820", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "15", "text_hash": "269c5afc869e1be8e60b87342969d702666c86de911315388247d4820d96993a", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/15/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "15", "build_id": 101, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "2c6faa4476d92d7fe6e66a44e5a9b7190ed94e1b81f2d7930b212b079e61f3bf", "fragment_sha256": "dbb8c720e2bc72217e95baa9779c2a7b321df1cc6d92c1deaaf64c2ab9a2b9ad", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:6bce1a2df9170cb1146a1411c5547190856638221a6539e618ee1016c9f493ad", "translated_from_revision": null}, "body_sha256": "a3e69be7e3596647229baf07be4606a990c189fcb9b539cad9d94b6192d37820", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/15/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/15/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "15", "link_map": {"/zh/docs/15/app-pgrewind.html": "/docs/15/app-pgrewind.html", "/zh/docs/15/libpq-envars.html": "/docs/15/libpq-envars.html", "/zh/docs/15/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/15/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/15/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/15/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/15/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/15/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/15/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/15/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "d8f068a6c28bba12f131546b6390b01cede6cde36ba35a354dc6e931c7eb7b2e", "content_hash": "269c5afc869e1be8e60b87342969d702666c86de911315388247d4820d96993a", "source_database": "center", "source_revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "269c5afc869e1be8e60b87342969d702666c86de911315388247d4820d96993a"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/15/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/15/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/15/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/15/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/15/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/16/app-pgrewind.html", "file": "app-pgrewind.html", "label": "16.15 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "947029346e76c330f2142fe2912ec7929bd4a0c5655eade70139d8398b055eda"}, {"url": "/docs/16/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "8aaa4422eece8f26d84715f855d9d0f7f87b200f8b82898c73c865ee42c2c70f"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/16/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "16", "build_id": 103, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "14c5903d03fd7bb6bef70411e6ae0dc6e7f73fc7212f8761029fcc6e0f062aa8", "fragment_sha256": "ecc0a10eba444529b2d561f17ed6ba12ef0ca18d8e581d2ec4e632aab766af25", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:80579a071736780f9c4022bb5148e1fb1256f1a33591306af67816e9e9bf3a9b", "translated_from_revision": null}, "body_sha256": "7e16221a2a88431fff89f17eb478ae65f8dbf8012519c2ee0e36fe194ffd47a7", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "16", "text_hash": "4f9c5fea3c61e90f910775341bb58ef437d26cc0cc5b52d180b919d8a66580fb", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/16/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "16", "build_id": 103, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "14c5903d03fd7bb6bef70411e6ae0dc6e7f73fc7212f8761029fcc6e0f062aa8", "fragment_sha256": "ecc0a10eba444529b2d561f17ed6ba12ef0ca18d8e581d2ec4e632aab766af25", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:80579a071736780f9c4022bb5148e1fb1256f1a33591306af67816e9e9bf3a9b", "translated_from_revision": null}, "body_sha256": "7e16221a2a88431fff89f17eb478ae65f8dbf8012519c2ee0e36fe194ffd47a7", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/16/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/16/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "16", "link_map": {"/zh/docs/16/app-pgrewind.html": "/docs/16/app-pgrewind.html", "/zh/docs/16/libpq-envars.html": "/docs/16/libpq-envars.html", "/zh/docs/16/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/16/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/16/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/16/runtime-config-wal.html#GUC-FULL-PAGE-WRITES"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/16/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/16/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/16/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/16/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "b182b6a15b2bc09881631b2c1a37af30f7eb5ba40c38fcb238edff923e1c2d1e", "content_hash": "4f9c5fea3c61e90f910775341bb58ef437d26cc0cc5b52d180b919d8a66580fb", "source_database": "center", "source_revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "4f9c5fea3c61e90f910775341bb58ef437d26cc0cc5b52d180b919d8a66580fb"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/16/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/16/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/16/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/16/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/16/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/17/app-pgrewind.html", "file": "app-pgrewind.html", "label": "17.11 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "96988c7be34a3d3715b61d80b5421a3cb7d156bf4cf70f9590f4bf035adc64d1"}, {"url": "/docs/17/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "01f07993ff020684f4c290d17cdafa26fb17ea5c1d476bc3a5efc68bf8ddd9b9"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/17/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "17", "build_id": 105, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "074832d1edf539c382f85c13d1d917d5cc294463a14b3b063562c46c24508218", "fragment_sha256": "460d4e0c2e0504629ef9b6739bead3c9f043e6be4030a10b5a00c764dd7fef66", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:7340767258d21c21b36f373f1fff6bab2be18e0daca13a865129db6105c09efd", "translated_from_revision": null}, "body_sha256": "b0c8ed0fe5135458a4e820cf1fa680a5f3be34dc69ae312056a4712a4831a3af", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "17", "text_hash": "b092d80258dba2019cb3c6cbf45489e13eb273acf3708e39405ebe50d38d2d40", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/17/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "17", "build_id": 105, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "074832d1edf539c382f85c13d1d917d5cc294463a14b3b063562c46c24508218", "fragment_sha256": "460d4e0c2e0504629ef9b6739bead3c9f043e6be4030a10b5a00c764dd7fef66", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:7340767258d21c21b36f373f1fff6bab2be18e0daca13a865129db6105c09efd", "translated_from_revision": null}, "body_sha256": "b0c8ed0fe5135458a4e820cf1fa680a5f3be34dc69ae312056a4712a4831a3af", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/17/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span> </dt><dd><p>\n        \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\n       </p><p>\n        \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=\"/zh/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/17/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "17", "link_map": {"/zh/docs/17/app-pgrewind.html": "/docs/17/app-pgrewind.html", "/zh/docs/17/libpq-envars.html": "/docs/17/libpq-envars.html", "/zh/docs/17/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/17/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/17/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/17/runtime-config-wal.html#GUC-FULL-PAGE-WRITES", "/zh/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD": "/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/17/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/17/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/17/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/17/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "513319fc6872fe6814c130e8e70b64d49b749713cb77d578db49e5ec95a82611", "content_hash": "b092d80258dba2019cb3c6cbf45489e13eb273acf3708e39405ebe50d38d2d40", "source_database": "center", "source_revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "b092d80258dba2019cb3c6cbf45489e13eb273acf3708e39405ebe50d38d2d40"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/17/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/17/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/17/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/17/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/17/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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": "/docs/18/app-pgrewind.html", "file": "app-pgrewind.html", "label": "18.6 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "2d8a13348838dfc44e3733f7e269f3fb35643d705686198ab09cc5bada9a1330"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/18/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "18", "build_id": 107, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "e288a54ad498f84bbe1f99eb62471662046113c78137cae1b61a420dd01270d2", "fragment_sha256": "c86e366667480ddad966c6cd4ca22e136328b2791ff435ba18eef799171a79c3", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b", "translated_from_revision": null}, "body_sha256": "1e127cea56ecf75988cff3034040de3f78d10025691eb6fe45be940b99736679", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "18", "text_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/18/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "18", "build_id": 107, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "e288a54ad498f84bbe1f99eb62471662046113c78137cae1b61a420dd01270d2", "fragment_sha256": "c86e366667480ddad966c6cd4ca22e136328b2791ff435ba18eef799171a79c3", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b", "translated_from_revision": null}, "body_sha256": "1e127cea56ecf75988cff3034040de3f78d10025691eb6fe45be940b99736679", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/18/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span> </dt><dd><p>\n        \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\n       </p><p>\n        \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=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "18", "link_map": {"/zh/docs/18/app-pgrewind.html": "/docs/18/app-pgrewind.html", "/zh/docs/18/libpq-envars.html": "/docs/18/libpq-envars.html", "/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES", "/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD": "/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/18/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "21697e94251db32e3fa5189670146b9a4c61572df204bb5e69a1589ab65f9582", "content_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096", "source_database": "center", "source_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/18/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "center_zh_rendered": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/docs/18/libpq-envars.html\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/docs/18/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "19": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "19rc1"}, {"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/v19rc1/postgresql-19rc1.tar.bz2", "label": "19rc1", "major": "19", "channel": "preview", "manifest": {"major": "19", "release": "19rc1", "source_url": "https://ftp.postgresql.org/pub/source/v19rc1/postgresql-19rc1.tar.bz2", "source_sha256": "af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701"}, "revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008", "evidence_kind": "English manual and source declarations", "source_sha256": "af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701"}, "sources": [{"url": "/docs/19/app-pgrewind.html", "file": "app-pgrewind.html", "label": "19rc1 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "cb2bed3369b5551258367eb22cf205c3658a6940f495f3da4716a4f4980dc85d"}, {"url": "/docs/19/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "3670173acada00f2cee0b0622a4ad231d7e5fa583f81d5d5b96cd17069e1dd9b"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/19/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "19", "build_id": 109, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "d7eebdcdc521e760997551aef995ad2599aae5efd0ea57848384d116cd043595", "fragment_sha256": "23836ab62c3001a40e48260dc237fd9fa54ffbf41e22c3ab5eab14e0ac18b281", "source_revision": "sha256:af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:65fda1f1b62a89992b84014c9157e61b67dbe8190e93945826efec668fad038c", "translated_from_revision": "sha256:af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701"}, "body_sha256": "93f769f8532078084222163ef5d60249520184b322a11707ae16727e50dd1d78", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008"}, "facts_zh": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "19rc1"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "14"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "19", "text_hash": "bdd0af81282a42ba3de3ee47d91b2302025b59ebf18644bea2cb366aa0b99369", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008"}, "payload": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_rewind"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "19rc1"}, {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/19/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "19", "build_id": 109, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "d7eebdcdc521e760997551aef995ad2599aae5efd0ea57848384d116cd043595", "fragment_sha256": "23836ab62c3001a40e48260dc237fd9fa54ffbf41e22c3ab5eab14e0ac18b281", "source_revision": "sha256:af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:65fda1f1b62a89992b84014c9157e61b67dbe8190e93945826efec668fad038c", "translated_from_revision": "sha256:af105fc8e960fc836a09fc2cd7f582b49fd17675d9d36631abe3a565bfd7d701"}, "body_sha256": "93f769f8532078084222163ef5d60249520184b322a11707ae16727e50dd1d78", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><div class=\"itemizedlist\"><ul class=\"itemizedlist\"><li class=\"listitem\"><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li class=\"listitem\"><p>\n     \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\n    </p></li><li class=\"listitem\"><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><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><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/19/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span> </dt><dd><p>\n        \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\n       </p><p>\n        \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=\"/zh/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/19/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "version": "19", "link_map": {"/zh/docs/19/app-pgrewind.html": "/docs/19/app-pgrewind.html", "/zh/docs/19/libpq-envars.html": "/docs/19/libpq-envars.html", "/zh/docs/19/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/19/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/19/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/19/runtime-config-wal.html#GUC-FULL-PAGE-WRITES", "/zh/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD": "/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>pg_rewind</span> \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a\n  </p><div><ul><li><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li><p>\n     \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\n    </p></li><li><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/19/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/19/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>datadir</code></em></code><br/></span><span><code>--target-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/19/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/19/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "6edc5bb60da8a3a54378d72eb81259de4f73194fc291186f69d164397c870f5e", "content_hash": "bdd0af81282a42ba3de3ee47d91b2302025b59ebf18644bea2cb366aa0b99369", "source_database": "center", "source_revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "bdd0af81282a42ba3de3ee47d91b2302025b59ebf18644bea2cb366aa0b99369"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>pg_rewind</span> \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a\n  </p><div><ul><li><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li><p>\n     \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\n    </p></li><li><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/19/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/19/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/19/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>datadir</code></em></code><br/></span><span><code>--target-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/19/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/19/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "source_revalidation": {"kind": "static-same-version-source-and-manual-replay", "audit": "wiki-audit-20261023", "runtime_rerun": false, "compared_fields": "entity membership and source-derived facts; presentation markup normalized", "source_revision": "d18947140876810d6024d5349bfc5822da04a1b923777cac5009d0665d889008", "previous_source_revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833"}}, "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": {"major": "20", "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "source_sha256": "49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac"}, "revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d", "evidence_kind": "English manual and source declarations", "source_sha256": "49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac"}, "sources": [{"url": "/docs/devel/app-pgrewind.html", "file": "app-pgrewind.html", "label": "20devel English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "380e66677d97905dd242be5c0f6b59d360787c098a18ace34db7a7be5b33595d"}, {"url": "/docs/devel/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1fce063747a6c9ad86e43068df4310d514cf97dfdf8e758d2957ec46df080cf6"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/devel/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "20", "build_id": 111, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "4b859328d27b78b6272805b7ec781fe43f4b2ab44a71f34935a4de72492ef735", "fragment_sha256": "10507ea0f253649ef8f9f25f279126a77d473135b3238f3c0f7ed952f2a814c7", "source_revision": "sha256:49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:98c980963b401d40bd50df72b909e7523e3148b8fdb48edd897de2efb67e5235", "translated_from_revision": "sha256:49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac"}, "body_sha256": "12f9533bd12a578db2c11457eb04b6366020fbc68309a2f4039818db14d327d5", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "20", "text_hash": "d09714cbe58f9a68f6cee6ed95b30d7eb006ca407006cfb99ef856c7dc8b7628", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/devel/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "20", "build_id": 111, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "4b859328d27b78b6272805b7ec781fe43f4b2ab44a71f34935a4de72492ef735", "fragment_sha256": "10507ea0f253649ef8f9f25f279126a77d473135b3238f3c0f7ed952f2a814c7", "source_revision": "sha256:49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:98c980963b401d40bd50df72b909e7523e3148b8fdb48edd897de2efb67e5235", "translated_from_revision": "sha256:49c73aa4c9cacef8ca979276a28ac416c08e9e54c9baee4ae5fd116a35fa13ac"}, "body_sha256": "12f9533bd12a578db2c11457eb04b6366020fbc68309a2f4039818db14d327d5", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><div class=\"itemizedlist\"><ul class=\"itemizedlist\"><li class=\"listitem\"><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li class=\"listitem\"><p>\n     \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\n    </p></li><li class=\"listitem\"><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><p>\n   \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=\"/zh/docs/devel/app-pgchecksums.html\"><span class=\"refentrytitle\"><span class=\"application\">pg_checksums</span></span></a>\u3002\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><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><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/devel/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span> </dt><dd><p>\n        \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\n       </p><p>\n        \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=\"/zh/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/devel/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "version": "20", "link_map": {"/zh/docs/devel/app-pgrewind.html": "/docs/devel/app-pgrewind.html", "/zh/docs/devel/libpq-envars.html": "/docs/devel/libpq-envars.html", "/zh/docs/devel/app-pgchecksums.html": "/docs/devel/app-pgchecksums.html", "/zh/docs/devel/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/devel/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/devel/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/devel/runtime-config-wal.html#GUC-FULL-PAGE-WRITES", "/zh/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD": "/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>pg_rewind</span> \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a\n  </p><div><ul><li><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li><p>\n     \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\n    </p></li><li><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/devel/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/devel/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><p>\n   \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>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 href=\"/zh/docs/devel/app-pgchecksums.html\" rel=\"nofollow\"><span><span>pg_checksums</span></span></a>\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>datadir</code></em></code><br/></span><span><code>--target-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/devel/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/devel/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "5b6f476a84baaa138a4eed1ba38e33ec4bdf47cc3947e3f83b1c3a4083305b10", "content_hash": "d09714cbe58f9a68f6cee6ed95b30d7eb006ca407006cfb99ef856c7dc8b7628", "source_database": "center", "source_revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "d09714cbe58f9a68f6cee6ed95b30d7eb006ca407006cfb99ef856c7dc8b7628"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002 \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 \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 \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } datadir { --source-pgdata= datadir | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>pg_rewind</span> \u4e0d\u9700\u8981\u6bd4\u8f83\u6216\u590d\u5236\u96c6\u7c07\u4e2d\u672a\u53d1\u751f\u53d8\u5316\u7684\u5173\u7cfb\u5757\uff1a\n  </p><div><ul><li><p>\n     \u53ea\u590d\u5236\u73b0\u6709\u5173\u7cfb\u6587\u4ef6\u4e2d\u53d1\u751f\u53d8\u5316\u7684\u5757\u3002\n    </p></li><li><p>\n     \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\n    </p></li><li><p>\n     \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\n    </p></li></ul></div><p>\n   \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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/devel/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/devel/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/devel/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><p>\n   \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>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 href=\"/zh/docs/devel/app-pgchecksums.html\" rel=\"nofollow\"><span><span>pg_checksums</span></span></a>\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>datadir</code></em></code><br/></span><span><code>--target-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>datadir</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/devel/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/devel/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "source_revalidation": {"kind": "static-same-version-source-and-manual-replay", "audit": "wiki-audit-20261023", "runtime_rerun": false, "compared_fields": "entity membership and source-derived facts; presentation markup normalized", "source_revision": "1a7c6c7636e5e62d87e76e3586ffcfdfba79093ddd5daa598c7f722ccfa45d5d", "previous_source_revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918"}}}}, "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": "/docs/18/app-pgrewind.html", "file": "app-pgrewind.html", "label": "18.6 English manual \u00b7 app-pgrewind.html", "anchor": "", "sha256": "2d8a13348838dfc44e3733f7e269f3fb35643d705686198ab09cc5bada9a1330"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/18/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "18", "build_id": 107, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "e288a54ad498f84bbe1f99eb62471662046113c78137cae1b61a420dd01270d2", "fragment_sha256": "c86e366667480ddad966c6cd4ca22e136328b2791ff435ba18eef799171a79c3", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b", "translated_from_revision": null}, "body_sha256": "1e127cea56ecf75988cff3034040de3f78d10025691eb6fe45be940b99736679", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "facts_zh": [{"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"}], "sections": [], "synopsis": ["pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }"], "center_zh": {"title": "pg_rewind", "locale": "zh-Hans", "source": {"key": "pg-rewind", "locale": "zh-Hans", "version": "18", "text_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096", "collection": "tool", "dataset_hash": "7c31b524dfe136022d39a6ae8dcfac6b3bbd5f8fdaf422536599981252aff0c9", "source_database": "center", "source_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "payload": {"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"}]}], "zh_from": {"kind": "same-version-chinese-manual-with-source-derived-identity", "manual": {"url": "/zh/docs/18/app-pgrewind.html", "anchor": "", "locale": "zh-Hans", "version": "18", "build_id": 107, "page_key": "app-pgrewind.html", "extraction": "command-description-and-options", "source_hash": "e288a54ad498f84bbe1f99eb62471662046113c78137cae1b61a420dd01270d2", "fragment_sha256": "c86e366667480ddad966c6cd4ca22e136328b2791ff435ba18eef799171a79c3", "source_revision": "unknown:rendered-translation-baseline", "translation_revision": "git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b", "translated_from_revision": null}, "body_sha256": "1e127cea56ecf75988cff3034040de3f78d10025691eb6fe45be940b99736679", "runtime_rerun": false, "authored_translation": "source-derived-identity", "source_facts_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "sections": [], "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div class=\"refsect1\"><h2>\u63cf\u8ff0</h2><p>\n<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\n  </p><p>\n   \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\n  </p><p>\n<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\n  </p><p>\n   \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=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<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=\"/zh/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=\"/zh/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\n  </p><div class=\"warning\"><h3 class=\"title\">\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \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\n   </p><p>\n    \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\n   </p><p>\n    \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\n   </p></div></div><div class=\"refsect1\"><h2>\u9009\u9879</h2><p>\n<span class=\"application\">pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div class=\"variablelist\"><dl class=\"variablelist\"><dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>directory</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--target-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-pgdata=<em class=\"replaceable\"><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--source-server=<em class=\"replaceable\"><code>connstr</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-R</code><br/></span><span class=\"term\"><code class=\"option\">--write-recovery-conf</code></span> </dt><dd><p>\n        \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=\"/zh/docs/18/libpq-envars.html\">\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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-n</code><br/></span><span class=\"term\"><code class=\"option\">--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-P</code><br/></span><span class=\"term\"><code class=\"option\">--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code class=\"filename\">pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code class=\"varname\">restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--config-file=<em class=\"replaceable\"><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span class=\"application\">pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span class=\"application\">postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code class=\"option\">-c/--restore-target-wal</code> \u83b7\u53d6 <code class=\"varname\">restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--debug</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--no-ensure-shutdown</code></span> </dt><dd><p>\n<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\n       </p></dd><dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span> </dt><dd><p>\n        \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\n       </p><p>\n        \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=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "summary": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "version": "18", "link_map": {"/zh/docs/18/app-pgrewind.html": "/docs/18/app-pgrewind.html", "/zh/docs/18/libpq-envars.html": "/docs/18/libpq-envars.html", "/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS": "/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS", "/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND": "/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND", "/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES": "/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES", "/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD": "/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD"}, "body_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/18/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "body_sha256": "21697e94251db32e3fa5189670146b9a4c61572df204bb5e69a1589ab65f9582", "content_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096", "source_database": "center", "source_revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}, "signature": "pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }", "tables_zh": [{"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"}]}], "description": ["\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728"], "environment": [], "manual_html": "", "manual_path": "app-pgrewind.html", "sections_zh": [], "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", "canonical_center_text_hash": "d19571bb04a8f65aa32a94601fecab9bc50e77eaeef393076f7f3d139d794096"}, "description_zh": "\u63cf\u8ff0 pg_rewind \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 PostgreSQL \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 \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 rsync \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c pg_rewind \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 pg_rewind \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 pg_wal \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 pg_wal \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 -c \u9009\u9879\u8fd0\u884c pg_rewind \uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002 pg_rewind \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 \u8fd0\u884c pg_rewind \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 pg_rewind \u65f6\uff0c\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e9b WAL \u5df2\u7ecf\u4e0d\u53ef\u7528\uff0c\u56e0\u6b64\u65e0\u6cd5\u7531 pg_rewind \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 recovery.signal \u6587\u4ef6\uff0c\u5e76\u5728 postgresql.conf \u4e2d\u914d\u7f6e\u5408\u9002\u7684 restore_command \u6765\u5b9e\u73b0\u3002 pg_rewind \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728", "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", "description_zh_html": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\" rel=\"nofollow\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/zh/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\" rel=\"nofollow\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/zh/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/zh/docs/18/libpq-envars.html\" rel=\"nofollow\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/zh/docs/18/app-pgrewind.html\" rel=\"nofollow\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>", "center_zh_rendered": "<p>\u547d\u4ee4\u884c\u5de5\u5177 pg_rewind [ option ...] { -D | --target-pgdata } directory { --source-pgdata= directory | --source-server= connstr }\u3002</p><h3>\u540c\u7248\u672c\u4e2d\u6587\u624b\u518c\u8282\u9009</h3><div><h2>\u63cf\u8ff0</h2><p>\n<span>pg_rewind</span> \u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u540c\u4e00 <span>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\n  </p><p>\n   \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>rsync</span> \u4e4b\u7c7b\u7684\u5de5\u5177\u4e0d\u540c\uff0c<span>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\n  </p><p>\n<span>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>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>pg_wal</code> \u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>-c</code> \u9009\u9879\u8fd0\u884c <span>pg_rewind</span>\uff0c\u8ba9\u5b83\u81ea\u52a8\u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de\u8fd9\u4e9b\u6587\u4ef6\u3002<span>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\n  </p><p>\n   \u8fd0\u884c <span>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>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>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>recovery.signal</code> \u6587\u4ef6\uff0c\u5e76\u5728 <code>postgresql.conf</code> \u4e2d\u914d\u7f6e\u5408\u9002\u7684 <a href=\"/docs/18/runtime-config-wal.html#GUC-RESTORE-COMMAND\">restore_command</a> \u6765\u5b9e\u73b0\u3002\n  </p><p>\n<span>pg_rewind</span> \u8981\u6c42\u76ee\u6807\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\uff1a\u8981\u4e48\u5728 <code>postgresql.conf</code> \u4e2d\u542f\u7528\u4e86 <a href=\"/docs/18/runtime-config-wal.html#GUC-WAL-LOG-HINTS\">wal_log_hints</a> \u9009\u9879\uff0c\u8981\u4e48\u5728\u7528 <span>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 href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\">full_page_writes</a> \u4e5f\u5fc5\u987b\u8bbe\u7f6e\u4e3a <code>on</code>\uff0c\u4e0d\u8fc7\u5b83\u9ed8\u8ba4\u5df2\u542f\u7528\u3002\n  </p><div><h3>\u8b66\u544a\uff1a\u56de\u5377\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c</h3><p>\n    \u5982\u679c <span>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\n   </p><p>\n    \u7531\u4e8e <span>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\n   </p><p>\n    \u5982\u679c <span>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>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\n   </p></div></div><div><h2>\u9009\u9879</h2><p>\n<span>pg_rewind</span> \u63a5\u53d7\u4ee5\u4e0b\u547d\u4ee4\u884c\u53c2\u6570\uff1a\n\n    </p><div><dl><dt><span><code>-D <em><code>directory</code></em></code><br/></span><span><code>--target-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \u6b64\u9009\u9879\u6307\u5b9a\u8981\u4e0e\u6e90\u540c\u6b65\u7684\u76ee\u6807\u6570\u636e\u76ee\u5f55\u3002\u5728\u8fd0\u884c <span>pg_rewind</span> \u4e4b\u524d\uff0c\u76ee\u6807\u670d\u52a1\u5668\u5fc5\u987b\u5df2\u6b63\u5e38\u5173\u95ed\u3002\n       </p></dd><dt><span><code>--source-pgdata=<em><code>directory</code></em></code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>--source-server=<em><code>connstr</code></em></code></span> </dt><dd><p>\n        \u6307\u5b9a\u4e00\u4e2a libpq \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u8fde\u63a5\u6e90 <span>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>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\n       </p></dd><dt><span><code>-R</code><br/></span><span><code>--write-recovery-conf</code></span> </dt><dd><p>\n        \u5728\u8f93\u51fa\u76ee\u5f55\u4e2d\u521b\u5efa <code>standby.signal</code>\uff0c\u5e76\u628a\u8fde\u63a5\u8bbe\u7f6e\u8ffd\u52a0\u5230 <code>postgresql.auto.conf</code> \u4e2d\u3002\u53ea\u6709\u5f53\u8fde\u63a5\u5b57\u7b26\u4e32\u6216<a href=\"/docs/18/libpq-envars.html\">\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>--source-server</code>\u3002\n       </p></dd><dt><span><code>-n</code><br/></span><span><code>--dry-run</code></span> </dt><dd><p>\n        \u6267\u884c\u9664\u5b9e\u9645\u4fee\u6539\u76ee\u6807\u76ee\u5f55\u4e4b\u5916\u7684\u6240\u6709\u64cd\u4f5c\u3002\n       </p></dd><dt><span><code>-N</code><br/></span><span><code>--no-sync</code></span> </dt><dd><p>\n        \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>pg_rewind</code> \u4f1a\u7b49\u5f85\u6240\u6709\u6587\u4ef6\u90fd\u5b89\u5168\u5199\u5165\u78c1\u76d8\u3002\u6b64\u9009\u9879\u4f1a\u4f7f <code>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\n       </p></dd><dt><span><code>-P</code><br/></span><span><code>--progress</code></span> </dt><dd><p>\n        \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\n       </p></dd><dt><span><code>-c</code><br/></span><span><code>--restore-target-wal</code></span> </dt><dd><p>\n        \u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5728 <code>pg_wal</code> \u76ee\u5f55\u4e2d\u5df2\u4e0d\u53ef\u7528\uff0c\u5219\u4f7f\u7528\u76ee\u6807\u96c6\u7c07\u914d\u7f6e\u4e2d\u5b9a\u4e49\u7684 <code>restore_command</code> \u4ece WAL \u5f52\u6863\u4e2d\u53d6\u56de WAL \u6587\u4ef6\u3002\n       </p></dd><dt><span><code>--config-file=<em><code>filename</code></em></code></span> </dt><dd><p>\n        \u4e3a\u76ee\u6807\u96c6\u7c07\u4f7f\u7528\u6307\u5b9a\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u3002\u5f53 <span>pg_rewind</span> \u5728\u8be5\u96c6\u7c07\u4e0a\u5185\u90e8\u4f7f\u7528 <span>postgres</span> \u547d\u4ee4\u6267\u884c\u56de\u5377\u64cd\u4f5c\u65f6\uff0c\u8fd9\u4e00\u9009\u9879\u4f1a\u5bf9\u5176\u4ea7\u751f\u5f71\u54cd\uff08\u5305\u62ec\u4f7f\u7528 <code>-c/--restore-target-wal</code> \u83b7\u53d6 <code>restore_command</code> \u4ee5\u53ca\u5f3a\u5236\u5b8c\u6210\u5d29\u6e83\u6062\u590d\u65f6\uff09\u3002\n       </p></dd><dt><span><code>--debug</code></span> </dt><dd><p>\n        \u6253\u5370\u8be6\u7ec6\u7684\u8c03\u8bd5\u8f93\u51fa\uff0c\u8fd9\u4e9b\u8f93\u51fa\u4e3b\u8981\u5bf9\u8c03\u8bd5 <span>pg_rewind</span> \u7684\u5f00\u53d1\u4eba\u5458\u6709\u7528\u3002\n       </p></dd><dt><span><code>--no-ensure-shutdown</code></span> </dt><dd><p>\n<span>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>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>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\n       </p></dd><dt><span><code>--sync-method=<em><code>method</code></em></code></span> </dt><dd><p>\n        \u8bbe\u4e3a <code>fsync</code>\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0c<code>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\n       </p><p>\n        \u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u6539\u7528 <code>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>syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u9650\u5236\uff0c\u8bf7\u53c2\u89c1 <a href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u3002\n       </p><p>\n        \u4f7f\u7528 <code>--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002\n       </p></dd><dt><span><code>-V</code><br/></span><span><code>--version</code></span> </dt><dd><p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd><dt><span><code>-?</code><br/></span><span><code>--help</code></span> </dt><dd><p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa\u3002</p></dd></dl></div><p>\n</p></div><p><a href=\"/docs/18/app-pgrewind.html\">\u67e5\u770b\u5b8c\u6574\u4e2d\u6587\u624b\u518c\u4e0e\u4e0a\u4e0b\u6587</a>\u3002</p>"}, "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.\","}}