{"kind": "tool", "major": "18", "item": {"slug": "pg-upgrade", "name": "pg_upgrade", "name_zh": "", "category": "\u670d\u52a1\u7aef\u7a0b\u5e8f", "summary": "pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b", "aliases": ["pg_upgrade"], "content_hash": "bb490e2e83b5f86bb0a73e4c7428ee4a381ee81037815b24d6ab8d5967b4d19c", "versions": {"10": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "16"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-D configdir --new-datadir= configdir y"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/10/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/10/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/10/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/10/pgupgrade.html", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/10/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/10/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir y", "source_url": "/docs/10/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/10/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/10/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/10/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/10/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/10/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/10/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/10/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/10/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/10/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/10/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/10/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/10/postgresql-10-A4.pdf", "bytes": 12631706, "pages": 2591, "sha256": "34497ab9efb45c5bdf1bd11b9016b5451354feb462fa029cf74557a5fa5fbbc1", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/10/postgresql-10-US.pdf", "bytes": 12531684, "pages": 2724, "sha256": "429cc7133ddf4f97c560aa466dc9caea4b718721a8321e293357037cf0af4733", "built_at": "2026-09-26"}}, "tree": "10", "index": "index.html", "major": "10", "pages": 1085, "release": "10.23", "source_url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea", "evidence_kind": "English manual and source declarations", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "sources": [{"url": "https://pg.center/docs/10/pgupgrade.html", "file": "pgupgrade.html", "label": "10.23 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "1265ba6532a0413b15e20ee2f58c8d8dcca5da1512e805188a26c483d73f3739", "language": "en", "original_url": "/docs/10/pgupgrade.html"}, {"url": "https://pg.center/docs/10/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "2a6043b88501763a31348758a370a42cd7f9a179c7fdf3ef0e353c82e95b33e9", "language": "en", "original_url": "/docs/10/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.11.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> <code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em> <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u91cd\u65b0\u8f7d\u5165\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 8.4.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em>y</span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/10</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre></li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/10/libpq-pgpass.html\" title=\"33.15.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a033.15\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\u3002\u4f8b\u5982\uff0c\u5728 Unix \u4e0a\u4f7f\u7528\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/10 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u6b63\u786e\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-9.6\nNET STOP postgresql-10\n</pre>\n<p>\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u53ef\u4ee5\u7ee7\u7eed\u8fd0\u884c\uff0c\u76f4\u5230\u540e\u9762\u7684\u6b65\u9aa4\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/10/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\uff08\u5982\u679c\u65e7\u5907\u5e93\u5728\u65e7\u4e3b\u5e93\u4e4b\u524d\u5173\u95ed\uff0c\u6216\u8005\u65e7\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8fd9\u4e9b\u503c\u5c31\u4f1a\u4e0d\u5339\u914d\u3002\uff09\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u5b8c\u6574\u9009\u9879\u5217\u8868\u8bf7\u53c2\u9605<code class=\"literal\">pg_upgrade --help</code>\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u91cd\u65b0\u88c5\u8f7d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\10\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/10/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/10/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e94\u5c06 <code class=\"option\">--link</code> \u9009\u9879\u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u94fe\u63a5\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/10/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/10/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/10/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<ol class=\"substeps\" type=\"a\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">recovery.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_start_backup()</code>\u548c<code class=\"function\">pg_stop_backup()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u65b0\u65e7\u96c6\u7c07\u53ef\u80fd\u5171\u4eab\u6570\u636e\u6587\u4ef6\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4e0b\u5217<code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u5e93\uff1a<code class=\"type\">regproc</code>\u3001<code class=\"type\">regprocedure</code>\u3001<code class=\"type\">regoper</code>\u3001<code class=\"type\">regoperator</code>\u3001<code class=\"type\">regconfig</code>\u548c<code class=\"type\">regdictionary</code>\u3002\uff08<code class=\"type\">regtype</code>\u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u6b63\u5728\u5347\u7ea7<span class=\"productname\">PostgreSQL</span> 9.2 \u4e4b\u524d\u7684\u96c6\u7c07\uff0c\u800c\u4e14\u5b83\u4f7f\u7528\u4e86\u53ea\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5c31\u5fc5\u987b\u628a\u5b9e\u9645\u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9<span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u628a\u914d\u7f6e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9\u670d\u52a1\u5668\uff0c\u4f8b\u5982<code class=\"literal\">-d /real-data-directory -o '-D /configuration-directory'</code>\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u65e7\u670d\u52a1\u5668\u65e9\u4e8e 9.1\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u9ed8\u8ba4\u7684 Unix \u57df\u5957\u63a5\u5b57\u76ee\u5f55\uff0c\u6216\u8005\u5176\u9ed8\u8ba4\u76ee\u5f55\u4e0e\u65b0\u96c6\u7c07\u7684\u9ed8\u8ba4\u76ee\u5f55\u4e0d\u540c\uff0c\u8bf7\u5c06<code class=\"envar\">PGHOST</code>\u8bbe\u7f6e\u4e3a\u65e7\u670d\u52a1\u5668\u7684\u5957\u63a5\u5b57\u4f4d\u7f6e\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/10/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2>\n<span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/10/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/10/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/10/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\">pg_dump</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/10/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span></div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/10/pgupgrade.html", "method": "same-major semantic node", "sha256": "aa25e0c20c8159d6cec1e97d89162999981434aa0e7aba319ded35ad2629f08d", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[6]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/10/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/10/tables/0/rows/1/summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "/versions/10/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/10/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/10/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/10/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/10/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/10/tables/0/rows/7/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/10/tables/0/rows/8/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/versions/10/tables/0/rows/9/summary": "the old cluster port number; environment variable PGPORTOLD", "/versions/10/tables/0/columns/0/label": "Option and arguments", "/versions/10/tables/0/columns/1/label": "Description", "/versions/10/tables/0/rows/10/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/10/tables/0/rows/11/summary": "retain SQL and log files even after successful completion", "/versions/10/tables/0/rows/12/summary": "cluster's install user name; environment variable PGUSER", "/versions/10/tables/0/rows/13/summary": "enable verbose internal logging", "/versions/10/tables/0/rows/14/summary": "display version information, then exit", "/versions/10/tables/0/rows/15/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "31172bd6007c4a776c4d316dca40169c6eeacbf1020e2a521435e17c20c34c5f"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir y", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "338ddfb5ec96e1ac8252650ee93c1f136eaa3a45dcaf7374ad931604c6c5c08e", "manual_language": "zh"}, "11": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "16"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/11/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/11/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/11/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/11/pgupgrade.html", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/11/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/11/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/11/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/11/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/11/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/11/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/11/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/11/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/11/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/11/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/11/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/11/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/11/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/11/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/11/postgresql-11-A4.pdf", "bytes": 13057499, "pages": 2732, "sha256": "41d75855e610d0d9b8802b87dc5b080bef8d7e91c7cf69401fbf8d3cf801b4b5", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/11/postgresql-11-US.pdf", "bytes": 12961189, "pages": 2883, "sha256": "6a8899ef36935a5b7ed2b436207564a567a4ef1eb1c2200195876b8de4d4fa30", "built_at": "2026-09-26"}}, "tree": "11", "index": "index.html", "major": "11", "pages": 1125, "release": "11.22", "source_url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f", "evidence_kind": "English manual and source declarations", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "sources": [{"url": "https://pg.center/docs/11/pgupgrade.html", "file": "pgupgrade.html", "label": "11.22 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "e0a281ec12db8c7050ce3b614aedb21986183f1472b7132388b40ad1256ddb44", "language": "en", "original_url": "/docs/11/pgupgrade.html"}, {"url": "https://pg.center/docs/11/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e940a8505b6742c717a1683d19bf8f759aad245633a59db9e83a345ae7c5709a", "language": "en", "original_url": "/docs/11/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.11.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> <code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em> <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 8.4.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/11</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/11/libpq-pgpass.html\" title=\"34.15.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a034.15\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\" lang=\"zh\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p lang=\"zh\">\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">pg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/11 stop\n</pre>\n<p lang=\"zh\">\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">NET STOP postgresql-9.6\nNET STOP postgresql-11\n</pre>\n<p lang=\"zh\">\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/11/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u5b8c\u6574\u9009\u9879\u5217\u8868\u8bf7\u53c2\u9605<code class=\"literal\">pg_upgrade --help</code>\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\11\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/11/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/11/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e94\u5c06 <code class=\"option\">--link</code> \u9009\u9879\u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u94fe\u63a5\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/11/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/11/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/11/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<ol class=\"substeps\" type=\"a\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">recovery.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_start_backup()</code>\u548c<code class=\"function\">pg_stop_backup()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u65b0\u65e7\u96c6\u7c07\u53ef\u80fd\u5171\u4eab\u6570\u636e\u6587\u4ef6\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217<code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a<code class=\"type\">regproc</code>\u3001<code class=\"type\">regprocedure</code>\u3001<code class=\"type\">regoper</code>\u3001<code class=\"type\">regoperator</code>\u3001<code class=\"type\">regconfig</code>\u548c<code class=\"type\">regdictionary</code>\u3002\uff08<code class=\"type\">regtype</code>\u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u6b63\u5728\u5347\u7ea7<span class=\"productname\">PostgreSQL</span> 9.2 \u4e4b\u524d\u7684\u96c6\u7c07\uff0c\u800c\u4e14\u5b83\u4f7f\u7528\u4e86\u53ea\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5c31\u5fc5\u987b\u628a\u5b9e\u9645\u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9<span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u628a\u914d\u7f6e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9\u670d\u52a1\u5668\uff0c\u4f8b\u5982<code class=\"literal\">-d /real-data-directory -o '-D /configuration-directory'</code>\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u65e7\u670d\u52a1\u5668\u65e9\u4e8e 9.1\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u9ed8\u8ba4\u7684 Unix \u57df\u5957\u63a5\u5b57\u76ee\u5f55\uff0c\u6216\u8005\u5176\u9ed8\u8ba4\u76ee\u5f55\u4e0e\u65b0\u96c6\u7c07\u7684\u9ed8\u8ba4\u76ee\u5f55\u4e0d\u540c\uff0c\u8bf7\u5c06<code class=\"envar\">PGHOST</code>\u8bbe\u7f6e\u4e3a\u65e7\u670d\u52a1\u5668\u7684\u5957\u63a5\u5b57\u4f4d\u7f6e\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/11/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.11.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/11/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/11/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/11/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\">pg_dump</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/11/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/11/pgupgrade.html", "method": "same-major semantic node", "sha256": "8bb210fd06b8bb838e5c2c8c9c65784149228b7e5b279932b7ed68af0801d2c9", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[6]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/11/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/11/tables/0/rows/1/summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "/versions/11/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/11/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/11/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/11/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/11/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/11/tables/0/rows/7/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/11/tables/0/rows/8/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/versions/11/tables/0/rows/9/summary": "the old cluster port number; environment variable PGPORTOLD", "/versions/11/tables/0/columns/0/label": "Option and arguments", "/versions/11/tables/0/columns/1/label": "Description", "/versions/11/tables/0/rows/10/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/11/tables/0/rows/11/summary": "retain SQL and log files even after successful completion", "/versions/11/tables/0/rows/12/summary": "cluster's install user name; environment variable PGUSER", "/versions/11/tables/0/rows/13/summary": "enable verbose internal logging", "/versions/11/tables/0/rows/14/summary": "display version information, then exit", "/versions/11/tables/0/rows/15/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "30a722b8887c74a85cf6a6d2b9e7e8f49b40bd2856b5b27e6117c0a7ae80bd97"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "1011c4bf627a7e9b7b8ab95922514ed15c7ed85912bcf2facc561d1b10cd1e2a", "manual_language": "zh"}, "12": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "18"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/12/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/12/pgupgrade.html", "text": "--clone"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/12/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/12/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/12/pgupgrade.html", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/12/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/12/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/12/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/12/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/12/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/12/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/12/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/12/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/12/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/12/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/12/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/12/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/12/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/12/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/12/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/12/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/12/postgresql-12-A4.pdf", "bytes": 13424351, "pages": 2803, "sha256": "7422cf53fd1939e7a3d2925231a88b0330e468afa5393627cac0ff86158a0621", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/12/postgresql-12-US.pdf", "bytes": 13322565, "pages": 2958, "sha256": "51f3b04e72907fc38512685946223452ea65f84419c60c66241dfa3396035e77", "built_at": "2026-09-26"}}, "tree": "12", "index": "index.html", "major": "12", "pages": 1131, "release": "12.22", "source_url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "svg_assets": 2, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4", "evidence_kind": "English manual and source declarations", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "sources": [{"url": "https://pg.center/docs/12/pgupgrade.html", "file": "pgupgrade.html", "label": "12.22 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "d6f2d54df6b9984b8609d2facd04401f13fb143d82cc6115ea47cbdb426e6810", "language": "en", "original_url": "/docs/12/pgupgrade.html"}, {"url": "https://pg.center/docs/12/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "7f6ae1fadc1b0bffa606551460e62aacdc2508a3fb66566ddae861928ca6080b", "language": "en", "original_url": "/docs/12/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.12.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> <code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em> <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.0.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/12</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/12/libpq-pgpass.html\" title=\"33.15.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a033.15\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\" lang=\"zh\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p lang=\"zh\">\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">pg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/12 stop\n</pre>\n<p lang=\"zh\">\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">NET STOP postgresql-9.6\nNET STOP postgresql-12\n</pre>\n<p lang=\"zh\">\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/12/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\12\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879 <code class=\"option\">--link</code> \u6216 <code class=\"option\">--clone</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/12/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/12/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/12/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<ol class=\"substeps\" type=\"a\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_start_backup()</code>\u548c<code class=\"function\">pg_stop_backup()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u65b0\u65e7\u96c6\u7c07\u53ef\u80fd\u5171\u4eab\u6570\u636e\u6587\u4ef6\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\u3002\u4e3a\u5b89\u5168\u8d77\u89c1\uff0c\u8bf7\u786e\u4fdd\u4efb\u4f55\u5176\u4ed6\u7528\u6237\u90fd\u65e0\u6cd5\u8bfb\u53d6\u6216\u5199\u5165\u8be5\u76ee\u5f55\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217<code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a<code class=\"type\">regproc</code>\u3001<code class=\"type\">regprocedure</code>\u3001<code class=\"type\">regoper</code>\u3001<code class=\"type\">regoperator</code>\u3001<code class=\"type\">regconfig</code>\u548c<code class=\"type\">regdictionary</code>\u3002\uff08<code class=\"type\">regtype</code>\u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u6b63\u5728\u5347\u7ea7<span class=\"productname\">PostgreSQL</span> 9.2 \u4e4b\u524d\u7684\u96c6\u7c07\uff0c\u800c\u4e14\u5b83\u4f7f\u7528\u4e86\u53ea\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5c31\u5fc5\u987b\u628a\u5b9e\u9645\u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9<span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u628a\u914d\u7f6e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9\u670d\u52a1\u5668\uff0c\u4f8b\u5982<code class=\"literal\">-d /real-data-directory -o '-D /configuration-directory'</code>\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u65e7\u670d\u52a1\u5668\u65e9\u4e8e 9.1\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u9ed8\u8ba4\u7684 Unix \u57df\u5957\u63a5\u5b57\u76ee\u5f55\uff0c\u6216\u8005\u5176\u9ed8\u8ba4\u76ee\u5f55\u4e0e\u65b0\u96c6\u7c07\u7684\u9ed8\u8ba4\u76ee\u5f55\u4e0d\u540c\uff0c\u8bf7\u5c06<code class=\"envar\">PGHOST</code>\u8bbe\u7f6e\u4e3a\u65e7\u670d\u52a1\u5668\u7684\u5957\u63a5\u5b57\u4f4d\u7f6e\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/12/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/12/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/12/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/12/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\">pg_dump</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/12/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/12/pgupgrade.html", "method": "same-major semantic node", "sha256": "4b2f44602536b36f9bcee69d192c382cc00a04bd73ca6dfe4b2524013eaab042", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[6]", "#PGUPGRADE/div[7]/p[7]", "#PGUPGRADE/div[7]/p[8]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/12/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/12/tables/0/rows/1/summary": "the new PostgreSQL executable directory; environment variable PGBINNEW", "/versions/12/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/12/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/12/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/12/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/12/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/12/tables/0/rows/7/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/12/tables/0/rows/8/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/versions/12/tables/0/rows/9/summary": "the old cluster port number; environment variable PGPORTOLD", "/versions/12/tables/0/columns/0/label": "Option and arguments", "/versions/12/tables/0/columns/1/label": "Description", "/versions/12/tables/0/rows/10/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/12/tables/0/rows/11/summary": "retain SQL and log files even after successful completion", "/versions/12/tables/0/rows/12/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/12/tables/0/rows/13/summary": "cluster's install user name; environment variable PGUSER", "/versions/12/tables/0/rows/14/summary": "enable verbose internal logging", "/versions/12/tables/0/rows/15/summary": "display version information, then exit", "/versions/12/tables/0/rows/16/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/12/tables/0/rows/17/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "253336c88f8f552105014c3bc1836d653ace964312c5fc0a16836b79b0fd884c"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "d04c8466c5ef01c979ff74ac2dddee051b0b260441bd74e88b47b6ec9cddd824", "manual_language": "zh"}, "13": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "18"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/13/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/13/pgupgrade.html", "text": "--clone"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/13/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/13/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/13/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/13/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/13/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/13/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/13/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/13/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/13/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/13/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/13/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/13/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/13/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/13/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/13/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/13/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/13/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/13/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/13/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/13/postgresql-13-A4.pdf", "bytes": 13843239, "pages": 2826, "sha256": "171cc09f90936dbc1cbd503a98ff07ae72ea58ab9771ff051313f1217737799c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/13/postgresql-13-US.pdf", "bytes": 13739572, "pages": 2984, "sha256": "48d09c6e197d9db4220f41afe83efe848a8661b1b168d3b89419751ecaf6c24d", "built_at": "2026-09-26"}}, "tree": "13", "index": "index.html", "major": "13", "pages": 1139, "release": "13.23", "source_url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6", "evidence_kind": "English manual and source declarations", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "sources": [{"url": "https://pg.center/docs/13/pgupgrade.html", "file": "pgupgrade.html", "label": "13.23 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "488d7eb2463c1ae887d115144b3855ca81e9bd3e4afa805e9c112f952575148f", "language": "en", "original_url": "/docs/13/pgupgrade.html"}, {"url": "https://pg.center/docs/13/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "074ef8577fd368272a2360309e1226e2d0b1e570a3e1da62dfcca63ac9ee5539", "language": "en", "original_url": "/docs/13/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.12.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.0.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/13</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/13/libpq-pgpass.html\" title=\"33.15.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a033.15\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\" lang=\"zh\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p lang=\"zh\">\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">pg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/13 stop\n</pre>\n<p lang=\"zh\">\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">NET STOP postgresql-9.6\nNET STOP postgresql-13\n</pre>\n<p lang=\"zh\">\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/13/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\13\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/13/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/13/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879 <code class=\"option\">--link</code> \u6216 <code class=\"option\">--clone</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/13/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/13/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/13/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<ol class=\"substeps\" type=\"a\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_start_backup()</code>\u548c<code class=\"function\">pg_stop_backup()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u65b0\u65e7\u96c6\u7c07\u53ef\u80fd\u5171\u4eab\u6570\u636e\u6587\u4ef6\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\u3002\u4e3a\u5b89\u5168\u8d77\u89c1\uff0c\u8bf7\u786e\u4fdd\u4efb\u4f55\u5176\u4ed6\u7528\u6237\u90fd\u65e0\u6cd5\u8bfb\u53d6\u6216\u5199\u5165\u8be5\u76ee\u5f55\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u6b63\u5728\u5347\u7ea7<span class=\"productname\">PostgreSQL</span> 9.2 \u4e4b\u524d\u7684\u96c6\u7c07\uff0c\u800c\u4e14\u5b83\u4f7f\u7528\u4e86\u53ea\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5c31\u5fc5\u987b\u628a\u5b9e\u9645\u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9<span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u628a\u914d\u7f6e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9\u670d\u52a1\u5668\uff0c\u4f8b\u5982<code class=\"literal\">-d /real-data-directory -o '-D /configuration-directory'</code>\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u65e7\u670d\u52a1\u5668\u65e9\u4e8e 9.1\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u9ed8\u8ba4\u7684 Unix \u57df\u5957\u63a5\u5b57\u76ee\u5f55\uff0c\u6216\u8005\u5176\u9ed8\u8ba4\u76ee\u5f55\u4e0e\u65b0\u96c6\u7c07\u7684\u9ed8\u8ba4\u76ee\u5f55\u4e0d\u540c\uff0c\u8bf7\u5c06<code class=\"envar\">PGHOST</code>\u8bbe\u7f6e\u4e3a\u65e7\u670d\u52a1\u5668\u7684\u5957\u63a5\u5b57\u4f4d\u7f6e\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/13/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/13/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/13/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/13/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\">pg_dump</span></a>, <a class=\"xref\" href=\"https://pg.center/docs/13/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/13/pgupgrade.html", "method": "same-major semantic node", "sha256": "04c23f3f4e5f96b41192a05be6e907aef691a3c499449160a61a4da0e03ef62e", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]/p[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[10]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[7]", "#PGUPGRADE/div[7]/p[8]", "#PGUPGRADE/div[7]/p[9]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/13/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/13/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/13/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/13/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/13/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/13/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/13/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/13/tables/0/rows/7/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/13/tables/0/rows/8/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/versions/13/tables/0/rows/9/summary": "the old cluster port number; environment variable PGPORTOLD", "/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": "the new cluster port number; environment variable PGPORTNEW", "/versions/13/tables/0/rows/11/summary": "retain SQL and log files even after successful completion", "/versions/13/tables/0/rows/12/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/13/tables/0/rows/13/summary": "cluster's install user name; environment variable PGUSER", "/versions/13/tables/0/rows/14/summary": "enable verbose internal logging", "/versions/13/tables/0/rows/15/summary": "display version information, then exit", "/versions/13/tables/0/rows/16/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/13/tables/0/rows/17/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "63e49be53cad404f7d56386761dbb0a514d999d0e5fb51b13f6295e13ea34876"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "8b6923b8950b8aed8d304e93de9e1491c045406c2435dc20a10c257d2ef44f2d", "manual_language": "zh"}, "14": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "18"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/14/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/14/pgupgrade.html", "text": "--clone"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/14/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/14/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/14/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/14/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/14/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/14/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/14/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/14/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/14/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/14/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/14/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/14/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/14/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/14/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/14/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/14/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/14/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/14/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/14/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/14/postgresql-14-A4.pdf", "bytes": 14354704, "pages": 2944, "sha256": "8bc6b9dd7b246888bb77f0a5e8c39a2eae52e9926569832669c7d1600becb27c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/14/postgresql-14-US.pdf", "bytes": 14242178, "pages": 3102, "sha256": "b7ecb5a5f62d8b9f73a69e25a7d26ba285373bc53168a553bff7b77955506db4", "built_at": "2026-09-26"}}, "tree": "14", "index": "index.html", "major": "14", "pages": 1158, "release": "14.24", "source_url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae", "evidence_kind": "English manual and source declarations", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "sources": [{"url": "https://pg.center/docs/14/pgupgrade.html", "file": "pgupgrade.html", "label": "14.24 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "9cb7a9a2abfd3e1423e32ddf4c61af1a74fb6db2575280bc8e4ebb182ab8fb85", "language": "en", "original_url": "/docs/14/pgupgrade.html"}, {"url": "https://pg.center/docs/14/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "db0cdccaa8d3c65ad3b2a07d4956eb5a783a18505bfa0f9d9626eef4ab94fe44", "language": "en", "original_url": "/docs/14/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.12.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.0.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.7\">\n<h2 lang=\"zh\">\u4f7f\u7528</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/14</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/14/libpq-pgpass.html\" title=\"34.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a034.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\u3002\u4f8b\u5982\uff0c\u5728 Unix \u4e0a\u4f7f\u7528\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/14 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u6b63\u786e\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-9.6\nNET STOP postgresql-14\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/14/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\14\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/14/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/14/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879 <code class=\"option\">--link</code> \u6216 <code class=\"option\">--clone</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/14/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/14/warm-standby.html#STREAMING-REPLICATION\" title=\"27.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a027.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/14/warm-standby.html\" title=\"27.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a027.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<ol class=\"substeps\" type=\"a\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_start_backup()</code>\u548c<code class=\"function\">pg_stop_backup()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\u3002\u4e3a\u5b89\u5168\u8d77\u89c1\uff0c\u8bf7\u786e\u4fdd\u4efb\u4f55\u5176\u4ed6\u7528\u6237\u90fd\u65e0\u6cd5\u8bfb\u53d6\u6216\u5199\u5165\u8be5\u76ee\u5f55\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u6b63\u5728\u5347\u7ea7<span class=\"productname\">PostgreSQL</span> 9.2 \u4e4b\u524d\u7684\u96c6\u7c07\uff0c\u800c\u4e14\u5b83\u4f7f\u7528\u4e86\u53ea\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5c31\u5fc5\u987b\u628a\u5b9e\u9645\u6570\u636e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9<span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u628a\u914d\u7f6e\u76ee\u5f55\u7684\u4f4d\u7f6e\u4f20\u7ed9\u670d\u52a1\u5668\uff0c\u4f8b\u5982<code class=\"literal\">-d /real-data-directory -o '-D /configuration-directory'</code>\u3002</p>\n<p lang=\"zh\">\u5982\u679c\u65e7\u670d\u52a1\u5668\u65e9\u4e8e 9.1\uff0c\u800c\u4e14\u4f7f\u7528\u975e\u9ed8\u8ba4\u7684 Unix \u57df\u5957\u63a5\u5b57\u76ee\u5f55\uff0c\u6216\u8005\u5176\u9ed8\u8ba4\u76ee\u5f55\u4e0e\u65b0\u96c6\u7c07\u7684\u9ed8\u8ba4\u76ee\u5f55\u4e0d\u540c\uff0c\u8bf7\u5c06<code class=\"envar\">PGHOST</code>\u8bbe\u7f6e\u4e3a\u65e7\u670d\u52a1\u5668\u7684\u5957\u63a5\u5b57\u4f4d\u7f6e\u3002\uff08\u8fd9\u4e0e Windows \u65e0\u5173\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/14/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"26.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a026.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/14/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/14/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/14/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/14/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/14/pgupgrade.html", "method": "same-major semantic node", "sha256": "2390a7ee510d19dd318ff142204add16b497ea257b7ebb855fcd7697f7ce97b9", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[10]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[7]", "#PGUPGRADE/div[7]/p[8]", "#PGUPGRADE/div[7]/p[9]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/14/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/14/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/14/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/14/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/14/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/14/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/14/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/14/tables/0/rows/7/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/14/tables/0/rows/8/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/versions/14/tables/0/rows/9/summary": "the old cluster port number; environment variable PGPORTOLD", "/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": "the new cluster port number; environment variable PGPORTNEW", "/versions/14/tables/0/rows/11/summary": "retain SQL and log files even after successful completion", "/versions/14/tables/0/rows/12/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/14/tables/0/rows/13/summary": "cluster's install user name; environment variable PGUSER", "/versions/14/tables/0/rows/14/summary": "enable verbose internal logging", "/versions/14/tables/0/rows/15/summary": "display version information, then exit", "/versions/14/tables/0/rows/16/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/14/tables/0/rows/17/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "5ff285830568780d1fe99662aa61d7c395f462ca26866af3418b5ce2b4486dd4"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "8b6923b8950b8aed8d304e93de9e1491c045406c2435dc20a10c257d2ef44f2d", "manual_language": "zh"}, "15": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "19"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/15/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/15/pgupgrade.html", "text": "--clone"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/15/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/15/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/15/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/15/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/15/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/15/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/15/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/15/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/15/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/15/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/15/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/15/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/15/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/15/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/15/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/15/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/15/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/15/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/15/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/15/postgresql-15-A4.pdf", "bytes": 14609140, "pages": 2987, "sha256": "66228564a4d16efb47d6a914085716ecfe22ca1566db56bc7c3d82f790646d72", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/15/postgresql-15-US.pdf", "bytes": 14495690, "pages": 3153, "sha256": "645a498c2390d47a6223ec74770631185807a19c484edb0fc5a295d9f460bc02", "built_at": "2026-09-26"}}, "tree": "15", "index": "index.html", "major": "15", "pages": 1168, "release": "15.19", "source_url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545", "evidence_kind": "English manual and source declarations", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "sources": [{"url": "https://pg.center/docs/15/pgupgrade.html", "file": "pgupgrade.html", "label": "15.19 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "12e15242e5ca93e9f840c59b99f08306ad4374b10e61653c48467d23cb30328f", "language": "en", "original_url": "/docs/15/pgupgrade.html"}, {"url": "https://pg.center/docs/15/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1240cfbb13ebfd22aac8d5ae40c62a9015b246f7774bcf0bce97355ce06350a0", "language": "en", "original_url": "/docs/15/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.12.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 9.5.8 \u5347\u7ea7\u5230 9.6.4\uff0c\u6216\u4ece 10.7 \u5347\u7ea7\u5230 11.2\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 9.6.2 \u5347\u7ea7\u5230 9.6.3\uff0c\u6216\u4ece 10.1 \u5347\u7ea7\u5230 10.2\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/15</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/15/libpq-pgpass.html\" title=\"34.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a034.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\u3002\u4f8b\u5982\uff0c\u5728 Unix \u4e0a\u4f7f\u7528\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/9.6 stop\npg_ctl -D /opt/PostgreSQL/15 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u6b63\u786e\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-9.6\nNET STOP postgresql-15\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/15/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\15\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/9.6/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/15/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/9.6/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/15/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879 <code class=\"option\">--link</code> \u6216 <code class=\"option\">--clone</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/15/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/15/warm-standby.html#STREAMING-REPLICATION\" title=\"27.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a027.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/15/warm-standby.html\" title=\"27.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a027.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code>\u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4e86\u89e3\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \\\n      /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\uff0c\u8fd0\u884c\u4f4d\u7f6e\u662f\u67d0\u4e2a\u5df2\u5347\u7ea7\u4e14\u5c1a\u672a\u542f\u52a8\u7684\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_9.5_201510051 \\\n      /vol1/pg_tblsp/PG_9.6_201608131 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_backup_start()</code>\u548c<code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/15/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"26.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a026.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/15/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/15/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/15/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/15/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/15/pgupgrade.html", "method": "same-major semantic node", "sha256": "07dfe7068b66d47c834f91945820fa91a2aedbc742c10da448f245b007d8e15b", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[7]", "#PGUPGRADE/div[7]/p[8]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/15/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/15/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/15/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/15/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/15/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/15/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/15/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/15/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/15/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/15/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/15/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/15/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/15/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/15/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/15/tables/0/rows/16/summary": "display version information, then exit", "/versions/15/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/15/tables/0/rows/18/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "0bee9d2a2f1e49f5ba42c70d34279e98b9012c1b75ca3aee3d2249cab0c5a1ac"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "ec26b089455b8a2c6d323ce0249d5bc869fda696ae7dce8d70e0c00f0b13648a", "manual_language": "zh"}, "16": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "20"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/16/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/16/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u548c --clone \u3002\uff09", "signature": {"url": "/docs/16/pgupgrade.html", "text": "--copy"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/16/pgupgrade.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": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/16/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/16/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/16/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/16/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/16/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/16/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/16/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/16/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/16/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/16/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/16/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/16/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/16/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/16/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/16/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/16/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/16/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link and --clone .)", "signature": "--copy", "source_url": "/docs/16/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link and --clone .)"}, {"names": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/16/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/16/postgresql-16-A4.pdf", "bytes": 15282337, "pages": 3055, "sha256": "4bb6c1f63deedac98736d8c4c7bc0fad0ac24e85b07e21ee10411872f06afd06", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/16/postgresql-16-US.pdf", "bytes": 15164148, "pages": 3220, "sha256": "5b6b6166c89991199e144bb0ae34c17a5f29826251dbf19db1abc0df3a3e771b", "built_at": "2026-09-26"}}, "tree": "16", "index": "index.html", "major": "16", "pages": 1169, "release": "16.15", "source_url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef", "evidence_kind": "English manual and source declarations", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "sources": [{"url": "https://pg.center/docs/16/pgupgrade.html", "file": "pgupgrade.html", "label": "16.15 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "ed9109b022b6f56d9bac401e6ecfbbb155e98579c0e9ac83073195851340adbc", "language": "en", "original_url": "/docs/16/pgupgrade.html"}, {"url": "https://pg.center/docs/16/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "8aaa4422eece8f26d84715f855d9d0f7f87b200f8b82898c73c865ee42c2c70f", "language": "en", "original_url": "/docs/16/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.12.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1<code class=\"option\">--link</code>\u548c<code class=\"option\">--clone</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/16</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/16/libpq-pgpass.html\" title=\"34.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a034.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/16 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-16\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/16/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>Windows \u7528\u6237\u5fc5\u987b\u5148\u767b\u5f55\u7ba1\u7406\u5458\u5e10\u53f7\uff0c\u7136\u540e\u4ee5 <code class=\"literal\">postgres</code> \u7528\u6237\u8eab\u4efd\u542f\u52a8 shell\uff0c\u5e76\u8bbe\u7f6e\u6b63\u786e\u7684\u8def\u5f84\uff1a</p>\n<pre class=\"programlisting\">\nRUNAS /USER:postgres \"CMD.EXE\"\nSET PATH=%PATH%;C:\\Program Files\\PostgreSQL\\16\\bin;\n</pre>\n<p>\u7136\u540e\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u5e76\u7528\u5f15\u53f7\u62ec\u8d77\u76ee\u5f55\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/16/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/16/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code>\u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\uff0c\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\u3002<code class=\"command\">pg_upgrade --check</code>\u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879 <code class=\"option\">--link</code> \u6216 <code class=\"option\">--clone</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code>\u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/16/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/16/warm-standby.html#STREAMING-REPLICATION\" title=\"27.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a027.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/16/warm-standby.html\" title=\"27.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a027.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/16 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_16_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c<code class=\"function\">pg_backup_start()</code>\u548c<code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u590d\u5236\u69fd\u4e0d\u4f1a\u88ab\u590d\u5236\uff0c\u5fc5\u987b\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.8\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/16/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"26.3.3.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a026.3.3\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.12.9\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/16/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/16/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/16/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/16/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/16/pgupgrade.html", "method": "same-major semantic node", "sha256": "08b1980c84f48e05b0e0f63102b4e98875cdba7dbe268adce27d9623da59c76d", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[7]/p[2]", "#PGUPGRADE/div[7]/p[3]", "#PGUPGRADE/div[7]/p[4]", "#PGUPGRADE/div[7]/p[5]", "#PGUPGRADE/div[7]/p[7]", "#PGUPGRADE/div[7]/p[8]", "#PGUPGRADE/div[8]/h2[0]"]}], "language": "zh", "original_text": {"/versions/16/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/16/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/16/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/16/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/16/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/16/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/16/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/16/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/16/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/16/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/16/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/16/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/16/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/16/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/16/tables/0/rows/16/summary": "display version information, then exit", "/versions/16/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/16/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link and --clone .)", "/versions/16/tables/0/rows/19/summary": "show help, then exit"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "6e873bc86e8446729f80d8006b99ae027e5642bcd0b131fdbbbb90263500e233"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link and --clone .)"}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": []}, "comparison_hash": "b174734c04985d171db3a5904d62a14255ad13c58bf9dca1755ab612b302a250", "manual_language": "zh"}, "17": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "22"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/17/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u548c --clone \u3002\uff09", "signature": {"url": "/docs/17/pgupgrade.html", "text": "--copy"}}, {"summary": "\u4f7f\u7528 copy_file_range \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e --clone \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002", "signature": {"url": "/docs/17/pgupgrade.html", "text": "--copy-file-range"}}, {"summary": "\u8bbe\u7f6e\u4e3a fsync \uff08\u9ed8\u8ba4\uff09\u65f6\uff0c pg_upgrade \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/17/pgupgrade.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/17/pgupgrade.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}, {"key": "environment", "rows": [{"name": "PGBINOLD", "description": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -b / --old-bindir \u3002"}, {"name": "PGBINNEW", "description": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -B / --new-bindir \u3002"}, {"name": "PGDATAOLD", "description": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -d / --old-datadir \u3002"}, {"name": "PGDATANEW", "description": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -D / --new-datadir \u3002"}, {"name": "PGPORTOLD", "description": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -p / --old-port \u3002"}, {"name": "PGPORTNEW", "description": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -P / --new-port \u3002"}, {"name": "PGSOCKETDIR", "description": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 -s / --socketdir \u3002"}, {"name": "PGUSER", "description": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 -U / --username \u3002"}], "title": "\u73af\u5883\u53d8\u91cf", "columns": [{"key": "name", "label": "\u53d8\u91cf"}, {"key": "description", "label": "\u542b\u4e49"}]}], "options": [{"names": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/17/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/17/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/17/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/17/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/17/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous processes or threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/17/pgupgrade.html", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/17/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/17/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/17/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/17/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/17/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/17/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/17/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/17/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/17/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/17/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/17/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link and --clone .)", "signature": "--copy", "source_url": "/docs/17/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link and --clone .)"}, {"names": ["--copy-file-range"], "summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "signature": "--copy-file-range", "source_url": "/docs/17/pgupgrade.html", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--sync-method="], "summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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/pgupgrade.html", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/17/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/17/postgresql-17-A4.pdf", "bytes": 15521293, "pages": 3099, "sha256": "1991354df0dc89e70ec39328c28988ef8b19c6a93671dab3893650b63e9f4e36", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/17/postgresql-17-US.pdf", "bytes": 15398150, "pages": 3270, "sha256": "07696c8f38abf31babf22d2db337093936e7c472d2af36d050b000c49bbcf52c", "built_at": "2026-09-26"}}, "tree": "17", "index": "index.html", "major": "17", "pages": 1143, "release": "17.11", "source_url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487", "evidence_kind": "English manual and source declarations", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "sources": [{"url": "https://pg.center/docs/17/pgupgrade.html", "file": "pgupgrade.html", "label": "17.11 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "a17a2afa3971d626e80f8daca4314b82d8b22055d0fc6302c809777dc14c5c55", "language": "en", "original_url": "/docs/17/pgupgrade.html"}, {"url": "https://pg.center/docs/17/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "01f07993ff020684f4c290d17cdafa26fb17ea5c1d476bc3a5efc68bf8ddd9b9", "language": "en", "original_url": "/docs/17/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.13.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\">pg_upgrade \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1<code class=\"option\">--link</code>\u548c<code class=\"option\">--clone</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy-file-range</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528 <code class=\"function\">copy_file_range</code> \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e <code class=\"option\">--clone</code> \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=</code><em class=\"replaceable\"><code>method</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u7f6e\u4e3a <code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\uff09\u65f6\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">syncfs</code>\uff0c\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u3001\u5176 WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u89c1<a class=\"xref\" href=\"/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u4e86\u89e3\u4f7f\u7528 <code class=\"literal\">syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002</p>\n<p lang=\"zh\">\u5f53\u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/17</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/17/libpq-pgpass.html\" title=\"32.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a032.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u53d1\u5e03\u8005\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p><span class=\"application\">pg_upgrade</span>\u4f1a\u5c1d\u8bd5\u8fc1\u79fb\u903b\u8f91\u590d\u5236\u69fd\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5728\u65b0\u53d1\u5e03\u8005\u4e0a\u624b\u5de5\u5b9a\u4e49\u76f8\u540c\u7684\u903b\u8f91\u590d\u5236\u69fd\u3002\u53ea\u6709\u65e7\u96c6\u7c07\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\u65f6\u624d\u652f\u6301\u8fc1\u79fb\u903b\u8f91\u590d\u5236\u69fd\u300217.0 \u4e4b\u524d\u96c6\u7c07\u4e0a\u7684\u903b\u8f91\u590d\u5236\u69fd\u4f1a\u88ab\u9759\u9ed8\u5ffd\u7565\u3002</p>\n<p>\u5f00\u59cb\u5347\u7ea7\u53d1\u5e03\u8005\u96c6\u7c07\u4e4b\u524d\uff0c\u8bf7\u6267\u884c <a class=\"link\" href=\"/docs/17/sql-altersubscription.html\" title=\"ALTER SUBSCRIPTION\"><code class=\"command\">ALTER SUBSCRIPTION ... DISABLE</code></a> \u4ee5\u786e\u4fdd\u6682\u65f6\u7981\u7528\u8ba2\u9605\u3002\u5347\u7ea7\u540e\u91cd\u65b0\u542f\u7528\u8ba2\u9605\u3002</p>\n<p>\u8981\u8ba9<span class=\"application\">pg_upgrade</span>\u80fd\u591f\u5347\u7ea7\u903b\u8f91\u590d\u5236\u69fd\uff0c\u9700\u8981\u6ee1\u8db3\u4e00\u4e9b\u5148\u51b3\u6761\u4ef6\u3002\u5982\u679c\u4e0d\u6ee1\u8db3\u8fd9\u4e9b\u6761\u4ef6\uff0c\u5c06\u62a5\u544a\u9519\u8bef\u3002</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u65b0\u96c6\u7c07\u5fc5\u987b\u5c06<a class=\"link\" href=\"/docs/17/runtime-config-wal.html#GUC-WAL-LEVEL\"><code class=\"varname\">wal_level</code></a> \u8bbe\u7f6e\u4e3a<code class=\"literal\">logical</code>\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65b0\u96c6\u7c07\u7684 <a class=\"link\" href=\"/docs/17/runtime-config-replication.html#GUC-MAX-REPLICATION-SLOTS\"><code class=\"varname\">max_replication_slots</code></a> \u914d\u7f6e\u503c\u5fc5\u987b\u5927\u4e8e\u6216\u7b49\u4e8e\u65e7\u96c6\u7c07\u4e2d\u7684\u590d\u5236\u69fd\u6570\u91cf\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65e7\u96c6\u7c07\u4e2d\u590d\u5236\u69fd\u5f15\u7528\u7684\u8f93\u51fa\u63d2\u4ef6\u5fc5\u987b\u5b89\u88c5\u5728\u65b0 PostgreSQL \u7684\u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\u4e2d\u3002\u5b83\u4eec\u8fd8\u5fc5\u987b\u5217\u5165\u65b0\u96c6\u7c07\u7684<a class=\"xref\" href=\"/docs/17/runtime-config-replication.html#GUC-OUTPUT-PLUGIN-LIBRARIES\">output_plugin_libraries</a>\uff1b\u6709\u5173\u5b89\u5168\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u8be5\u53c2\u6570\u7684\u6587\u6863\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65e7\u96c6\u7c07\u5df2\u5c06\u6240\u6709\u4e8b\u52a1\u548c\u903b\u8f91\u89e3\u7801\u6d88\u606f\u590d\u5236\u5230\u8ba2\u9605\u8005\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65e7\u96c6\u7c07\u4e0a\u7684\u6240\u6709\u590d\u5236\u69fd\u90fd\u5fc5\u987b\u53ef\u7528\uff0c\u5373\u4e0d\u5b58\u5728 <a class=\"link\" href=\"/docs/17/view-pg-replication-slots.html\" title=\"52.19.\u00a0pg_replication_slots\">pg_replication_slots</a>.<code class=\"structfield\">conflicting</code> \u4e0d\u4e3a<code class=\"literal\">true</code>\u7684\u590d\u5236\u69fd\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65b0\u96c6\u7c07\u4e0d\u5f97\u6709\u6c38\u4e45\u903b\u8f91\u590d\u5236\u69fd\uff0c\u5373\u4e0d\u5f97\u6709 <a class=\"link\" href=\"/docs/17/view-pg-replication-slots.html\" title=\"52.19.\u00a0pg_replication_slots\">pg_replication_slots</a>.<code class=\"structfield\">temporary</code> \u4e3a<code class=\"literal\">false</code>\u7684\u590d\u5236\u69fd\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u8ba2\u9605\u8005\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5728\u65b0\u8ba2\u9605\u8005\u4e0a\u8bbe\u7f6e<a class=\"link\" href=\"/docs/17/logical-replication-config.html#LOGICAL-REPLICATION-CONFIG-SUBSCRIBER\" title=\"29.11.2.\u00a0\u8ba2\u9605\u8005\">\u8ba2\u9605\u8005\u914d\u7f6e</a>\u3002<span class=\"application\">pg_upgrade</span>\u4f1a\u5c1d\u8bd5\u8fc1\u79fb\u8ba2\u9605\u4f9d\u8d56\u9879\uff0c\u5176\u4e2d\u5305\u62ec<a class=\"link\" href=\"/docs/17/catalog-pg-subscription-rel.html\" title=\"51.55.\u00a0pg_subscription_rel\">pg_subscription_rel</a>\u7cfb\u7edf\u76ee\u5f55\u4e2d\u7684\u8ba2\u9605\u8868\u4fe1\u606f\uff0c\u4ee5\u53ca\u8ba2\u9605\u7684\u590d\u5236\u6e90\u3002\u8fd9\u6837\uff0c\u65b0\u8ba2\u9605\u8005\u4e0a\u7684\u903b\u8f91\u590d\u5236\u5c31\u80fd\u4ece\u65e7\u8ba2\u9605\u8005\u505c\u6b62\u7684\u4f4d\u7f6e\u7ee7\u7eed\u3002\u53ea\u6709\u65e7\u96c6\u7c07\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\u65f6\u624d\u652f\u6301\u8fc1\u79fb\u8ba2\u9605\u4f9d\u8d56\u9879\u300217.0 \u4e4b\u524d\u96c6\u7c07\u4e0a\u7684\u8ba2\u9605\u4f9d\u8d56\u9879\u4f1a\u88ab\u9759\u9ed8\u5ffd\u7565\u3002</p>\n<p>\u8981\u8ba9<span class=\"application\">pg_upgrade</span>\u80fd\u591f\u5347\u7ea7\u8ba2\u9605\uff0c\u9700\u8981\u6ee1\u8db3\u4e00\u4e9b\u5148\u51b3\u6761\u4ef6\u3002\u5982\u679c\u4e0d\u6ee1\u8db3\u8fd9\u4e9b\u6761\u4ef6\uff0c\u5c06\u62a5\u544a\u9519\u8bef\u3002</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u65e7\u8ba2\u9605\u8005\u4e2d\u7684\u6240\u6709\u8ba2\u9605\u8868\u90fd\u5e94\u5904\u4e8e<code class=\"literal\">i</code>\uff08\u521d\u59cb\u5316\uff09\u6216<code class=\"literal\">r</code>\uff08\u5c31\u7eea\uff09\u72b6\u6001\u3002\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5<a class=\"link\" href=\"/docs/17/catalog-pg-subscription-rel.html\" title=\"51.55.\u00a0pg_subscription_rel\">pg_subscription_rel</a>.<code class=\"structfield\">srsubstate</code>\u6765\u9a8c\u8bc1\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65e7\u96c6\u7c07\u4e2d\u5e94\u5b58\u5728\u4e0e\u6bcf\u4e2a\u8ba2\u9605\u76f8\u5bf9\u5e94\u7684\u590d\u5236\u6e90\u6761\u76ee\u3002\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5<a class=\"link\" href=\"/docs/17/catalog-pg-subscription.html\" title=\"51.54.\u00a0pg_subscription\">pg_subscription</a>\u548c<a class=\"link\" href=\"/docs/17/catalog-pg-replication-origin.html\" title=\"51.44.\u00a0pg_replication_origin\">pg_replication_origin</a>\u7cfb\u7edf\u8868\u6765\u627e\u5230\u8fd9\u4e9b\u6761\u76ee\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u65b0\u96c6\u7c07\u7684<a class=\"link\" href=\"/docs/17/runtime-config-replication.html#GUC-MAX-REPLICATION-SLOTS\"><code class=\"varname\">max_replication_slots</code></a>\u914d\u7f6e\u503c\u5fc5\u987b\u5927\u4e8e\u6216\u7b49\u4e8e\u65e7\u96c6\u7c07\u4e2d\u7684\u8ba2\u9605\u6570\u91cf\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/17 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-17\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/17/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 13</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u6216\u514b\u9686\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002</p>\n<p><code class=\"option\">--jobs</code>\u9009\u9879\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a CPU \u6838\u5fc3\u590d\u5236/\u94fe\u63a5\u6587\u4ef6\uff0c\u5e76\u884c\u8f6c\u50a8\u548c\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\uff1b\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f CPU \u6838\u5fc3\u6570\u4e0e\u8868\u7a7a\u95f4\u6570\u91cf\u4e2d\u7684\u8f83\u5927\u503c\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u591a\u5904\u7406\u5668\u673a\u5668\u4e0a\u7684\u591a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>\u5bf9\u4e8e Windows \u7528\u6237\uff0c\u5fc5\u987b\u767b\u5f55\u5230\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u7136\u540e\u7ed9\u76ee\u5f55\u53c2\u6570\u52a0\u4e0a\u5f15\u53f7\uff0c\u518d\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/17/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/17/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade --check</code> \u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u6216\u514b\u9686\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06\u9009\u9879<code class=\"option\">--link</code>\u6216<code class=\"option\">--clone</code>\u4e0e<code class=\"option\">--check</code>\u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code> \u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/17/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 19</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/17/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/17/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/17 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_17_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c <code class=\"function\">pg_backup_start()</code> \u548c <code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u5982\u679c\u65e7\u4e3b\u5e93\u65e9\u4e8e 17.0\uff0c\u5219\u4e3b\u5e93\u4e0a\u7684\u4efb\u4f55\u69fd\u90fd\u4e0d\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u56e0\u6b64\u65e7\u5907\u5e93\u4e0a\u7684\u6240\u6709\u69fd\u90fd\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002\u5982\u679c\u65e7\u4e3b\u5e93\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ea\u6709\u4e3b\u5e93\u4e0a\u7684\u903b\u8f91\u69fd\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u800c\u65e7\u5907\u5e93\u4e0a\u7684\u5176\u4ed6\u69fd\u4e0d\u4f1a\u590d\u5236\uff0c\u56e0\u6b64\u4e5f\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u7531\u4e8e\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4e0d\u4f1a\u7531<code class=\"command\">pg_upgrade</code>\u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n<p>\u4f7f\u7528<code class=\"command\">vacuumdb --all --analyze-only</code>\u53ef\u4ee5\u9ad8\u6548\u751f\u6210\u8fd9\u4e9b\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f7f\u7528<code class=\"option\">--jobs</code>\u8fd8\u53ef\u4ee5\u52a0\u5feb\u901f\u5ea6\u3002\u53ef\u4ee5\u4f7f\u7528<code class=\"option\">--analyze-in-stages</code>\u9009\u9879\u5feb\u901f\u751f\u6210\u6700\u57fa\u672c\u7684\u7edf\u8ba1\u4fe1\u606f\u3002\u5982\u679c<code class=\"varname\">vacuum_cost_delay</code>\u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff0c\u53ef\u4ee5\u901a\u8fc7<code class=\"envar\">PGOPTIONS</code>\u8986\u76d6\u5b83\u6765\u52a0\u5feb\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\uff0c\u4f8b\u5982<code class=\"literal\">PGOPTIONS='-c vacuum_cost_delay=0' vacuumdb ...</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c<code class=\"option\">--link</code>\u9009\u9879<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u88ab\u4f7f\u7528\uff0c\u65e7\u96c6\u7c07\u5c31\u672a\u88ab\u4fee\u6539\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.8\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u4e3a\u547d\u4ee4\u884c\u9009\u9879\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGBINOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-b</code>/<code class=\"option\">--old-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGBINNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-B</code>/<code class=\"option\">--new-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATAOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-d</code>/<code class=\"option\">--old-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATANEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-D</code>/<code class=\"option\">--new-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-p</code>/<code class=\"option\">--old-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-P</code>/<code class=\"option\">--new-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGSOCKETDIR</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-s</code>/<code class=\"option\">--socketdir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 <code class=\"option\">-U</code>/<code class=\"option\">--username</code>\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.9\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/17/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.4\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.10\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/17/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/17/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/17/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/17/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/17/pgupgrade.html", "method": "same-major semantic node", "sha256": "3d7e7b35f091bd24e83599268762112bbb403e5de08037be94a0236e58cf0358", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[17]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[18]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[2]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[8]/h2[0]", "#PGUPGRADE/div[8]/p[1]", "#PGUPGRADE/div[8]/p[2]", "#PGUPGRADE/div[8]/p[3]", "#PGUPGRADE/div[8]/p[4]", "#PGUPGRADE/div[8]/p[5]", "#PGUPGRADE/div[8]/p[7]", "#PGUPGRADE/div[8]/p[8]", "#PGUPGRADE/div[9]/h2[0]"]}], "language": "zh", "original_text": {"/versions/17/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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/1/title": "Environment variables", "/versions/17/tables/0/rows/0/summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/17/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/17/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/17/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/17/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/17/tables/0/rows/5/summary": "number of simultaneous processes or threads to use", "/versions/17/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/17/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/17/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/17/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/17/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/17/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/17/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/17/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/17/tables/0/rows/16/summary": "display version information, then exit", "/versions/17/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/17/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link and --clone .)", "/versions/17/tables/0/rows/19/summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "/versions/17/tables/0/rows/20/summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/17/tables/0/rows/21/summary": "show help, then exit", "/versions/17/tables/1/columns/0/label": "Variable", "/versions/17/tables/1/columns/1/label": "Meaning", "/versions/17/tables/1/rows/0/description": "The old PostgreSQL executable directory; option -b / --old-bindir .", "/versions/17/tables/1/rows/1/description": "The new PostgreSQL executable directory; option -B / --new-bindir .", "/versions/17/tables/1/rows/2/description": "The old database cluster configuration directory; option -d / --old-datadir .", "/versions/17/tables/1/rows/3/description": "The new database cluster configuration directory; option -D / --new-datadir .", "/versions/17/tables/1/rows/4/description": "The old cluster port number; option -p / --old-port .", "/versions/17/tables/1/rows/5/description": "The new cluster port number; option -P / --new-port .", "/versions/17/tables/1/rows/6/description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir .", "/versions/17/tables/1/rows/7/description": "Cluster's install user name; option -U / --username ."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "2a4f8f79ea4eb7617ffa1e91495e3e7689d32a1bd91f936488eb7ba18373549d"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous processes or threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link and --clone .)"}, {"names": ["--copy-file-range"], "signature": "--copy-file-range", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--sync-method="], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}]}, "comparison_hash": "d861728c2218a6048a9c320abbe90965bd0988bbe0b9b7b5db94cfb6e0c1c3ae", "manual_language": "zh"}, "18": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "25"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u3001 --clone \u3001 --copy-file-range \u548c --swap \u3002\uff09", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--copy"}}, {"summary": "\u4f7f\u7528 copy_file_range \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e --clone \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--copy-file-range"}}, {"summary": "\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--no-statistics"}}, {"summary": "\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a signed \u548c unsigned \u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--set-char-signedness= option"}}, {"summary": "\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e --link \u3001 --clone \u3001 --copy \u548c --copy-file-range \uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--swap"}}, {"summary": "\u8bbe\u7f6e\u4e3a fsync \uff08\u9ed8\u8ba4\uff09\u65f6\uff0c pg_upgrade \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}, {"key": "environment", "rows": [{"name": "PGBINOLD", "description": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -b / --old-bindir \u3002"}, {"name": "PGBINNEW", "description": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -B / --new-bindir \u3002"}, {"name": "PGDATAOLD", "description": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -d / --old-datadir \u3002"}, {"name": "PGDATANEW", "description": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -D / --new-datadir \u3002"}, {"name": "PGPORTOLD", "description": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -p / --old-port \u3002"}, {"name": "PGPORTNEW", "description": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -P / --new-port \u3002"}, {"name": "PGSOCKETDIR", "description": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 -s / --socketdir \u3002"}, {"name": "PGUSER", "description": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 -U / --username \u3002"}], "title": "\u73af\u5883\u53d8\u91cf", "columns": [{"key": "name", "label": "\u53d8\u91cf"}, {"key": "description", "label": "\u542b\u4e49"}]}], "options": [{"names": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/18/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/18/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/18/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/18/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/18/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous connections and processes/threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/18/pgupgrade.html", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/18/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/18/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/18/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/18/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/18/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/18/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/18/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/18/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/18/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/18/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/18/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "signature": "--copy", "source_url": "/docs/18/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "signature": "--copy-file-range", "source_url": "/docs/18/pgupgrade.html", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "summary": "Do not restore statistics from the old cluster into the new cluster.", "signature": "--no-statistics", "source_url": "/docs/18/pgupgrade.html", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "signature": "--set-char-signedness= option", "source_url": "/docs/18/pgupgrade.html", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "signature": "--swap", "source_url": "/docs/18/pgupgrade.html", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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/pgupgrade.html", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/18/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "https://pg.center/docs/18/pgupgrade.html", "file": "pgupgrade.html", "label": "18.6 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "2e660b507e9708faa548f04934c0108f501d26931606e9c14dfbfbb1e5ec7917", "language": "en", "original_url": "/docs/18/pgupgrade.html"}, {"url": "https://pg.center/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3", "language": "en", "original_url": "/docs/18/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.13.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u548c <code class=\"option\">--swap</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy-file-range</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528 <code class=\"function\">copy_file_range</code> \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e <code class=\"option\">--clone</code> \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--set-char-signedness=</code><em class=\"replaceable\"><code>option</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a <code class=\"literal\">signed</code> \u548c <code class=\"literal\">unsigned</code>\u3002</p>\n<p lang=\"zh\">\u5728 C \u8bed\u8a00\u4e2d\uff0c<code class=\"type\">char</code> \u7c7b\u578b\u5728\u672a\u663e\u5f0f\u6307\u5b9a\u65f6\u7684\u9ed8\u8ba4\u6709\u7b26\u53f7\u6027\u56e0\u5e73\u53f0\u800c\u5f02\u3002\u4f8b\u5982\uff0c\u5728 x86 CPU \u4e0a <code class=\"type\">char</code> \u9ed8\u8ba4\u662f <code class=\"type\">signed char</code>\uff0c\u800c\u5728 ARM CPU \u4e0a\u9ed8\u8ba4\u662f <code class=\"type\">unsigned char</code>\u3002</p>\n<p lang=\"zh\">\u4ece <span class=\"productname\">PostgreSQL</span> 18 \u5f00\u59cb\uff0c\u6570\u636e\u5e93\u96c6\u7c07\u4f1a\u7ef4\u62a4\u81ea\u8eab\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\uff0c\u53ef\u7528\u4e8e\u786e\u4fdd\u5728\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e4b\u95f4\u4fdd\u6301\u4e00\u81f4\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<span class=\"application\">pg_upgrade</span> \u5728\u4ece\u73b0\u6709\u96c6\u7c07\u5347\u7ea7\u65f6\u4f1a\u4fdd\u7559\u8be5\u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u4ece <span class=\"productname\">PostgreSQL</span> 17 \u6216\u66f4\u65e9\u7248\u672c\u5347\u7ea7\u65f6\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u91c7\u7528\u5176\u6784\u5efa\u6240\u5728\u5e73\u53f0\u7684 char \u6709\u7b26\u53f7\u6027\u3002</p>\n<p lang=\"zh\">\u8be5\u9009\u9879\u5141\u8bb8\u4f60\u663e\u5f0f\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\uff0c\u4ee5\u8986\u76d6\u4efb\u4f55\u7ee7\u627f\u503c\u3002\u5728\u4ee5\u4e0b\u4e24\u79cd\u573a\u666f\u4e2d\u9700\u8981\u8003\u8651\u8be5\u9009\u9879\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u8ba1\u5212\u5728\u5347\u7ea7\u540e\u8fc1\u79fb\u5230\u4e0d\u540c\u5e73\u53f0\uff0c\u5219\u4e0d\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u884c\u4e3a\u624d\u662f\u6b63\u786e\u7684\u3002\u5e94\u5f53\u5148\u5728\u539f\u5e73\u53f0\u4e0a\u4e0d\u5e26\u6b64\u9009\u9879\u5b8c\u6210\u5347\u7ea7\uff0c\u7136\u540e\u518d\u8fc1\u79fb\u96c6\u7c07\u3002\u8fd9\u662f\u63a8\u8350\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u5c06\u96c6\u7c07\u8fc1\u79fb\u5230\u4e86\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff08\u4f8b\u5982\u4ece\u57fa\u4e8e x86 \u7684\u7cfb\u7edf\u8fc1\u79fb\u5230\u57fa\u4e8e ARM \u7684\u7cfb\u7edf\uff09\uff0c\u5219\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u6765\u6307\u5b9a\u4e0e\u539f\u5e73\u53f0\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u76f8\u5339\u914d\u7684\u503c\u3002\u6b64\u5916\uff0c\u4ece\u8fc1\u79fb\u6570\u636e\u6587\u4ef6\u5230\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u95f4\uff0c\u5207\u52ff\u4fee\u6539\u4efb\u4f55\u6570\u636e\u6587\u4ef6\u3002<code class=\"command\">pg_upgrade</code> \u5e94\u5f53\u662f\u65b0\u5e73\u53f0\u4e0a\u9996\u6b21\u542f\u52a8\u8be5\u96c6\u7c07\u7684\u64cd\u4f5c\u3002</p>\n</li>\n</ul>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--swap</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy</code> \u548c <code class=\"option\">--copy-file-range</code>\uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002</p>\n<p lang=\"zh\">\u4e0d\u8fc7\uff0c\u6b64\u6a21\u5f0f\u4f1a\u5728\u65e7\u96c6\u7fa4\u4e2d\u4ea7\u751f\u8bb8\u591a\u5783\u573e\u6587\u4ef6\uff1b\u5982\u679c\u4f7f\u7528 --sync-method=syncfs\uff0c\u6587\u4ef6\u540c\u6b65\u6b65\u9aa4\u53ef\u80fd\u56e0\u6b64\u53d8\u6162\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06 --swap \u4e0e --sync-method=fsync \u4e00\u8d77\u4f7f\u7528\u3002</p>\n<p lang=\"zh\">\u6b64\u5916\uff0c\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u65e7\u96c6\u7c07\u5c31\u4f1a\u88ab\u7834\u574f\u6027\u4fee\u6539\uff0c\u56e0\u6b64\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u3002\u8be6\u89c1<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=</code><em class=\"replaceable\"><code>method</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u7f6e\u4e3a <code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\uff09\u65f6\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">syncfs</code>\uff0c\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u3001\u5176 WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u89c1<a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u4e86\u89e3\u4f7f\u7528 <code class=\"literal\">syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002</p>\n<p lang=\"zh\">\u5f53\u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">\u6ce8\u610f</h3>\n<p lang=\"zh\">\u8fd9\u91cc\u4e0d\u4ecb\u7ecd\u5347\u7ea7<a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\"></a><a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\" title=\"\u903b\u8f91\u590d\u5236\u96c6\u7fa4\">\u903b\u8f91\u590d\u5236\u96c6\u7fa4</a>\u7684\u6b65\u9aa4\uff1b\u8be6\u89c1<a class=\"xref\" href=\"/docs/18/logical-replication-upgrade.html\" title=\"29.13.\u00a0\u5347\u7ea7\">\u7b2c\u00a029.13\u00a0\u8282</a>\u3002</p>\n</div>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/18</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a032.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/18 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-18\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u3001\u514b\u9686\u6216\u4ea4\u6362\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002\u5982\u679c\u5173\u7cfb\u5f88\u591a\uff0c\u4ea4\u6362\u6a21\u5f0f\u53ef\u80fd\u6700\u5feb\uff0c\u4f46\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u4f60\u5c06\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u4ea4\u6362\u6a21\u5f0f\u4e5f\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002</p>\n<p>\u5c06 <code class=\"option\">--jobs</code> \u8bbe\u7f6e\u4e3a 2 \u6216\u66f4\u9ad8\u53ef\u4ee5\u8ba9 pg_upgrade \u5e76\u884c\u5904\u7406\u591a\u4e2a\u6570\u636e\u5e93\u548c\u8868\u7a7a\u95f4\u3002\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u5bf9\u4e8e\u591a\u6570\u636e\u5e93\u3001\u591a\u8868\u7a7a\u95f4\u7684\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>\u5bf9\u4e8e Windows \u7528\u6237\uff0c\u5fc5\u987b\u767b\u5f55\u5230\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u7136\u540e\u7ed9\u76ee\u5f55\u53c2\u6570\u52a0\u4e0a\u5f15\u53f7\uff0c\u518d\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/18/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/18/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade --check</code> \u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u3001\u514b\u9686\u3001copy-file-range \u6216\u4ea4\u6362\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u6216 <code class=\"option\">--swap</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code> \u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/18/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/18/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/18 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_18_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c <code class=\"function\">pg_backup_start()</code> \u548c <code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u5982\u679c\u65e7\u4e3b\u5e93\u65e9\u4e8e 17.0\uff0c\u5219\u4e3b\u5e93\u4e0a\u7684\u4efb\u4f55\u69fd\u90fd\u4e0d\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u56e0\u6b64\u65e7\u5907\u5e93\u4e0a\u7684\u6240\u6709\u69fd\u90fd\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002\u5982\u679c\u65e7\u4e3b\u5e93\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ea\u6709\u4e3b\u5e93\u4e0a\u7684\u903b\u8f91\u69fd\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u800c\u65e7\u5907\u5e93\u4e0a\u7684\u5176\u4ed6\u69fd\u4e0d\u4f1a\u590d\u5236\uff0c\u56e0\u6b64\u4e5f\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u9664\u975e\u6307\u5b9a <code class=\"option\">--no-statistics</code>\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u5c06\u5927\u591a\u6570\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4ece\u65e7\u96c6\u7c07\u4f20\u8f93\u5230\u65b0\u96c6\u7c07\u3002\u4f46\u8fd9\u4e0d\u4f1a\u4f20\u8f93\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f8b\u5982\u901a\u8fc7<a class=\"xref\" href=\"/docs/18/sql-createstatistics.html\" title=\"CREATE STATISTICS\"><span class=\"refentrytitle\">CREATE STATISTICS</span></a>\u663e\u5f0f\u521b\u5efa\u7684\u7edf\u8ba1\u4fe1\u606f\u3001\u6269\u5c55\u6dfb\u52a0\u7684\u81ea\u5b9a\u4e49\u7edf\u8ba1\u4fe1\u606f\uff0c\u6216\u7531\u7d2f\u79ef\u7edf\u8ba1\u7cfb\u7edf\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002</p>\n<p>\u7531\u4e8e\u5e76\u975e\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\u90fd\u4f1a\u7531 <code class=\"command\">pg_upgrade</code> \u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-in-stages --missing-stats-only</code> \u4e3a\u5c1a\u65e0\u7edf\u8ba1\u4fe1\u606f\u7684\u5173\u7cfb\u5feb\u901f\u751f\u6210\u6700\u57fa\u672c\u7684\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-only</code> \u4ee5\u786e\u4fdd\u6240\u6709\u5173\u7cfb\u90fd\u62e5\u6709\u6700\u65b0\u7684\u7d2f\u79ef\u7edf\u8ba1\u4fe1\u606f\uff0c\u7528\u4e8e\u89e6\u53d1 vacuum \u548c analyze\u3002\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff0c\u4f7f\u7528 <code class=\"option\">--jobs</code> \u90fd\u53ef\u4ee5\u52a0\u5feb\u901f\u5ea6\u3002\u5982\u679c <code class=\"varname\">vacuum_cost_delay</code> \u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff0c\u53ef\u4ee5\u901a\u8fc7 <code class=\"envar\">PGOPTIONS</code> \u8986\u76d6\u5b83\u6765\u52a0\u5feb\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\uff0c\u4f8b\u5982 <code class=\"literal\">PGOPTIONS='-c vacuum_cost_delay=0' vacuumdb ...</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u65e2\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--link</code>\uff0c\u4e5f\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--swap</code>\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--swap</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u53ef\u80fd\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u4e4b\u524d\u4e2d\u6b62\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5df2\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\uff0c\u5219\u65e7\u96c6\u7c07\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.8\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u4e3a\u547d\u4ee4\u884c\u9009\u9879\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGBINOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-b</code>/<code class=\"option\">--old-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGBINNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-B</code>/<code class=\"option\">--new-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATAOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-d</code>/<code class=\"option\">--old-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATANEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-D</code>/<code class=\"option\">--new-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-p</code>/<code class=\"option\">--old-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-P</code>/<code class=\"option\">--new-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGSOCKETDIR</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-s</code>/<code class=\"option\">--socketdir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 <code class=\"option\">-U</code>/<code class=\"option\">--username</code>\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.9\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.4\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.10\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/18/pgupgrade.html", "method": "same-major semantic node", "sha256": "453b23176fbf9a379c9763866fbeb98542dd17b4d315dec77a3ad0197edb11eb", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[49]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/h3[0]", "#PGUPGRADE/div[6]/div[2]/p[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[8]/h2[0]", "#PGUPGRADE/div[8]/p[1]", "#PGUPGRADE/div[8]/p[2]", "#PGUPGRADE/div[8]/p[3]", "#PGUPGRADE/div[8]/p[4]", "#PGUPGRADE/div[8]/p[5]", "#PGUPGRADE/div[8]/p[7]", "#PGUPGRADE/div[8]/p[8]", "#PGUPGRADE/div[9]/h2[0]"]}], "language": "zh", "original_text": {"/versions/18/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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/1/title": "Environment variables", "/versions/18/tables/0/rows/0/summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/18/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/18/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/18/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/18/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/18/tables/0/rows/5/summary": "number of simultaneous connections and processes/threads to use", "/versions/18/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/18/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/18/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/18/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/18/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/18/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/18/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/18/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/18/tables/0/rows/16/summary": "display version information, then exit", "/versions/18/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/18/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "/versions/18/tables/0/rows/19/summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "/versions/18/tables/0/rows/20/summary": "Do not restore statistics from the old cluster into the new cluster.", "/versions/18/tables/0/rows/21/summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "/versions/18/tables/0/rows/22/summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "/versions/18/tables/0/rows/23/summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/18/tables/0/rows/24/summary": "show help, then exit", "/versions/18/tables/1/columns/0/label": "Variable", "/versions/18/tables/1/columns/1/label": "Meaning", "/versions/18/tables/1/rows/0/description": "The old PostgreSQL executable directory; option -b / --old-bindir .", "/versions/18/tables/1/rows/1/description": "The new PostgreSQL executable directory; option -B / --new-bindir .", "/versions/18/tables/1/rows/2/description": "The old database cluster configuration directory; option -d / --old-datadir .", "/versions/18/tables/1/rows/3/description": "The new database cluster configuration directory; option -D / --new-datadir .", "/versions/18/tables/1/rows/4/description": "The old cluster port number; option -p / --old-port .", "/versions/18/tables/1/rows/5/description": "The new cluster port number; option -P / --new-port .", "/versions/18/tables/1/rows/6/description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir .", "/versions/18/tables/1/rows/7/description": "Cluster's install user name; option -U / --username ."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "589d6202e3155f69fc4b7a8185a73def2535f63c2ea5ec3eff1c60d2319d0546"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "signature": "--copy-file-range", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "signature": "--set-char-signedness= option", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "signature": "--swap", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}]}, "comparison_hash": "ed8c09156ba62bb3138b603b905750e0ebd88baadd61089e3fe1a1e8186934e5", "manual_language": "zh"}, "19": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"label": "\u7a0b\u5e8f\u7248\u672c", "value": "19beta4"}, {"label": "\u53c2\u8003\u6e05\u5355", "value": "\u670d\u52a1\u7aef\u7a0b\u5e8f"}, {"label": "\u9009\u9879\u5b9a\u4e49\u7ec4", "value": "25"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u3001 --clone \u3001 --copy-file-range \u548c --swap \u3002\uff09", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--copy"}}, {"summary": "\u4f7f\u7528 copy_file_range \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e --clone \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--copy-file-range"}}, {"summary": "\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--no-statistics"}}, {"summary": "\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a signed \u548c unsigned \u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--set-char-signedness= option"}}, {"summary": "\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e --link \u3001 --clone \u3001 --copy \u548c --copy-file-range \uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--swap"}}, {"summary": "\u8bbe\u7f6e\u4e3a fsync \uff08\u9ed8\u8ba4\uff09\u65f6\uff0c pg_upgrade \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/19/pgupgrade.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/19/pgupgrade.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}, {"key": "environment", "rows": [{"name": "PGBINOLD", "description": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -b / --old-bindir \u3002"}, {"name": "PGBINNEW", "description": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -B / --new-bindir \u3002"}, {"name": "PGDATAOLD", "description": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -d / --old-datadir \u3002"}, {"name": "PGDATANEW", "description": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -D / --new-datadir \u3002"}, {"name": "PGPORTOLD", "description": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -p / --old-port \u3002"}, {"name": "PGPORTNEW", "description": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -P / --new-port \u3002"}, {"name": "PGSOCKETDIR", "description": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 -s / --socketdir \u3002"}, {"name": "PGUSER", "description": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 -U / --username \u3002"}], "title": "\u73af\u5883\u53d8\u91cf", "columns": [{"key": "name", "label": "\u53d8\u91cf"}, {"key": "description", "label": "\u542b\u4e49"}]}], "options": [{"names": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/19/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/19/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/19/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/19/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/19/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous connections and processes/threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/19/pgupgrade.html", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/19/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/19/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/19/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/19/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/19/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/19/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/19/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/19/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/19/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/19/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/19/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "signature": "--copy", "source_url": "/docs/19/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "signature": "--copy-file-range", "source_url": "/docs/19/pgupgrade.html", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "summary": "Do not restore statistics from the old cluster into the new cluster.", "signature": "--no-statistics", "source_url": "/docs/19/pgupgrade.html", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "signature": "--set-char-signedness= option", "source_url": "/docs/19/pgupgrade.html", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "signature": "--swap", "source_url": "/docs/19/pgupgrade.html", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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/pgupgrade.html", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/19/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/19/postgresql-19-A4.pdf", "bytes": 16064841, "pages": 3052, "sha256": "4dd099e4125c591128fc5f3ebd02178dc24781f9e5ae629f96d67c4c8547427b", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/19/postgresql-19-US.pdf", "bytes": 15974616, "pages": 3225, "sha256": "61971fa857f0956d47341a0388fa6af9ae10acf691d4b2fc009007d384b0342b", "built_at": "2026-09-26"}}, "tree": "19", "index": "index.html", "major": "19", "pages": 1155, "release": "19beta4", "source_url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "svg_assets": 5, "source_mode": "en SGML built with pinned official archive", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833", "evidence_kind": "English manual and source declarations", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "sources": [{"url": "https://pg.center/docs/19/pgupgrade.html", "file": "pgupgrade.html", "label": "19beta4 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "a7a3b7084fbcfdd209127947e1eee779d527b145f7e4371a022790e015a0e8c0", "language": "en", "original_url": "/docs/19/pgupgrade.html"}, {"url": "https://pg.center/docs/19/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "425b070323b448b5516d2cb4e9e4ac77efb5d19dd4e8005d0ae1c61db9ec78e6", "language": "en", "original_url": "/docs/19/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.13.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u548c <code class=\"option\">--swap</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy-file-range</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528 <code class=\"function\">copy_file_range</code> \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e <code class=\"option\">--clone</code> \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--set-char-signedness=</code><em class=\"replaceable\"><code>option</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a <code class=\"literal\">signed</code> \u548c <code class=\"literal\">unsigned</code>\u3002</p>\n<p lang=\"zh\">\u5728 C \u8bed\u8a00\u4e2d\uff0c<code class=\"type\">char</code> \u7c7b\u578b\u5728\u672a\u663e\u5f0f\u6307\u5b9a\u65f6\u7684\u9ed8\u8ba4\u6709\u7b26\u53f7\u6027\u56e0\u5e73\u53f0\u800c\u5f02\u3002\u4f8b\u5982\uff0c\u5728 x86 CPU \u4e0a <code class=\"type\">char</code> \u9ed8\u8ba4\u662f <code class=\"type\">signed char</code>\uff0c\u800c\u5728 ARM CPU \u4e0a\u9ed8\u8ba4\u662f <code class=\"type\">unsigned char</code>\u3002</p>\n<p lang=\"zh\">\u4ece <span class=\"productname\">PostgreSQL</span> 18 \u5f00\u59cb\uff0c\u6570\u636e\u5e93\u96c6\u7c07\u4f1a\u7ef4\u62a4\u81ea\u8eab\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\uff0c\u53ef\u7528\u4e8e\u786e\u4fdd\u5728\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e4b\u95f4\u4fdd\u6301\u4e00\u81f4\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<span class=\"application\">pg_upgrade</span> \u5728\u4ece\u73b0\u6709\u96c6\u7c07\u5347\u7ea7\u65f6\u4f1a\u4fdd\u7559\u8be5\u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u4ece <span class=\"productname\">PostgreSQL</span> 17 \u6216\u66f4\u65e9\u7248\u672c\u5347\u7ea7\u65f6\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u91c7\u7528\u5176\u6784\u5efa\u6240\u5728\u5e73\u53f0\u7684 char \u6709\u7b26\u53f7\u6027\u3002</p>\n<p lang=\"zh\">\u8be5\u9009\u9879\u5141\u8bb8\u4f60\u663e\u5f0f\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\uff0c\u4ee5\u8986\u76d6\u4efb\u4f55\u7ee7\u627f\u503c\u3002\u5728\u4ee5\u4e0b\u4e24\u79cd\u573a\u666f\u4e2d\u9700\u8981\u8003\u8651\u8be5\u9009\u9879\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u8ba1\u5212\u5728\u5347\u7ea7\u540e\u8fc1\u79fb\u5230\u4e0d\u540c\u5e73\u53f0\uff0c\u5219\u4e0d\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u884c\u4e3a\u624d\u662f\u6b63\u786e\u7684\u3002\u5e94\u5f53\u5148\u5728\u539f\u5e73\u53f0\u4e0a\u4e0d\u5e26\u6b64\u9009\u9879\u5b8c\u6210\u5347\u7ea7\uff0c\u7136\u540e\u518d\u8fc1\u79fb\u96c6\u7c07\u3002\u8fd9\u662f\u63a8\u8350\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u5c06\u96c6\u7c07\u8fc1\u79fb\u5230\u4e86\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff08\u4f8b\u5982\u4ece\u57fa\u4e8e x86 \u7684\u7cfb\u7edf\u8fc1\u79fb\u5230\u57fa\u4e8e ARM \u7684\u7cfb\u7edf\uff09\uff0c\u5219\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u6765\u6307\u5b9a\u4e0e\u539f\u5e73\u53f0\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u76f8\u5339\u914d\u7684\u503c\u3002\u6b64\u5916\uff0c\u4ece\u8fc1\u79fb\u6570\u636e\u6587\u4ef6\u5230\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u95f4\uff0c\u5207\u52ff\u4fee\u6539\u4efb\u4f55\u6570\u636e\u6587\u4ef6\u3002<code class=\"command\">pg_upgrade</code> \u5e94\u5f53\u662f\u65b0\u5e73\u53f0\u4e0a\u9996\u6b21\u542f\u52a8\u8be5\u96c6\u7c07\u7684\u64cd\u4f5c\u3002</p>\n</li>\n</ul>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--swap</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy</code> \u548c <code class=\"option\">--copy-file-range</code>\uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002</p>\n<p lang=\"zh\">\u4e0d\u8fc7\uff0c\u6b64\u6a21\u5f0f\u4f1a\u5728\u65e7\u96c6\u7fa4\u4e2d\u4ea7\u751f\u8bb8\u591a\u5783\u573e\u6587\u4ef6\uff1b\u5982\u679c\u4f7f\u7528 --sync-method=syncfs\uff0c\u6587\u4ef6\u540c\u6b65\u6b65\u9aa4\u53ef\u80fd\u56e0\u6b64\u53d8\u6162\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06 --swap \u4e0e --sync-method=fsync \u4e00\u8d77\u4f7f\u7528\u3002</p>\n<p lang=\"zh\">\u6b64\u5916\uff0c\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u65e7\u96c6\u7c07\u5c31\u4f1a\u88ab\u7834\u574f\u6027\u4fee\u6539\uff0c\u56e0\u6b64\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u3002\u8be6\u89c1<a class=\"xref\" href=\"/docs/19/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=</code><em class=\"replaceable\"><code>method</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u7f6e\u4e3a <code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\uff09\u65f6\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">syncfs</code>\uff0c\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u3001\u5176 WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u89c1<a class=\"xref\" href=\"/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u4e86\u89e3\u4f7f\u7528 <code class=\"literal\">syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002</p>\n<p lang=\"zh\">\u5f53\u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">\u6ce8\u610f</h3>\n<p lang=\"zh\">\u8fd9\u91cc\u4e0d\u4ecb\u7ecd\u5347\u7ea7<a class=\"glossterm\" href=\"/docs/19/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\"></a><a class=\"glossterm\" href=\"/docs/19/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\" title=\"\u903b\u8f91\u590d\u5236\u96c6\u7fa4\">\u903b\u8f91\u590d\u5236\u96c6\u7fa4</a>\u7684\u6b65\u9aa4\uff1b\u8be6\u89c1<a class=\"xref\" href=\"/docs/19/logical-replication-upgrade.html\" title=\"29.14.\u00a0\u5347\u7ea7\">\u7b2c\u00a029.14\u00a0\u8282</a>\u3002</p>\n</div>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/19</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/19/libpq-pgpass.html\" title=\"32.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a032.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/19 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-19\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/19/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u3001\u514b\u9686\u6216\u4ea4\u6362\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002\u5982\u679c\u5173\u7cfb\u5f88\u591a\uff0c\u4ea4\u6362\u6a21\u5f0f\u53ef\u80fd\u6700\u5feb\uff0c\u4f46\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u4f60\u5c06\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u4ea4\u6362\u6a21\u5f0f\u4e5f\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002</p>\n<p>\u5c06 <code class=\"option\">--jobs</code> \u8bbe\u7f6e\u4e3a 2 \u6216\u66f4\u9ad8\u53ef\u4ee5\u8ba9 pg_upgrade \u5e76\u884c\u5904\u7406\u591a\u4e2a\u6570\u636e\u5e93\u548c\u8868\u7a7a\u95f4\u3002\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u5bf9\u4e8e\u591a\u6570\u636e\u5e93\u3001\u591a\u8868\u7a7a\u95f4\u7684\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>\u5bf9\u4e8e Windows \u7528\u6237\uff0c\u5fc5\u987b\u767b\u5f55\u5230\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u7136\u540e\u7ed9\u76ee\u5f55\u53c2\u6570\u52a0\u4e0a\u5f15\u53f7\uff0c\u518d\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/19/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/19/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade --check</code> \u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u3001\u514b\u9686\u3001copy-file-range \u6216\u4ea4\u6362\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u6216 <code class=\"option\">--swap</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code> \u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/19/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/19/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/19/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/19 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_19_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c <code class=\"function\">pg_backup_start()</code> \u548c <code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u5982\u679c\u65e7\u4e3b\u5e93\u65e9\u4e8e 17.0\uff0c\u5219\u4e3b\u5e93\u4e0a\u7684\u4efb\u4f55\u69fd\u90fd\u4e0d\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u56e0\u6b64\u65e7\u5907\u5e93\u4e0a\u7684\u6240\u6709\u69fd\u90fd\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002\u5982\u679c\u65e7\u4e3b\u5e93\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ea\u6709\u4e3b\u5e93\u4e0a\u7684\u903b\u8f91\u69fd\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u800c\u65e7\u5907\u5e93\u4e0a\u7684\u5176\u4ed6\u69fd\u4e0d\u4f1a\u590d\u5236\uff0c\u56e0\u6b64\u4e5f\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u9664\u975e\u6307\u5b9a <code class=\"option\">--no-statistics</code>\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u5c06\u5927\u591a\u6570\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4ece\u65e7\u96c6\u7c07\u4f20\u8f93\u5230\u65b0\u96c6\u7c07\u3002\u4f46\u8fd9\u4e0d\u4f1a\u4f20\u8f93\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f8b\u5982\u6269\u5c55\u6dfb\u52a0\u7684\u81ea\u5b9a\u4e49\u7edf\u8ba1\u4fe1\u606f\uff0c\u6216\u7531\u7d2f\u79ef\u7edf\u8ba1\u7cfb\u7edf\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002</p>\n<p>\u7531\u4e8e\u5e76\u975e\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\u90fd\u4f1a\u7531 <code class=\"command\">pg_upgrade</code> \u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-in-stages --missing-stats-only</code> \u4e3a\u5c1a\u65e0\u7edf\u8ba1\u4fe1\u606f\u7684\u5173\u7cfb\u5feb\u901f\u751f\u6210\u6700\u57fa\u672c\u7684\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-only</code> \u4ee5\u786e\u4fdd\u6240\u6709\u5173\u7cfb\u90fd\u62e5\u6709\u6700\u65b0\u7684\u7d2f\u79ef\u7edf\u8ba1\u4fe1\u606f\uff0c\u7528\u4e8e\u89e6\u53d1 vacuum \u548c analyze\u3002\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff0c\u4f7f\u7528 <code class=\"option\">--jobs</code> \u90fd\u53ef\u4ee5\u52a0\u5feb\u901f\u5ea6\u3002\u5982\u679c <code class=\"varname\">vacuum_cost_delay</code> \u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff0c\u53ef\u4ee5\u901a\u8fc7 <code class=\"envar\">PGOPTIONS</code> \u8986\u76d6\u5b83\u6765\u52a0\u5feb\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\uff0c\u4f8b\u5982 <code class=\"literal\">PGOPTIONS='-c vacuum_cost_delay=0' vacuumdb ...</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u65e2\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--link</code>\uff0c\u4e5f\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--swap</code>\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--swap</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u53ef\u80fd\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u4e4b\u524d\u4e2d\u6b62\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5df2\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\uff0c\u5219\u65e7\u96c6\u7c07\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.8\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u4e3a\u547d\u4ee4\u884c\u9009\u9879\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGBINOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-b</code>/<code class=\"option\">--old-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGBINNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-B</code>/<code class=\"option\">--new-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATAOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-d</code>/<code class=\"option\">--old-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATANEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-D</code>/<code class=\"option\">--new-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-p</code>/<code class=\"option\">--old-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-P</code>/<code class=\"option\">--new-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGSOCKETDIR</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-s</code>/<code class=\"option\">--socketdir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 <code class=\"option\">-U</code>/<code class=\"option\">--username</code>\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.9\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regdatabase</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/19/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.4\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.10\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/19/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/19/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/19/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/19/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/19/pgupgrade.html", "method": "same-major semantic node", "sha256": "56e3b71fe1d1b24694df8693ba3542a2d4487f12031d434f45c53ddf3ab9063c", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[49]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/h3[0]", "#PGUPGRADE/div[6]/div[2]/p[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[8]/h2[0]", "#PGUPGRADE/div[8]/p[1]", "#PGUPGRADE/div[8]/p[2]", "#PGUPGRADE/div[8]/p[3]", "#PGUPGRADE/div[8]/p[4]", "#PGUPGRADE/div[8]/p[5]", "#PGUPGRADE/div[8]/p[7]", "#PGUPGRADE/div[8]/p[8]", "#PGUPGRADE/div[9]/h2[0]"]}], "language": "zh", "original_text": {"/versions/19/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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/1/title": "Environment variables", "/versions/19/tables/0/rows/0/summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/19/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/19/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/19/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/19/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/19/tables/0/rows/5/summary": "number of simultaneous connections and processes/threads to use", "/versions/19/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/19/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/19/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/19/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/19/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/19/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/19/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/19/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/19/tables/0/rows/16/summary": "display version information, then exit", "/versions/19/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/19/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "/versions/19/tables/0/rows/19/summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "/versions/19/tables/0/rows/20/summary": "Do not restore statistics from the old cluster into the new cluster.", "/versions/19/tables/0/rows/21/summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "/versions/19/tables/0/rows/22/summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "/versions/19/tables/0/rows/23/summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/19/tables/0/rows/24/summary": "show help, then exit", "/versions/19/tables/1/columns/0/label": "Variable", "/versions/19/tables/1/columns/1/label": "Meaning", "/versions/19/tables/1/rows/0/description": "The old PostgreSQL executable directory; option -b / --old-bindir .", "/versions/19/tables/1/rows/1/description": "The new PostgreSQL executable directory; option -B / --new-bindir .", "/versions/19/tables/1/rows/2/description": "The old database cluster configuration directory; option -d / --old-datadir .", "/versions/19/tables/1/rows/3/description": "The new database cluster configuration directory; option -D / --new-datadir .", "/versions/19/tables/1/rows/4/description": "The old cluster port number; option -p / --old-port .", "/versions/19/tables/1/rows/5/description": "The new cluster port number; option -P / --new-port .", "/versions/19/tables/1/rows/6/description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir .", "/versions/19/tables/1/rows/7/description": "Cluster's install user name; option -U / --username ."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "513340ac32e8a156125c3e8998b55fddd41780ca2da37ad75c0dd3c8a21c68d2"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "signature": "--copy-file-range", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "signature": "--set-char-signedness= option", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "signature": "--swap", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}]}, "comparison_hash": "ed8c09156ba62bb3138b603b905750e0ebd88baadd61089e3fe1a1e8186934e5", "manual_language": "zh"}, "20": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "25"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u3001 --clone \u3001 --copy-file-range \u548c --swap \u3002\uff09", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--copy"}}, {"summary": "\u4f7f\u7528 copy_file_range \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e --clone \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--copy-file-range"}}, {"summary": "\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--no-statistics"}}, {"summary": "\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a signed \u548c unsigned \u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--set-char-signedness= option"}}, {"summary": "\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e --link \u3001 --clone \u3001 --copy \u548c --copy-file-range \uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--swap"}}, {"summary": "\u8bbe\u7f6e\u4e3a fsync \uff08\u9ed8\u8ba4\uff09\u65f6\uff0c pg_upgrade \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/devel/pgupgrade.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}, {"key": "environment", "rows": [{"name": "PGBINOLD", "description": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -b / --old-bindir \u3002"}, {"name": "PGBINNEW", "description": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -B / --new-bindir \u3002"}, {"name": "PGDATAOLD", "description": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -d / --old-datadir \u3002"}, {"name": "PGDATANEW", "description": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -D / --new-datadir \u3002"}, {"name": "PGPORTOLD", "description": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -p / --old-port \u3002"}, {"name": "PGPORTNEW", "description": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -P / --new-port \u3002"}, {"name": "PGSOCKETDIR", "description": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 -s / --socketdir \u3002"}, {"name": "PGUSER", "description": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 -U / --username \u3002"}], "title": "\u73af\u5883\u53d8\u91cf", "columns": [{"key": "name", "label": "\u53d8\u91cf"}, {"key": "description", "label": "\u542b\u4e49"}]}], "options": [{"names": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/devel/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/devel/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/devel/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/devel/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/devel/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous connections and processes/threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/devel/pgupgrade.html", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/devel/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/devel/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/devel/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/devel/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/devel/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/devel/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/devel/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/devel/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/devel/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/devel/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/devel/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "signature": "--copy", "source_url": "/docs/devel/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "signature": "--copy-file-range", "source_url": "/docs/devel/pgupgrade.html", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "summary": "Do not restore statistics from the old cluster into the new cluster.", "signature": "--no-statistics", "source_url": "/docs/devel/pgupgrade.html", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "signature": "--set-char-signedness= option", "source_url": "/docs/devel/pgupgrade.html", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "signature": "--swap", "source_url": "/docs/devel/pgupgrade.html", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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/pgupgrade.html", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/devel/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/20/postgresql-20-A4.pdf", "bytes": 16030631, "pages": 3052, "sha256": "bd5d82c0ce38fc18f92a0447818a91a193a261776bca1c37564bf9a683e177d0", "built_at": "2026-09-28"}, "US": {"url": "/files/documentation/pdf/20/postgresql-20-US.pdf", "bytes": 15936613, "pages": 3223, "sha256": "d97d9e0db479a02f4234b175f50fcad70c3661619afc8d6df9b9437882e3c299", "built_at": "2026-09-28"}}, "tree": "0", "index": "index.html", "major": "20", "pages": 1156, "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "svg_assets": 6, "source_mode": "en SGML built with pinned official archive", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_snapshot_utc": "26-Sep-2026 20:22"}, "revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918", "evidence_kind": "English manual and source declarations", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, "sources": [{"url": "https://pg.center/docs/devel/pgupgrade.html", "file": "pgupgrade.html", "label": "20devel English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "5590819f78af0489e8b710823b4890629e05ec1eb8f15cbe5fca6aaad7ff7bf0", "language": "en", "original_url": "/docs/devel/pgupgrade.html"}, {"url": "https://pg.center/docs/devel/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "5532c1ebfb8c6f310301be63a28daf0ae212e2a78025bea61a1bdca99e02c43d", "language": "en", "original_url": "/docs/devel/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.13.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u652f\u6301\u4ece 10.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d <span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u548c <code class=\"option\">--swap</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy-file-range</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528 <code class=\"function\">copy_file_range</code> \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e <code class=\"option\">--clone</code> \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--set-char-signedness=</code><em class=\"replaceable\"><code>option</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a <code class=\"literal\">signed</code> \u548c <code class=\"literal\">unsigned</code>\u3002</p>\n<p lang=\"zh\">\u5728 C \u8bed\u8a00\u4e2d\uff0c<code class=\"type\">char</code> \u7c7b\u578b\u5728\u672a\u663e\u5f0f\u6307\u5b9a\u65f6\u7684\u9ed8\u8ba4\u6709\u7b26\u53f7\u6027\u56e0\u5e73\u53f0\u800c\u5f02\u3002\u4f8b\u5982\uff0c\u5728 x86 CPU \u4e0a <code class=\"type\">char</code> \u9ed8\u8ba4\u662f <code class=\"type\">signed char</code>\uff0c\u800c\u5728 ARM CPU \u4e0a\u9ed8\u8ba4\u662f <code class=\"type\">unsigned char</code>\u3002</p>\n<p lang=\"zh\">\u4ece <span class=\"productname\">PostgreSQL</span> 18 \u5f00\u59cb\uff0c\u6570\u636e\u5e93\u96c6\u7c07\u4f1a\u7ef4\u62a4\u81ea\u8eab\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\uff0c\u53ef\u7528\u4e8e\u786e\u4fdd\u5728\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e4b\u95f4\u4fdd\u6301\u4e00\u81f4\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<span class=\"application\">pg_upgrade</span> \u5728\u4ece\u73b0\u6709\u96c6\u7c07\u5347\u7ea7\u65f6\u4f1a\u4fdd\u7559\u8be5\u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u4ece <span class=\"productname\">PostgreSQL</span> 17 \u6216\u66f4\u65e9\u7248\u672c\u5347\u7ea7\u65f6\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u91c7\u7528\u5176\u6784\u5efa\u6240\u5728\u5e73\u53f0\u7684 char \u6709\u7b26\u53f7\u6027\u3002</p>\n<p lang=\"zh\">\u8be5\u9009\u9879\u5141\u8bb8\u4f60\u663e\u5f0f\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\uff0c\u4ee5\u8986\u76d6\u4efb\u4f55\u7ee7\u627f\u503c\u3002\u5728\u4ee5\u4e0b\u4e24\u79cd\u573a\u666f\u4e2d\u9700\u8981\u8003\u8651\u8be5\u9009\u9879\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u8ba1\u5212\u5728\u5347\u7ea7\u540e\u8fc1\u79fb\u5230\u4e0d\u540c\u5e73\u53f0\uff0c\u5219\u4e0d\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u884c\u4e3a\u624d\u662f\u6b63\u786e\u7684\u3002\u5e94\u5f53\u5148\u5728\u539f\u5e73\u53f0\u4e0a\u4e0d\u5e26\u6b64\u9009\u9879\u5b8c\u6210\u5347\u7ea7\uff0c\u7136\u540e\u518d\u8fc1\u79fb\u96c6\u7c07\u3002\u8fd9\u662f\u63a8\u8350\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u5c06\u96c6\u7c07\u8fc1\u79fb\u5230\u4e86\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff08\u4f8b\u5982\u4ece\u57fa\u4e8e x86 \u7684\u7cfb\u7edf\u8fc1\u79fb\u5230\u57fa\u4e8e ARM \u7684\u7cfb\u7edf\uff09\uff0c\u5219\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u6765\u6307\u5b9a\u4e0e\u539f\u5e73\u53f0\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u76f8\u5339\u914d\u7684\u503c\u3002\u6b64\u5916\uff0c\u4ece\u8fc1\u79fb\u6570\u636e\u6587\u4ef6\u5230\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u95f4\uff0c\u5207\u52ff\u4fee\u6539\u4efb\u4f55\u6570\u636e\u6587\u4ef6\u3002<code class=\"command\">pg_upgrade</code> \u5e94\u5f53\u662f\u65b0\u5e73\u53f0\u4e0a\u9996\u6b21\u542f\u52a8\u8be5\u96c6\u7c07\u7684\u64cd\u4f5c\u3002</p>\n</li>\n</ul>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--swap</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy</code> \u548c <code class=\"option\">--copy-file-range</code>\uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002</p>\n<p lang=\"zh\">\u4e0d\u8fc7\uff0c\u6b64\u6a21\u5f0f\u4f1a\u5728\u65e7\u96c6\u7fa4\u4e2d\u4ea7\u751f\u8bb8\u591a\u5783\u573e\u6587\u4ef6\uff1b\u5982\u679c\u4f7f\u7528 --sync-method=syncfs\uff0c\u6587\u4ef6\u540c\u6b65\u6b65\u9aa4\u53ef\u80fd\u56e0\u6b64\u53d8\u6162\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06 --swap \u4e0e --sync-method=fsync \u4e00\u8d77\u4f7f\u7528\u3002</p>\n<p lang=\"zh\">\u6b64\u5916\uff0c\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u65e7\u96c6\u7c07\u5c31\u4f1a\u88ab\u7834\u574f\u6027\u4fee\u6539\uff0c\u56e0\u6b64\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u3002\u8be6\u89c1<a class=\"xref\" href=\"/docs/devel/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=</code><em class=\"replaceable\"><code>method</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u7f6e\u4e3a <code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\uff09\u65f6\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">syncfs</code>\uff0c\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u3001\u5176 WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u89c1<a class=\"xref\" href=\"/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u4e86\u89e3\u4f7f\u7528 <code class=\"literal\">syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002</p>\n<p lang=\"zh\">\u5f53\u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">\u6ce8\u610f</h3>\n<p lang=\"zh\">\u8fd9\u91cc\u4e0d\u4ecb\u7ecd\u5347\u7ea7<a class=\"glossterm\" href=\"/docs/devel/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\"></a><a class=\"glossterm\" href=\"/docs/devel/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\" title=\"\u903b\u8f91\u590d\u5236\u96c6\u7fa4\">\u903b\u8f91\u590d\u5236\u96c6\u7fa4</a>\u7684\u6b65\u9aa4\uff1b\u8be6\u89c1<a class=\"xref\" href=\"/docs/devel/logical-replication-upgrade.html\" title=\"29.14.\u00a0\u5347\u7ea7\">\u7b2c\u00a029.14\u00a0\u8282</a>\u3002</p>\n</div>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/20</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/devel/libpq-pgpass.html\" title=\"32.15.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a032.15\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/20 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-20\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/devel/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u3001\u514b\u9686\u6216\u4ea4\u6362\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002\u5982\u679c\u5173\u7cfb\u5f88\u591a\uff0c\u4ea4\u6362\u6a21\u5f0f\u53ef\u80fd\u6700\u5feb\uff0c\u4f46\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u4f60\u5c06\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u4ea4\u6362\u6a21\u5f0f\u4e5f\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002</p>\n<p>\u5c06 <code class=\"option\">--jobs</code> \u8bbe\u7f6e\u4e3a 2 \u6216\u66f4\u9ad8\u53ef\u4ee5\u8ba9 pg_upgrade \u5e76\u884c\u5904\u7406\u591a\u4e2a\u6570\u636e\u5e93\u548c\u8868\u7a7a\u95f4\u3002\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u5bf9\u4e8e\u591a\u6570\u636e\u5e93\u3001\u591a\u8868\u7a7a\u95f4\u7684\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>\u5bf9\u4e8e Windows \u7528\u6237\uff0c\u5fc5\u987b\u767b\u5f55\u5230\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u7136\u540e\u7ed9\u76ee\u5f55\u53c2\u6570\u52a0\u4e0a\u5f15\u53f7\uff0c\u518d\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/20/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/20/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade --check</code> \u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u3001\u514b\u9686\u3001copy-file-range \u6216\u4ea4\u6362\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u6216 <code class=\"option\">--swap</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code> \u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/devel/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/devel/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/devel/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/20 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_20_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c <code class=\"function\">pg_backup_start()</code> \u548c <code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u5982\u679c\u65e7\u4e3b\u5e93\u65e9\u4e8e 17.0\uff0c\u5219\u4e3b\u5e93\u4e0a\u7684\u4efb\u4f55\u69fd\u90fd\u4e0d\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u56e0\u6b64\u65e7\u5907\u5e93\u4e0a\u7684\u6240\u6709\u69fd\u90fd\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002\u5982\u679c\u65e7\u4e3b\u5e93\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ea\u6709\u4e3b\u5e93\u4e0a\u7684\u903b\u8f91\u69fd\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u800c\u65e7\u5907\u5e93\u4e0a\u7684\u5176\u4ed6\u69fd\u4e0d\u4f1a\u590d\u5236\uff0c\u56e0\u6b64\u4e5f\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u9664\u975e\u6307\u5b9a <code class=\"option\">--no-statistics</code>\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u5c06\u5927\u591a\u6570\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4ece\u65e7\u96c6\u7c07\u4f20\u8f93\u5230\u65b0\u96c6\u7c07\u3002\u4f46\u8fd9\u4e0d\u4f1a\u4f20\u8f93\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f8b\u5982\u6269\u5c55\u6dfb\u52a0\u7684\u81ea\u5b9a\u4e49\u7edf\u8ba1\u4fe1\u606f\uff0c\u6216\u7531\u7d2f\u79ef\u7edf\u8ba1\u7cfb\u7edf\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002</p>\n<p>\u7531\u4e8e\u5e76\u975e\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\u90fd\u4f1a\u7531 <code class=\"command\">pg_upgrade</code> \u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-in-stages --missing-stats-only</code> \u4e3a\u5c1a\u65e0\u7edf\u8ba1\u4fe1\u606f\u7684\u5173\u7cfb\u5feb\u901f\u751f\u6210\u6700\u57fa\u672c\u7684\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-only</code> \u4ee5\u786e\u4fdd\u6240\u6709\u5173\u7cfb\u90fd\u62e5\u6709\u6700\u65b0\u7684\u7d2f\u79ef\u7edf\u8ba1\u4fe1\u606f\uff0c\u7528\u4e8e\u89e6\u53d1 vacuum \u548c analyze\u3002\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff0c\u4f7f\u7528 <code class=\"option\">--jobs</code> \u90fd\u53ef\u4ee5\u52a0\u5feb\u901f\u5ea6\u3002\u5982\u679c <code class=\"varname\">vacuum_cost_delay</code> \u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff0c\u53ef\u4ee5\u901a\u8fc7 <code class=\"envar\">PGOPTIONS</code> \u8986\u76d6\u5b83\u6765\u52a0\u5feb\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\uff0c\u4f8b\u5982 <code class=\"literal\">PGOPTIONS='-c vacuum_cost_delay=0' vacuumdb ...</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u65e2\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--link</code>\uff0c\u4e5f\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--swap</code>\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--swap</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u53ef\u80fd\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u4e4b\u524d\u4e2d\u6b62\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5df2\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\uff0c\u5219\u65e7\u96c6\u7c07\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.8\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u4e3a\u547d\u4ee4\u884c\u9009\u9879\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGBINOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-b</code>/<code class=\"option\">--old-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGBINNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-B</code>/<code class=\"option\">--new-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATAOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-d</code>/<code class=\"option\">--old-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATANEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-D</code>/<code class=\"option\">--new-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-p</code>/<code class=\"option\">--old-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-P</code>/<code class=\"option\">--new-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGSOCKETDIR</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-s</code>/<code class=\"option\">--socketdir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 <code class=\"option\">-U</code>/<code class=\"option\">--username</code>\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.9\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regdatabase</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/devel/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.4\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.10\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/devel/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/devel/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/devel/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/devel/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/devel/pgupgrade.html", "method": "same-major semantic node", "sha256": "b3c1f6fc2836c44de4cdb076606d1859f27431dce437bf0bc11004d13620b141", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[49]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/h3[0]", "#PGUPGRADE/div[6]/div[2]/p[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[8]/h2[0]", "#PGUPGRADE/div[8]/p[1]", "#PGUPGRADE/div[8]/p[2]", "#PGUPGRADE/div[8]/p[3]", "#PGUPGRADE/div[8]/p[4]", "#PGUPGRADE/div[8]/p[5]", "#PGUPGRADE/div[8]/p[7]", "#PGUPGRADE/div[8]/p[8]", "#PGUPGRADE/div[9]/h2[0]"]}], "language": "zh", "original_text": {"/summary": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/category": "Server applications", "/versions/20/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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/1/title": "Environment variables", "/versions/20/tables/0/rows/0/summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/20/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/20/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/20/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/20/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/20/tables/0/rows/5/summary": "number of simultaneous connections and processes/threads to use", "/versions/20/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/20/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/20/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/20/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/20/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/20/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/20/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/20/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/20/tables/0/rows/16/summary": "display version information, then exit", "/versions/20/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/20/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "/versions/20/tables/0/rows/19/summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "/versions/20/tables/0/rows/20/summary": "Do not restore statistics from the old cluster into the new cluster.", "/versions/20/tables/0/rows/21/summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "/versions/20/tables/0/rows/22/summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "/versions/20/tables/0/rows/23/summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/20/tables/0/rows/24/summary": "show help, then exit", "/versions/20/tables/1/columns/0/label": "Variable", "/versions/20/tables/1/columns/1/label": "Meaning", "/versions/20/tables/1/rows/0/description": "The old PostgreSQL executable directory; option -b / --old-bindir .", "/versions/20/tables/1/rows/1/description": "The new PostgreSQL executable directory; option -B / --new-bindir .", "/versions/20/tables/1/rows/2/description": "The old database cluster configuration directory; option -d / --old-datadir .", "/versions/20/tables/1/rows/3/description": "The new database cluster configuration directory; option -D / --new-datadir .", "/versions/20/tables/1/rows/4/description": "The old cluster port number; option -p / --old-port .", "/versions/20/tables/1/rows/5/description": "The new cluster port number; option -P / --new-port .", "/versions/20/tables/1/rows/6/description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir .", "/versions/20/tables/1/rows/7/description": "Cluster's install user name; option -U / --username ."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "6d139f38d015b0ae89777466887448edb55d77cf57685e1f8a29eb6a625add91"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "signature": "--copy-file-range", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "signature": "--set-char-signedness= option", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "signature": "--swap", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}]}, "comparison_hash": "ed8c09156ba62bb3138b603b905750e0ebd88baadd61089e3fe1a1e8186934e5", "manual_language": "zh"}}}, "snapshot": {"facts": [{"label": "\u624b\u518c\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f", "value": "pg_upgrade"}, {"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": "25"}], "tables": [{"key": "options", "rows": [{"summary": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-b bindir --old-bindir= bindir"}}, {"summary": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f pg_upgrade \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGBINNEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-B bindir --new-bindir= bindir"}}, {"summary": "\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-c --check"}}, {"summary": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATAOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-d configdir --old-datadir= configdir"}}, {"summary": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGDATANEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-D configdir --new-datadir= configdir"}}, {"summary": "\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-k --link"}}, {"summary": "\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c pg_upgrade \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f pg_upgrade \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-N --no-sync"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-o options --old-options options"}}, {"summary": "\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 postgres \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-O options --new-options options"}}, {"summary": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTOLD", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-p port --old-port= port"}}, {"summary": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf PGPORTNEW", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-P port --new-port= port"}}, {"summary": "\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-r --retain"}}, {"summary": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf PGSOCKETDIR", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-s dir --socketdir= dir"}}, {"summary": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf PGUSER", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-U username --username= username"}}, {"summary": "\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-v --verbose"}}, {"summary": "\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-V --version"}}, {"summary": "\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a \u201c reflinks \u201d \uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 -k / --link \u7684\u901f\u5ea6\u4f18\u52bf\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--clone"}}, {"summary": "\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 --link \u3001 --clone \u3001 --copy-file-range \u548c --swap \u3002\uff09", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--copy"}}, {"summary": "\u4f7f\u7528 copy_file_range \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e --clone \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--copy-file-range"}}, {"summary": "\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--no-statistics"}}, {"summary": "\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a signed \u548c unsigned \u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--set-char-signedness= option"}}, {"summary": "\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e --link \u3001 --clone \u3001 --copy \u548c --copy-file-range \uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--swap"}}, {"summary": "\u8bbe\u7f6e\u4e3a fsync \uff08\u9ed8\u8ba4\uff09\u65f6\uff0c pg_upgrade \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002", "signature": {"url": "/docs/18/pgupgrade.html", "text": "--sync-method= method"}}, {"summary": "\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa", "signature": {"url": "/docs/18/pgupgrade.html", "text": "-? --help"}}], "title": "\u624b\u518c\u4e2d\u7684\u9009\u9879", "columns": [{"key": "signature", "label": "\u9009\u9879\u4e0e\u53c2\u6570"}, {"key": "summary", "label": "\u8bf4\u660e"}]}, {"key": "environment", "rows": [{"name": "PGBINOLD", "description": "\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -b / --old-bindir \u3002"}, {"name": "PGBINNEW", "description": "\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 -B / --new-bindir \u3002"}, {"name": "PGDATAOLD", "description": "\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -d / --old-datadir \u3002"}, {"name": "PGDATANEW", "description": "\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 -D / --new-datadir \u3002"}, {"name": "PGPORTOLD", "description": "\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -p / --old-port \u3002"}, {"name": "PGPORTNEW", "description": "\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 -P / --new-port \u3002"}, {"name": "PGSOCKETDIR", "description": "\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 -s / --socketdir \u3002"}, {"name": "PGUSER", "description": "\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 -U / --username \u3002"}], "title": "\u73af\u5883\u53d8\u91cf", "columns": [{"key": "name", "label": "\u53d8\u91cf"}, {"key": "description", "label": "\u542b\u4e49"}]}], "options": [{"names": ["-b", "--old-bindir="], "summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "signature": "-b bindir --old-bindir= bindir", "source_url": "/docs/18/pgupgrade.html", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "signature": "-B bindir --new-bindir= bindir", "source_url": "/docs/18/pgupgrade.html", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "summary": "check clusters only, don't change any data", "signature": "-c --check", "source_url": "/docs/18/pgupgrade.html", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "signature": "-d configdir --old-datadir= configdir", "source_url": "/docs/18/pgupgrade.html", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "summary": "the new database cluster configuration directory; environment variable PGDATANEW", "signature": "-D configdir --new-datadir= configdir", "source_url": "/docs/18/pgupgrade.html", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "number of simultaneous connections and processes/threads to use", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/18/pgupgrade.html", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "summary": "use hard links instead of copying files to the new cluster", "signature": "-k --link", "source_url": "/docs/18/pgupgrade.html", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/pgupgrade.html", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "signature": "-o options --old-options options", "source_url": "/docs/18/pgupgrade.html", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "signature": "-O options --new-options options", "source_url": "/docs/18/pgupgrade.html", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "summary": "the old cluster port number; environment variable PGPORTOLD", "signature": "-p port --old-port= port", "source_url": "/docs/18/pgupgrade.html", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "summary": "the new cluster port number; environment variable PGPORTNEW", "signature": "-P port --new-port= port", "source_url": "/docs/18/pgupgrade.html", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "summary": "retain SQL and log files even after successful completion", "signature": "-r --retain", "source_url": "/docs/18/pgupgrade.html", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "signature": "-s dir --socketdir= dir", "source_url": "/docs/18/pgupgrade.html", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "summary": "cluster's install user name; environment variable PGUSER", "signature": "-U username --username= username", "source_url": "/docs/18/pgupgrade.html", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "summary": "enable verbose internal logging", "signature": "-v --verbose", "source_url": "/docs/18/pgupgrade.html", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "summary": "display version information, then exit", "signature": "-V --version", "source_url": "/docs/18/pgupgrade.html", "description": "display version information, then exit"}, {"names": ["--clone"], "summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "signature": "--clone", "source_url": "/docs/18/pgupgrade.html", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "signature": "--copy", "source_url": "/docs/18/pgupgrade.html", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "signature": "--copy-file-range", "source_url": "/docs/18/pgupgrade.html", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "summary": "Do not restore statistics from the old cluster into the new cluster.", "signature": "--no-statistics", "source_url": "/docs/18/pgupgrade.html", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "signature": "--set-char-signedness= option", "source_url": "/docs/18/pgupgrade.html", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "signature": "--swap", "source_url": "/docs/18/pgupgrade.html", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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/pgupgrade.html", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "summary": "show help, then exit", "signature": "-? --help", "source_url": "/docs/18/pgupgrade.html", "description": "show help, then exit"}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "https://pg.center/docs/18/pgupgrade.html", "file": "pgupgrade.html", "label": "18.6 English manual \u00b7 pgupgrade.html", "anchor": "", "sha256": "2e660b507e9708faa548f04934c0108f501d26931606e9c14dfbfbb1e5ec7917", "language": "en", "original_url": "/docs/18/pgupgrade.html"}, {"url": "https://pg.center/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3", "language": "en", "original_url": "/docs/18/reference-server.html"}], "sections": [], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "signature": "pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]", "description": ["pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a PostgreSQL \u670d\u52a1\u5668\u5b9e\u4f8b"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}], "manual_html": "<div><div class=\"refentry\" id=\"PGUPGRADE\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_upgrade</span></span></h2>\n<p lang=\"zh\">pg_upgrade \u2014 \u5347\u7ea7\u4e00\u4e2a<span class=\"productname\">PostgreSQL</span>\u670d\u52a1\u5668\u5b9e\u4f8b</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2 lang=\"zh\">\u5927\u7eb2</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.13.4.1\"><code class=\"command\">pg_upgrade</code> <code class=\"option\">-b</code> <em class=\"replaceable\"><code>oldbindir</code></em> [<code class=\"option\">-B</code> <em class=\"replaceable\"><code>newbindir</code></em>] <code class=\"option\">-d</code> <em class=\"replaceable\"><code>oldconfigdir</code></em> <code class=\"option\">-D</code> <em class=\"replaceable\"><code>newconfigdir</code></em> [<em class=\"replaceable\"><code>option</code></em>...]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.5\">\n<h2 lang=\"zh\">\u8bf4\u660e</h2>\n<p lang=\"zh\">pg_upgrade\uff08\u539f\u540d pg_migrator\uff09\u5141\u8bb8\u5c06 PostgreSQL \u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5347\u7ea7\u5230\u66f4\u9ad8\u7684 PostgreSQL \u4e3b\u8981\u7248\u672c\uff0c\u800c\u4e0d\u5fc5\u50cf\u901a\u5e38\u7684\u4e3b\u8981\u7248\u672c\u5347\u7ea7\u90a3\u6837\u8f6c\u50a8\u5e76\u6062\u590d\u6570\u636e\uff0c\u4f8b\u5982\u4ece 12.14 \u5347\u7ea7\u5230 13.10\uff0c\u6216\u4ece 14.9 \u5347\u7ea7\u5230 15.5\u3002\u6b21\u8981\u7248\u672c\u5347\u7ea7\u4e0d\u9700\u8981\u4f7f\u7528\u5b83\uff0c\u4f8b\u5982\u4ece 12.7 \u5347\u7ea7\u5230 12.8\uff0c\u6216\u4ece 14.1 \u5347\u7ea7\u5230 14.5\u3002</p>\n<p lang=\"zh\">PostgreSQL \u4e3b\u7248\u672c\u4f1a\u5b9a\u671f\u589e\u52a0\u65b0\u7279\u6027\uff0c\u8fd9\u4e9b\u7279\u6027\u5e38\u5e38\u4f1a\u6539\u53d8\u7cfb\u7edf\u8868\u7684\u5e03\u5c40\uff0c\u4f46\u5185\u90e8\u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5f88\u5c11\u6539\u53d8\u3002<span class=\"application\">pg_upgrade</span>\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u7684\u7cfb\u7edf\u8868\u5e76\u76f4\u63a5\u91cd\u7528\u65e7\u7684\u7528\u6237\u6570\u636e\u6587\u4ef6\u6765\u5feb\u901f\u5b8c\u6210\u5347\u7ea7\u3002\u5982\u679c\u672a\u6765\u67d0\u4e2a\u4e3b\u7248\u672c\u6539\u53d8\u4e86\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff0c\u81f4\u4f7f\u65e7\u6570\u636e\u683c\u5f0f\u65e0\u6cd5\u8bfb\u53d6\uff0c\u90a3\u4e48 <span class=\"application\">pg_upgrade</span>\u5c31\u4e0d\u80fd\u7528\u4e8e\u8fd9\u7c7b\u5347\u7ea7\u3002\uff08\u793e\u533a\u4f1a\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002\uff09</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span>\u4f1a\u5c3d\u6700\u5927\u52aa\u529b\u786e\u4fdd\u65b0\u65e7\u96c6\u7c07\u5728\u4e8c\u8fdb\u5236\u4e0a\u517c\u5bb9\uff0c\u4f8b\u5982\u4f1a\u68c0\u67e5\u517c\u5bb9\u7684\u7f16\u8bd1\u65f6\u8bbe\u7f6e\uff0c\u5305\u62ec 32/64 \u4f4d\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u3002\u4efb\u4f55\u5916\u90e8\u6a21\u5757\u4e5f\u540c\u6837\u5fc5\u987b\u4e8c\u8fdb\u5236\u517c\u5bb9\uff0c\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4f46 <span class=\"application\">pg_upgrade</span> \u65e0\u6cd5\u68c0\u67e5\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u652f\u6301\u4ece 9.2.X \u53ca\u66f4\u9ad8\u7248\u672c\u5347\u7ea7\u5230\u5f53\u524d<span class=\"productname\">PostgreSQL</span>\u4e3b\u7248\u672c\uff0c\u5305\u62ec\u5feb\u7167\u7248\u548c beta \u7248\u3002</p>\n<div class=\"warning\">\n<h3 class=\"title\" lang=\"zh\">\u8b66\u544a</h3>\n<p lang=\"zh\">\u5347\u7ea7\u96c6\u7c07\u4f1a\u4f7f\u76ee\u6807\u96c6\u7c07\u6267\u884c\u7531\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u6240\u9009\u62e9\u7684\u4efb\u610f\u4ee3\u7801\u3002\u5347\u7ea7\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e90\u96c6\u7c07\u8d85\u7ea7\u7528\u6237\u662f\u53d7\u4fe1\u4efb\u7684\u3002</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.6\">\n<h2 lang=\"zh\">\u9009\u9879</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u63a5\u53d7\u4e0b\u5217\u547d\u4ee4\u884c\u53c2\u6570\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-b</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code> <em class=\"replaceable\"><code>bindir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-bindir=</code><em class=\"replaceable\"><code>bindir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9ed8\u8ba4\u662f <span class=\"application\">pg_upgrade</span> \u6240\u5728\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGBINNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br/></span><span class=\"term\"><code class=\"option\">--check</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4ec5\u68c0\u67e5\u96c6\u7c07\uff0c\u4e0d\u66f4\u6539\u4efb\u4f55\u6570\u636e</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-d</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATAOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D</code> <em class=\"replaceable\"><code>configdir</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-datadir=</code><em class=\"replaceable\"><code>configdir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGDATANEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br/></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u8981\u4f7f\u7528\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u8fdb\u7a0b/\u7ebf\u7a0b\u6570</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-k</code><br/></span><span class=\"term\"><code class=\"option\">--link</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528\u786c\u94fe\u63a5\u800c\u4e0d\u662f\u628a\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N</code><br/></span><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u7b49\u5f85\u5347\u7ea7\u540e\u96c6\u7c07\u7684\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u5b89\u5168\u5730\u5199\u5165\u78c1\u76d8\u3002\u8be5\u9009\u9879\u4f1a\u4f7f <code class=\"command\">pg_upgrade</code> \u4e0d\u7b49\u5f85\u5373\u8fd4\u56de\uff0c\u8fd9\u6837\u66f4\u5feb\uff0c\u4f46\u4e5f\u610f\u5473\u7740\u540e\u7eed\u82e5\u53d1\u751f\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff0c\u6570\u636e\u76ee\u5f55\u53ef\u80fd\u4f1a\u635f\u574f\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8fd9\u4e2a\u9009\u9879\u9002\u7528\u4e8e\u6d4b\u8bd5\uff0c\u4f46\u4e0d\u5e94\u5728\u751f\u4ea7\u5b89\u88c5\u4e2d\u4f7f\u7528\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65e7 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code> <em class=\"replaceable\"><code>options</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-options</code> <em class=\"replaceable\"><code>options</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u76f4\u63a5\u4f20\u9012\u7ed9\u65b0 <code class=\"command\">postgres</code> \u547d\u4ee4\u7684\u9009\u9879\uff1b\u591a\u6b21\u6307\u5b9a\u4f1a\u8ffd\u52a0</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--old-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTOLD</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P</code> <em class=\"replaceable\"><code>port</code></em><br/></span><span class=\"term\"><code class=\"option\">--new-port=</code><em class=\"replaceable\"><code>port</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGPORTNEW</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-r</code><br/></span><span class=\"term\"><code class=\"option\">--retain</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5373\u4f7f\u6210\u529f\u5b8c\u6210\u540e\u4e5f\u4fdd\u7559 SQL \u548c\u65e5\u5fd7\u6587\u4ef6</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code> <em class=\"replaceable\"><code>dir</code></em><br/></span><span class=\"term\"><code class=\"option\">--socketdir=</code><em class=\"replaceable\"><code>dir</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGSOCKETDIR</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em><br/></span><span class=\"term\"><code class=\"option\">--username=</code><em class=\"replaceable\"><code>username</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u73af\u5883\u53d8\u91cf <code class=\"envar\">PGUSER</code></p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br/></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u542f\u7528\u8be6\u7ec6\u7684\u5185\u90e8\u65e5\u5fd7\u8bb0\u5f55</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br/></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--clone</code></span></dt>\n<dd>\n<p lang=\"zh\">\u4f7f\u7528\u9ad8\u6548\u7684\u6587\u4ef6\u514b\u9686\uff08\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\u4e5f\u79f0\u4e3a<span class=\"quote\">\u201c<span class=\"quote\">reflinks</span>\u201d</span>\uff09\u4ee3\u66ff\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u53ef\u4ee5\u51e0\u4e4e\u77ac\u95f4\u590d\u5236\u6570\u636e\u6587\u4ef6\uff0c\u4ece\u800c\u5728\u4fdd\u6301\u65e7\u96c6\u7c07\u4e0d\u53d8\u7684\u540c\u65f6\uff0c\u83b7\u5f97 <code class=\"option\">-k</code>/<code class=\"option\">--link</code> \u7684\u901f\u5ea6\u4f18\u52bf\u3002</p>\n<p lang=\"zh\">\u6587\u4ef6\u514b\u9686\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53d7\u652f\u6301\u3002\u5982\u679c\u9009\u62e9\u4e86\u8be5\u9009\u9879\u4f46\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c<span class=\"application\">pg_upgrade</span> \u5c31\u4f1a\u62a5\u9519\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux\uff08\u5185\u6838 4.5 \u6216\u66f4\u9ad8\u7248\u672c\uff09\u4e0a\u7684 Btrfs \u548c XFS\uff08\u6587\u4ef6\u7cfb\u7edf\u9700\u5728\u521b\u5efa\u65f6\u542f\u7528 reflink \u652f\u6301\uff09\u4ee5\u53ca macOS \u4e0a\u7684 APFS \u4e2d\u53d7\u652f\u6301\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5c06\u6587\u4ef6\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\uff08\u53e6\u89c1 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u548c <code class=\"option\">--swap</code>\u3002\uff09</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--copy-file-range</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4f7f\u7528 <code class=\"function\">copy_file_range</code> \u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9ad8\u6548\u590d\u5236\u3002\u5728\u67d0\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u8fd9\u4f1a\u4ea7\u751f\u4e0e <code class=\"option\">--clone</code> \u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u5373\u5171\u4eab\u7269\u7406\u78c1\u76d8\u5757\uff1b\u5728\u53e6\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u4e0a\uff0c\u5b83\u4ecd\u7136\u4f1a\u590d\u5236\u5757\uff0c\u4f46\u4f1a\u901a\u8fc7\u4f18\u5316\u8def\u5f84\u5b8c\u6210\u3002\u76ee\u524d\uff0c\u5b83\u5728 Linux \u548c FreeBSD \u4e0a\u53d7\u652f\u6301\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u4e0d\u8981\u628a\u65e7\u96c6\u7c07\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u6062\u590d\u5230\u65b0\u96c6\u7c07\u4e2d\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--set-char-signedness=</code><em class=\"replaceable\"><code>option</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u624b\u5de5\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u3002\u53ef\u9009\u503c\u4e3a <code class=\"literal\">signed</code> \u548c <code class=\"literal\">unsigned</code>\u3002</p>\n<p lang=\"zh\">\u5728 C \u8bed\u8a00\u4e2d\uff0c<code class=\"type\">char</code> \u7c7b\u578b\u5728\u672a\u663e\u5f0f\u6307\u5b9a\u65f6\u7684\u9ed8\u8ba4\u6709\u7b26\u53f7\u6027\u56e0\u5e73\u53f0\u800c\u5f02\u3002\u4f8b\u5982\uff0c\u5728 x86 CPU \u4e0a <code class=\"type\">char</code> \u9ed8\u8ba4\u662f <code class=\"type\">signed char</code>\uff0c\u800c\u5728 ARM CPU \u4e0a\u9ed8\u8ba4\u662f <code class=\"type\">unsigned char</code>\u3002</p>\n<p lang=\"zh\">\u4ece <span class=\"productname\">PostgreSQL</span> 18 \u5f00\u59cb\uff0c\u6570\u636e\u5e93\u96c6\u7c07\u4f1a\u7ef4\u62a4\u81ea\u8eab\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\uff0c\u53ef\u7528\u4e8e\u786e\u4fdd\u5728\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e4b\u95f4\u4fdd\u6301\u4e00\u81f4\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<span class=\"application\">pg_upgrade</span> \u5728\u4ece\u73b0\u6709\u96c6\u7c07\u5347\u7ea7\u65f6\u4f1a\u4fdd\u7559\u8be5\u6709\u7b26\u53f7\u6027\u8bbe\u7f6e\u3002\u7136\u800c\uff0c\u4ece <span class=\"productname\">PostgreSQL</span> 17 \u6216\u66f4\u65e9\u7248\u672c\u5347\u7ea7\u65f6\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u91c7\u7528\u5176\u6784\u5efa\u6240\u5728\u5e73\u53f0\u7684 char \u6709\u7b26\u53f7\u6027\u3002</p>\n<p lang=\"zh\">\u8be5\u9009\u9879\u5141\u8bb8\u4f60\u663e\u5f0f\u8bbe\u7f6e\u65b0\u96c6\u7c07\u9ed8\u8ba4\u7684 char \u6709\u7b26\u53f7\u6027\uff0c\u4ee5\u8986\u76d6\u4efb\u4f55\u7ee7\u627f\u503c\u3002\u5728\u4ee5\u4e0b\u4e24\u79cd\u573a\u666f\u4e2d\u9700\u8981\u8003\u8651\u8be5\u9009\u9879\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u8ba1\u5212\u5728\u5347\u7ea7\u540e\u8fc1\u79fb\u5230\u4e0d\u540c\u5e73\u53f0\uff0c\u5219\u4e0d\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u884c\u4e3a\u624d\u662f\u6b63\u786e\u7684\u3002\u5e94\u5f53\u5148\u5728\u539f\u5e73\u53f0\u4e0a\u4e0d\u5e26\u6b64\u9009\u9879\u5b8c\u6210\u5347\u7ea7\uff0c\u7136\u540e\u518d\u8fc1\u79fb\u96c6\u7c07\u3002\u8fd9\u662f\u63a8\u8350\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u3002</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u5c06\u96c6\u7c07\u8fc1\u79fb\u5230\u4e86\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff08\u4f8b\u5982\u4ece\u57fa\u4e8e x86 \u7684\u7cfb\u7edf\u8fc1\u79fb\u5230\u57fa\u4e8e ARM \u7684\u7cfb\u7edf\uff09\uff0c\u5219\u5e94\u4f7f\u7528\u8be5\u9009\u9879\u6765\u6307\u5b9a\u4e0e\u539f\u5e73\u53f0\u9ed8\u8ba4 char \u6709\u7b26\u53f7\u6027\u76f8\u5339\u914d\u7684\u503c\u3002\u6b64\u5916\uff0c\u4ece\u8fc1\u79fb\u6570\u636e\u6587\u4ef6\u5230\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u95f4\uff0c\u5207\u52ff\u4fee\u6539\u4efb\u4f55\u6570\u636e\u6587\u4ef6\u3002<code class=\"command\">pg_upgrade</code> \u5e94\u5f53\u662f\u65b0\u5e73\u53f0\u4e0a\u9996\u6b21\u542f\u52a8\u8be5\u96c6\u7c07\u7684\u64cd\u4f5c\u3002</p>\n</li>\n</ul>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--swap</code></span></dt>\n<dd>\n<p lang=\"zh\">\u5c06\u6570\u636e\u76ee\u5f55\u4ece\u65e7\u96c6\u7c07\u79fb\u52a8\u5230\u65b0\u96c6\u7c07\uff0c\u7136\u540e\u7528\u4e3a\u65b0\u96c6\u7c07\u751f\u6210\u7684\u7cfb\u7edf\u76ee\u5f55\u6587\u4ef6\u66ff\u6362\u539f\u6709\u76ee\u5f55\u6587\u4ef6\u3002\u8be5\u6a21\u5f0f\u7684\u6027\u80fd\u53ef\u80fd\u4f18\u4e8e <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy</code> \u548c <code class=\"option\">--copy-file-range</code>\uff0c\u5c24\u5176\u662f\u5728\u5173\u7cfb\u5f88\u591a\u7684\u96c6\u7c07\u4e0a\u3002</p>\n<p lang=\"zh\">\u4e0d\u8fc7\uff0c\u6b64\u6a21\u5f0f\u4f1a\u5728\u65e7\u96c6\u7fa4\u4e2d\u4ea7\u751f\u8bb8\u591a\u5783\u573e\u6587\u4ef6\uff1b\u5982\u679c\u4f7f\u7528 --sync-method=syncfs\uff0c\u6587\u4ef6\u540c\u6b65\u6b65\u9aa4\u53ef\u80fd\u56e0\u6b64\u53d8\u6162\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06 --swap \u4e0e --sync-method=fsync \u4e00\u8d77\u4f7f\u7528\u3002</p>\n<p lang=\"zh\">\u6b64\u5916\uff0c\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u65e7\u96c6\u7c07\u5c31\u4f1a\u88ab\u7834\u574f\u6027\u4fee\u6539\uff0c\u56e0\u6b64\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u3002\u8be6\u89c1<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=</code><em class=\"replaceable\"><code>method</code></em></span></dt>\n<dd>\n<p lang=\"zh\">\u8bbe\u7f6e\u4e3a <code class=\"literal\">fsync</code>\uff08\u9ed8\u8ba4\uff09\u65f6\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9012\u5f52\u6253\u5f00\u5e76\u540c\u6b65\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\u4f1a\u8ddf\u968f WAL \u76ee\u5f55\u548c\u5404\u4e2a\u5df2\u914d\u7f6e\u8868\u7a7a\u95f4\u7684\u7b26\u53f7\u94fe\u63a5\u3002</p>\n<p lang=\"zh\">\u5728 Linux \u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">syncfs</code>\uff0c\u8ba9\u64cd\u4f5c\u7cfb\u7edf\u540c\u6b65\u5305\u542b\u5347\u7ea7\u540e\u96c6\u7c07\u6570\u636e\u76ee\u5f55\u3001\u5176 WAL \u6587\u4ef6\u4ee5\u53ca\u5404\u4e2a\u8868\u7a7a\u95f4\u7684\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002\u89c1<a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a>\u4e86\u89e3\u4f7f\u7528 <code class=\"literal\">syncfs</code> \u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002</p>\n<p lang=\"zh\">\u5f53\u4f7f\u7528 <code class=\"option\">--no-sync</code> \u65f6\uff0c\u6b64\u9009\u9879\u65e0\u6548\u3002</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br/></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u663e\u793a\u5e2e\u52a9\uff0c\u7136\u540e\u9000\u51fa</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.7\">\n<h2 lang=\"zh\">\u7528\u6cd5</h2>\n<p lang=\"zh\">\u4f7f\u7528 <span class=\"application\">pg_upgrade</span> \u6267\u884c\u5347\u7ea7\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a</p>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">\u6ce8\u610f</h3>\n<p lang=\"zh\">\u8fd9\u91cc\u4e0d\u4ecb\u7ecd\u5347\u7ea7<a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\"></a><a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-LOGICAL-REPLICATION-CLUSTER\" title=\"\u903b\u8f91\u590d\u5236\u96c6\u7fa4\">\u903b\u8f91\u590d\u5236\u96c6\u7fa4</a>\u7684\u6b65\u9aa4\uff1b\u8be6\u89c1<a class=\"xref\" href=\"/docs/18/logical-replication-upgrade.html\" title=\"29.13.\u00a0\u5347\u7ea7\">\u7b2c\u00a029.13\u00a0\u8282</a>\u3002</p>\n</div>\n<div class=\"procedure\">\n<ol class=\"procedure\">\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u79fb\u52a8\u65e7\u96c6\u7c07\uff08\u53ef\u9009\uff09</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u4f8b\u5982 <code class=\"filename\">/opt/PostgreSQL/18</code>\uff0c\u5219\u4e0d\u5fc5\u79fb\u52a8\u65e7\u96c6\u7c07\u3002\u56fe\u5f62\u5316\u5b89\u88c5\u7a0b\u5e8f\u90fd\u4f7f\u7528\u5e26\u7248\u672c\u53f7\u7684\u5b89\u88c5\u76ee\u5f55\u3002</p>\n<p>\u5982\u679c\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e0d\u662f\u5e26\u7248\u672c\u53f7\u7684\uff0c\u4f8b\u5982 <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u5c31\u5fc5\u987b\u79fb\u52a8\u5f53\u524d\u7684 PostgreSQL \u5b89\u88c5\u76ee\u5f55\uff0c\u4ee5\u514d\u5b83\u5e72\u6270\u65b0\u7684 <span class=\"productname\">PostgreSQL</span> \u5b89\u88c5\u3002\u5f53\u524d\u7684 <span class=\"productname\">PostgreSQL</span> \u670d\u52a1\u5668\u5173\u95ed\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u5168\u5730\u91cd\u547d\u540d PostgreSQL \u5b89\u88c5\u76ee\u5f55\u3002\u5047\u8bbe\u65e7\u76ee\u5f55\u662f <code class=\"filename\">/usr/local/pgsql</code>\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a</p>\n<pre class=\"programlisting\">\nmv /usr/local/pgsql /usr/local/pgsql.old\n</pre>\n<p>\u4ee5\u4e0a\u547d\u4ee4\u4f1a\u91cd\u547d\u540d\u8be5\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u7f16\u8bd1\u65b0\u7248\u672c</strong></p>\n<p>\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u517c\u5bb9\u7684 <code class=\"command\">configure</code> \u6807\u5fd7\u7f16\u8bd1\u65b0\u7684 PostgreSQL \u6e90\u7801\u3002<span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u5f00\u59cb\u5347\u7ea7\u524d\u68c0\u67e5 <code class=\"command\">pg_controldata</code>\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u8bbe\u7f6e\u90fd\u517c\u5bb9\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u5b89\u88c5\u65b0\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002\u9ed8\u8ba4\u5b89\u88c5\u4e2d\u5305\u542b <span class=\"application\">pg_upgrade</span>\u3002</p>\n<p>\u5bf9\u4e8e\u6e90\u7801\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u628a\u65b0\u670d\u52a1\u5668\u5b89\u88c5\u5230\u81ea\u5b9a\u4e49\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code class=\"literal\">prefix</code> \u53d8\u91cf\uff1a</p>\n<pre class=\"programlisting\">\nmake prefix=/usr/local/pgsql.new install\n</pre>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u521d\u59cb\u5316\u65b0\u7684 PostgreSQL \u96c6\u7c07</strong></p>\n<p>\u4f7f\u7528 <code class=\"command\">initdb</code> \u521d\u59cb\u5316\u65b0\u96c6\u7c07\u3002\u8fd9\u91cc\u540c\u6837\u8981\u4f7f\u7528\u4e0e\u65e7\u96c6\u7c07\u5339\u914d\u7684\u517c\u5bb9 <code class=\"command\">initdb</code> \u6807\u5fd7\u3002\u8bb8\u591a\u9884\u6784\u5efa\u7684\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u6b65\u9aa4\u3002\u65e0\u9700\u542f\u52a8\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u8bb8\u591a\u6765\u81ea <code class=\"filename\">contrib</code> \u6216\u5176\u4ed6\u6765\u6e90\u7684\u6269\u5c55\u548c\u81ea\u5b9a\u4e49\u6a21\u5757\u90fd\u4f1a\u4f7f\u7528\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff08\u6216 DLL\uff09\uff0c\u4f8b\u5982 <code class=\"filename\">pgcrypto.so</code>\u3002\u5982\u679c\u65e7\u96c6\u7c07\u4f7f\u7528\u4e86\u8fd9\u4e9b\u6a21\u5757\uff0c\u5219\u5fc5\u987b\u5728\u65b0\u96c6\u7c07\u4e2d\u5b89\u88c5\u4e0e\u65b0\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u76f8\u5339\u914d\u7684\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\uff0c\u8fd9\u901a\u5e38\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u5b8c\u6210\u3002\u4e0d\u8981\u88c5\u8f7d\u6a21\u5f0f\u5b9a\u4e49\uff0c\u4f8b\u5982 <code class=\"command\">CREATE EXTENSION pgcrypto</code>\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u4f1a\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u8fc7\u6765\u3002\u5982\u679c\u6709\u53ef\u7528\u7684\u6269\u5c55\u66f4\u65b0\uff0c<span class=\"application\">pg_upgrade</span> \u4f1a\u62a5\u544a\u8fd9\u4e00\u70b9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u7a0d\u540e\u53ef\u8fd0\u884c\u7684\u811a\u672c\u6765\u66f4\u65b0\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u590d\u5236\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6</strong></p>\n<p>\u5c06\u6240\u6709\u81ea\u5b9a\u4e49\u5168\u6587\u68c0\u7d22\u6587\u4ef6\uff08\u8bcd\u5178\u3001\u540c\u4e49\u8bcd\u3001\u8bcd\u5e93\u3001\u505c\u7528\u8bcd\uff09\u4ece\u65e7\u96c6\u7c07\u590d\u5236\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8c03\u6574\u8ba4\u8bc1</strong></p>\n<p><code class=\"command\">pg_upgrade</code> \u4f1a\u591a\u6b21\u8fde\u63a5\u65e7\u670d\u52a1\u5668\u548c\u65b0\u670d\u52a1\u5668\uff0c\u56e0\u6b64\u4f60\u53ef\u80fd\u5e0c\u671b\u5c06\u8ba4\u8bc1\u8bbe\u7f6e\u4e3a <code class=\"literal\">peer</code>\uff08\u5728 <code class=\"filename\">pg_hba.conf</code> \u4e2d\uff09\uff0c\u6216\u8005\u4f7f\u7528 <code class=\"filename\">~/.pgpass</code> \u6587\u4ef6\uff08\u89c1<a class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16.\u00a0\u5bc6\u7801\u6587\u4ef6\">\u7b2c\u00a032.16\u00a0\u8282</a>\uff09\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u505c\u6b62\u4e24\u4e2a\u670d\u52a1\u5668</strong></p>\n<p>\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u90fd\u5df2\u505c\u6b62\uff0c\u5728 Unix \u4e0a\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_ctl -D /opt/PostgreSQL/12 stop\npg_ctl -D /opt/PostgreSQL/18 stop\n</pre>\n<p>\u6216\u8005\u5728 Windows \u4e0a\u4f7f\u7528\u5408\u9002\u7684\u670d\u52a1\u540d\uff1a</p>\n<pre class=\"programlisting\">\nNET STOP postgresql-12\nNET STOP postgresql-18\n</pre>\n<p>\u5728\u6b64\u6b21\u5173\u95ed\u671f\u95f4\uff0c\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\u5fc5\u987b\u4fdd\u6301\u8fd0\u884c\uff0c\u4ee5\u4fbf\u63a5\u6536\u6240\u6709\u66f4\u6539\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u4e3a\u5907\u5e93\u5347\u7ea7\u505a\u51c6\u5907</strong></p>\n<p>\u5982\u679c\u4f60\u8981\u4f7f\u7528<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REPLICAS\" title=\"\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u6b65\u9aa4 11</a>\u8282\u6982\u8ff0\u7684\u65b9\u6cd5\u5347\u7ea7\u5907\u5e93\uff0c\u8bf7\u901a\u8fc7\u5bf9\u65e7\u4e3b\u5e93\u96c6\u7c07\u548c\u5907\u5e93\u96c6\u7c07\u8fd0\u884c <span class=\"application\">pg_controldata</span> \u6765\u786e\u8ba4\u65e7\u5907\u5e93\u5df2\u8ffd\u4e0a\u4e3b\u5e93\u3002\u786e\u8ba4\u6240\u6709\u96c6\u7c07\u4e2d\u7684<span class=\"quote\">\u201c<span class=\"quote\">Latest checkpoint location</span>\u201d</span>\u503c\u4e00\u81f4\u3002\u53e6\u5916\uff0c\u8bf7\u786e\u4fdd <code class=\"varname\">wal_level</code> \u6ca1\u6709\u88ab\u8bbe\u7f6e\u4e3a <code class=\"literal\">minimal</code>\uff0c\u8fd9\u4e00\u70b9\u53ef\u5728\u65b0\u4e3b\u5e93\u96c6\u7c07\u7684 <code class=\"filename\">postgresql.conf</code> \u6587\u4ef6\u4e2d\u68c0\u67e5\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">pg_upgrade</span></strong></p>\n<p>\u59cb\u7ec8\u8fd0\u884c\u65b0\u670d\u52a1\u5668\u7684 <span class=\"application\">pg_upgrade</span> \u4e8c\u8fdb\u5236\uff0c\u800c\u4e0d\u662f\u65e7\u670d\u52a1\u5668\u7684\u3002<span class=\"application\">pg_upgrade</span> \u9700\u8981\u6307\u5b9a\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u548c\u53ef\u6267\u884c\u6587\u4ef6\uff08<code class=\"filename\">bin</code>\uff09\u76ee\u5f55\u3002\u4f60\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u548c\u7aef\u53e3\u503c\uff0c\u4ee5\u53ca\u662f\u5426\u5e0c\u671b\u5c06\u6570\u636e\u6587\u4ef6\u94fe\u63a5\u3001\u514b\u9686\u6216\u4ea4\u6362\uff0c\u800c\u4e0d\u662f\u91c7\u7528\u9ed8\u8ba4\u7684\u590d\u5236\u884c\u4e3a\u3002</p>\n<p>\u5982\u679c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u5347\u7ea7\u5c06\u5feb\u5f97\u591a\uff08\u65e0\u9700\u590d\u5236\u6587\u4ef6\uff09\u4e14\u5360\u7528\u66f4\u5c11\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u4e00\u65e6\u5728\u5347\u7ea7\u540e\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5c31\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u94fe\u63a5\u6a21\u5f0f\u8fd8\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff08\u8868\u7a7a\u95f4\u548c <code class=\"filename\">pg_wal</code> \u53ef\u4ee5\u4f4d\u4e8e\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\uff09\u514b\u9686\u6a21\u5f0f\u5177\u6709\u76f8\u540c\u7684\u901f\u5ea6\u548c\u78c1\u76d8\u7a7a\u95f4\u4f18\u52bf\uff0c\u4f46\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u540e\u4e0d\u4f1a\u4f7f\u65e7\u96c6\u7c07\u4e0d\u53ef\u7528\u3002\u514b\u9686\u6a21\u5f0f\u540c\u6837\u8981\u6c42\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002\u8be5\u6a21\u5f0f\u53ea\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u548c\u6587\u4ef6\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002\u5982\u679c\u5173\u7cfb\u5f88\u591a\uff0c\u4ea4\u6362\u6a21\u5f0f\u53ef\u80fd\u6700\u5feb\uff0c\u4f46\u4e00\u65e6\u6587\u4ef6\u4f20\u8f93\u6b65\u9aa4\u5f00\u59cb\uff0c\u4f60\u5c06\u65e0\u6cd5\u518d\u8bbf\u95ee\u65e7\u96c6\u7c07\u3002\u4ea4\u6362\u6a21\u5f0f\u4e5f\u8981\u6c42\u65b0\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002</p>\n<p>\u5c06 <code class=\"option\">--jobs</code> \u8bbe\u7f6e\u4e3a 2 \u6216\u66f4\u9ad8\u53ef\u4ee5\u8ba9 pg_upgrade \u5e76\u884c\u5904\u7406\u591a\u4e2a\u6570\u636e\u5e93\u548c\u8868\u7a7a\u95f4\u3002\u4e00\u4e2a\u4e0d\u9519\u7684\u8d77\u59cb\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u5bf9\u4e8e\u591a\u6570\u636e\u5e93\u3001\u591a\u8868\u7a7a\u95f4\u7684\u670d\u52a1\u5668\uff0c\u6b64\u9009\u9879\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5347\u7ea7\u65f6\u95f4\u3002</p>\n<p>\u5bf9\u4e8e Windows \u7528\u6237\uff0c\u5fc5\u987b\u767b\u5f55\u5230\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u7136\u540e\u7ed9\u76ee\u5f55\u53c2\u6570\u52a0\u4e0a\u5f15\u53f7\uff0c\u518d\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\npg_upgrade.exe\n        --old-datadir \"C:/Program Files/PostgreSQL/12/data\"\n        --new-datadir \"C:/Program Files/PostgreSQL/18/data\"\n        --old-bindir \"C:/Program Files/PostgreSQL/12/bin\"\n        --new-bindir \"C:/Program Files/PostgreSQL/18/bin\"\n</pre>\n<p>\u542f\u52a8\u540e\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u9a8c\u8bc1\u4e24\u4e2a\u96c6\u7c07\u662f\u5426\u517c\u5bb9\uff0c\u7136\u540e\u6267\u884c\u5347\u7ea7\u3002\u5373\u4f7f\u65e7\u670d\u52a1\u5668\u4ecd\u5728\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code class=\"command\">pg_upgrade --check</code> \u4ec5\u6267\u884c\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade --check</code> \u8fd8\u4f1a\u6982\u8ff0\u5347\u7ea7\u540e\u9700\u8981\u624b\u5de5\u8fdb\u884c\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u6253\u7b97\u4f7f\u7528\u94fe\u63a5\u3001\u514b\u9686\u3001copy-file-range \u6216\u4ea4\u6362\u6a21\u5f0f\uff0c\u5219\u5e94\u5c06 <code class=\"option\">--link</code>\u3001<code class=\"option\">--clone</code>\u3001<code class=\"option\">--copy-file-range</code> \u6216 <code class=\"option\">--swap</code> \u4e0e <code class=\"option\">--check</code> \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u542f\u7528\u5bf9\u5e94\u6a21\u5f0f\u7684\u4e13\u7528\u68c0\u67e5\u3002<code class=\"command\">pg_upgrade</code> \u9700\u8981\u5bf9\u5f53\u524d\u76ee\u5f55\u5177\u6709\u5199\u6743\u9650\u3002</p>\n<p>\u663e\u7136\uff0c\u5728\u5347\u7ea7\u671f\u95f4\u4e0d\u5e94\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e9b\u96c6\u7c07\u3002<span class=\"application\">pg_upgrade</span> \u9ed8\u8ba4\u4f1a\u5728 50432 \u7aef\u53e3\u4e0a\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u4ee5\u907f\u514d\u610f\u5916\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u3002\u5347\u7ea7\u65f6\u53ef\u4ee5\u8ba9\u4e24\u4e2a\u96c6\u7c07\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u4e3a\u65b0\u65e7\u96c6\u7c07\u4e0d\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u5728\u68c0\u67e5\u4ecd\u5728\u8fd0\u884c\u7684\u65e7\u670d\u52a1\u5668\u65f6\uff0c\u65b0\u65e7\u7aef\u53e3\u53f7\u5fc5\u987b\u4e0d\u540c\u3002</p>\n<p>\u5982\u679c\u5728\u6062\u590d\u6570\u636e\u5e93\u6a21\u5f0f\u65f6\u53d1\u751f\u9519\u8bef\uff0c<code class=\"command\">pg_upgrade</code> \u5c06\u9000\u51fa\uff0c\u4f60\u5fc5\u987b\u6309\u7167\u4e0b\u6587<a class=\"xref\" href=\"/docs/18/pgupgrade.html#PGUPGRADE-STEP-REVERT\" title=\"\u6062\u590d\u5230\u65e7\u96c6\u7c07\">\u6b65\u9aa4 17</a>\u6240\u8ff0\u56de\u9000\u5230\u65e7\u96c6\u7c07\u3002\u82e5\u8981\u518d\u6b21\u5c1d\u8bd5 <code class=\"command\">pg_upgrade</code>\uff0c\u4f60\u9700\u8981\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u4f7f pg_upgrade \u7684\u6a21\u5f0f\u6062\u590d\u6b65\u9aa4\u80fd\u591f\u6210\u529f\u5b8c\u6210\u3002\u5982\u679c\u95ee\u9898\u51fa\u5728\u67d0\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u800c\u8be5\u6a21\u5757\u5e76\u672a\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u6570\u636e\uff0c\u5219\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4ece\u65e7\u96c6\u7c07\u5378\u8f7d\u8fd9\u4e2a <code class=\"filename\">contrib</code> \u6a21\u5757\uff0c\u5e76\u5728\u5347\u7ea7\u540e\u5c06\u5176\u5b89\u88c5\u5230\u65b0\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REPLICAS\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u94fe\u63a5\u6a21\u5f0f\uff0c\u5e76\u4e14\u6709\u6d41\u590d\u5236\uff08\u89c1<a class=\"xref\" href=\"/docs/18/warm-standby.html#STREAMING-REPLICATION\" title=\"26.2.5.\u00a0\u6d41\u590d\u5236\">\u7b2c\u00a026.2.5\u00a0\u8282</a>\uff09\u6216\u65e5\u5fd7\u4f20\u9001\uff08\u89c1<a class=\"xref\" href=\"/docs/18/warm-standby.html\" title=\"26.2.\u00a0\u65e5\u5fd7\u4f20\u9001\u5907\u5e93\">\u7b2c\u00a026.2\u00a0\u8282</a>\uff09\u5907\u5e93\uff0c\u53ef\u4ee5\u6309\u7167\u4e0b\u5217\u6b65\u9aa4\u5feb\u901f\u5347\u7ea7\u5b83\u4eec\u3002\u4f60\u65e0\u9700\u5728\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">pg_upgrade</span>\uff0c\u800c\u662f\u8981\u5728\u4e3b\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span>\u3002\u73b0\u5728\u5148\u4e0d\u8981\u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5668\u3002</p>\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u3001\u6ca1\u6709\u6216\u4e0d\u60f3\u4f7f\u7528 <span class=\"application\">rsync</span>\uff0c\u6216\u8005\u60f3\u8981\u66f4\u7b80\u5355\u7684\u65b9\u6848\uff0c\u8bf7\u8df3\u8fc7\u672c\u8282\u8bf4\u660e\uff1b\u5f85 <span class=\"application\">pg_upgrade</span> \u5b8c\u6210\u4e14\u65b0\u4e3b\u5e93\u96c6\u7c07\u542f\u52a8\u540e\uff0c\u76f4\u63a5\u91cd\u5efa\u5907\u5e93\u5373\u53ef\u3002</p>\n<div class=\"procedure\">\n<ol class=\"procedure\" type=\"1\">\n<li class=\"step\">\n<p class=\"title\"><strong>\u5728\u5907\u5e93\u4e0a\u5b89\u88c5\u65b0\u7684 PostgreSQL \u4e8c\u8fdb\u5236\u6587\u4ef6</strong></p>\n<p>\u786e\u4fdd\u6240\u6709\u5907\u5e93\u90fd\u5df2\u5b89\u88c5\u65b0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u652f\u6301\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728</strong></p>\n<p>\u786e\u4fdd\u65b0\u7684\u5907\u5e93\u6570\u636e\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0d</em></span>\u5b58\u5728\uff0c\u6216\u8005\u4e3a\u7a7a\u3002\u5982\u679c\u8fd0\u884c\u8fc7 <span class=\"application\">initdb</span>\uff0c\u8bf7\u5220\u9664\u5907\u5e93\u7684\u65b0\u6570\u636e\u76ee\u5f55\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u5b89\u88c5\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6</strong></p>\n<p>\u5728\u65b0\u5907\u5e93\u4e0a\u5b89\u88c5\u4e0e\u65b0\u4e3b\u5e93\u96c6\u7c07\u4e2d\u76f8\u540c\u7684\u6269\u5c55\u5171\u4eab\u5bf9\u8c61\u6587\u4ef6\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u505c\u6b62\u5907\u5e93</strong></p>\n<p>\u5982\u679c\u5907\u5e93\u4ecd\u5728\u8fd0\u884c\uff0c\u8bf7\u6309\u4e0a\u8ff0\u8bf4\u660e\u7acb\u5373\u505c\u6b62\u5b83\u4eec\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6</strong></p>\n<p>\u4fdd\u5b58\u65e7\u5907\u5e93\u914d\u7f6e\u76ee\u5f55\u4e2d\u9700\u8981\u4fdd\u7559\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u3001<code class=\"filename\">postgresql.auto.conf</code>\u3001<code class=\"literal\">pg_hba.conf</code>\uff0c\u56e0\u4e3a\u5728\u4e0b\u4e00\u6b65\u4e2d\u5b83\u4eec\u4f1a\u88ab\u8986\u76d6\u6216\u5220\u9664\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u8fd0\u884c <span class=\"application\">rsync</span></strong></p>\n<p>\u5728\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 <span class=\"application\">rsync</span> \u5feb\u901f\u5347\u7ea7\u5907\u5e93\u3002\u4e3a\u6b64\uff0c\u5728\u4e3b\u5e93\u4e0a\u9009\u62e9\u4e00\u4e2a\u4f4d\u4e8e\u65b0\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u76ee\u5f55\u4e4b\u4e0a\u7684\u76ee\u5f55\uff0c\u5e76\u5728<span class=\"emphasis\"><em>\u4e3b\u5e93</em></span>\u4e0a\u9488\u5bf9\u6bcf\u4e2a\u5907\u5e93\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir\n</pre>\n<p>\u5176\u4e2d\uff0c<code class=\"option\">old_cluster</code> \u548c <code class=\"option\">new_cluster</code> \u662f\u76f8\u5bf9\u4e8e\u4e3b\u5e93\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\uff0c<code class=\"option\">remote_dir</code> \u5219\u662f\u5907\u5e93\u4e0a\u4f4d\u4e8e\u65b0\u65e7\u96c6\u7c07\u76ee\u5f55<span class=\"emphasis\"><em>\u4e0a\u5c42</em></span>\u7684\u76ee\u5f55\u3002\u4e3b\u5e93\u548c\u5907\u5e93\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\u3002\u5173\u4e8e\u5982\u4f55\u6307\u5b9a\u8fdc\u7a0b\u76ee\u5f55\u7684\u7ec6\u8282\uff0c\u8bf7\u53c2\u9605 <span class=\"application\">rsync</span> \u624b\u518c\u9875\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/12 \\\n      /opt/PostgreSQL/18 standby.example.com:/opt/PostgreSQL\n</pre>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <span class=\"application\">rsync</span> \u7684 <code class=\"option\">--dry-run</code> \u9009\u9879\u6765\u9a8c\u8bc1\u547d\u4ee4\u5c06\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u3002\u5c3d\u7ba1\u81f3\u5c11\u8981\u5728\u4e3b\u5e93\u4e0a\u4e3a\u4e00\u4e2a\u5907\u5e93\u8fd0\u884c <span class=\"application\">rsync</span>\uff0c\u4f46\u53ea\u8981\u67d0\u4e2a\u5df2\u5347\u7ea7\u7684\u5907\u5e93\u5c1a\u672a\u542f\u52a8\uff0c\u4e5f\u53ef\u4ee5\u5728\u8be5\u5907\u5e93\u4e0a\u8fd0\u884c <span class=\"application\">rsync</span> \u6765\u5347\u7ea7\u5176\u4ed6\u5907\u5e93\u3002</p>\n<p>\u5176\u539f\u7406\u662f\u8bb0\u5f55\u4e3b\u5e93\u4e0a\u65b0\u65e7\u96c6\u7c07\u6587\u4ef6\u4e4b\u95f4\u7531 <span class=\"application\">pg_upgrade</span> \u94fe\u63a5\u6a21\u5f0f\u521b\u5efa\u7684\u786c\u94fe\u63a5\uff0c\u7136\u540e\u5728\u5907\u5e93\u7684\u65e7\u96c6\u7c07\u4e2d\u627e\u5230\u5339\u914d\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u65b0\u96c6\u7c07\u4e2d\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u521b\u5efa\u94fe\u63a5\u3002\u4e3b\u5e93\u4e0a\u672a\u88ab\u94fe\u63a5\u7684\u6587\u4ef6\u4f1a\u4ece\u4e3b\u5e93\u590d\u5236\u5230\u5907\u5e93\uff08\u901a\u5e38\u90fd\u5f88\u5c0f\uff09\u3002\u8fd9\u4f7f\u5f97\u5907\u5e93\u80fd\u591f\u5feb\u901f\u5347\u7ea7\u3002\u4e0d\u5e78\u7684\u662f\uff0c<span class=\"application\">rsync</span> \u4f1a\u65e0\u8c13\u5730\u590d\u5236\u4e0e\u4e34\u65f6\u8868\u548c\u4e0d\u8bb0\u5f55 WAL \u7684\u8868\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u901a\u5e38\u4e0d\u5b58\u5728\u4e8e\u5907\u5e93\u4e0a\u3002</p>\n<p>\u5982\u679c\u4f60\u6709\u8868\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u5bf9\u6bcf\u4e2a\u8868\u7a7a\u95f4\u76ee\u5f55\u8fd0\u884c\u7c7b\u4f3c\u7684 <span class=\"application\">rsync</span> \u547d\u4ee4\uff0c\u4f8b\u5982\uff1a</p>\n<pre class=\"programlisting\">\nrsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tblsp/PG_12_201909212 \\\n      /vol1/pg_tblsp/PG_18_202307071 standby.example.com:/vol1/pg_tblsp\n</pre>\n<p>\u5982\u679c\u4f60\u628a <code class=\"filename\">pg_wal</code> \u8fc1\u79fb\u5230\u4e86\u6570\u636e\u76ee\u5f55\u4e4b\u5916\uff0c\u4e5f\u5fc5\u987b\u5bf9\u8fd9\u4e9b\u76ee\u5f55\u8fd0\u884c <span class=\"application\">rsync</span>\u3002</p>\n</li>\n<li class=\"step\">\n<p class=\"title\"><strong>\u914d\u7f6e\u6d41\u590d\u5236\u548c\u65e5\u5fd7\u4f20\u9001\u5907\u5e93</strong></p>\n<p>\u4e3a\u670d\u52a1\u5668\u914d\u7f6e\u65e5\u5fd7\u4f20\u9001\u3002\uff08\u7531\u4e8e\u5907\u5e93\u4ecd\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\uff0c\u56e0\u6b64\u65e0\u9700\u8fd0\u884c <code class=\"function\">pg_backup_start()</code> \u548c <code class=\"function\">pg_backup_stop()</code>\uff0c\u4e5f\u65e0\u9700\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u3002\uff09\u5982\u679c\u65e7\u4e3b\u5e93\u65e9\u4e8e 17.0\uff0c\u5219\u4e3b\u5e93\u4e0a\u7684\u4efb\u4f55\u69fd\u90fd\u4e0d\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u56e0\u6b64\u65e7\u5907\u5e93\u4e0a\u7684\u6240\u6709\u69fd\u90fd\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002\u5982\u679c\u65e7\u4e3b\u5e93\u4e3a 17.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ea\u6709\u4e3b\u5e93\u4e0a\u7684\u903b\u8f91\u69fd\u4f1a\u590d\u5236\u5230\u65b0\u5907\u5e93\uff0c\u800c\u65e7\u5907\u5e93\u4e0a\u7684\u5176\u4ed6\u69fd\u4e0d\u4f1a\u590d\u5236\uff0c\u56e0\u6b64\u4e5f\u5fc5\u987b\u624b\u5de5\u91cd\u5efa\u3002</p>\n</li>\n</ol>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d <code class=\"filename\">pg_hba.conf</code></strong></p>\n<p>\u5982\u679c\u4f60\u4fee\u6539\u4e86 <code class=\"filename\">pg_hba.conf</code>\uff0c\u8bf7\u6062\u590d\u5176\u539f\u59cb\u8bbe\u7f6e\u3002\u4e5f\u53ef\u80fd\u9700\u8981\u8c03\u6574\u65b0\u96c6\u7c07\u4e2d\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u4ee5\u5339\u914d\u65e7\u96c6\u7c07\uff0c\u4f8b\u5982 <code class=\"filename\">postgresql.conf</code>\uff08\u4ee5\u53ca\u5176\u5305\u542b\u7684\u6240\u6709\u6587\u4ef6\uff09\u548c <code class=\"filename\">postgresql.auto.conf</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u542f\u52a8\u65b0\u670d\u52a1\u5668</strong></p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u5730\u542f\u52a8\u65b0\u670d\u52a1\u5668\uff0c\u7136\u540e\u542f\u52a8\u6240\u6709\u7ecf <span class=\"application\">rsync</span> \u540c\u6b65\u7684\u5907\u5e93\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5347\u7ea7\u540e\u5904\u7406</strong></p>\n<p>\u5982\u679c\u9700\u8981\u4efb\u4f55\u5347\u7ea7\u540e\u5904\u7406\uff0cpg_upgrade \u5728\u5b8c\u6210\u65f6\u4f1a\u53d1\u51fa\u8b66\u544a\u3002\u5b83\u8fd8\u4f1a\u751f\u6210\u5fc5\u987b\u7531\u7ba1\u7406\u5458\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u811a\u672c\u4f1a\u8fde\u63a5\u5230\u6bcf\u4e2a\u9700\u8981\u5347\u7ea7\u540e\u5904\u7406\u7684\u6570\u636e\u5e93\u3002\u6bcf\u4e2a\u811a\u672c\u5e94\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\uff1a</p>\n<pre class=\"programlisting\">\npsql --username=postgres --file=script.sql postgres\n</pre>\n<p>\u8fd9\u4e9b\u811a\u672c\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd0\u884c\uff0c\u8fd0\u884c\u5b8c\u6bd5\u540e\u5373\u53ef\u5220\u9664\u3002</p>\n<div class=\"caution\">\n<h3 class=\"title\">\u5c0f\u5fc3</h3>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u5728\u91cd\u5efa\u811a\u672c\u8fd0\u884c\u5b8c\u6210\u4e4b\u524d\u8bbf\u95ee\u5176\u4e2d\u5f15\u7528\u7684\u8868\u662f\u4e0d\u5b89\u5168\u7684\uff1b\u8fd9\u6837\u505a\u53ef\u80fd\u4ea7\u751f\u9519\u8bef\u7ed3\u679c\u6216\u8f83\u5dee\u7684\u6027\u80fd\u3002\u672a\u5728\u91cd\u5efa\u811a\u672c\u4e2d\u5f15\u7528\u7684\u8868\u5219\u53ef\u4ee5\u7acb\u5373\u8bbf\u95ee\u3002</p>\n</div>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u7edf\u8ba1\u4fe1\u606f</strong></p>\n<p>\u9664\u975e\u6307\u5b9a <code class=\"option\">--no-statistics</code>\uff0c<code class=\"command\">pg_upgrade</code> \u4f1a\u5c06\u5927\u591a\u6570\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u4ece\u65e7\u96c6\u7c07\u4f20\u8f93\u5230\u65b0\u96c6\u7c07\u3002\u4f46\u8fd9\u4e0d\u4f1a\u4f20\u8f93\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f8b\u5982\u901a\u8fc7<a class=\"xref\" href=\"/docs/18/sql-createstatistics.html\" title=\"CREATE STATISTICS\"><span class=\"refentrytitle\">CREATE STATISTICS</span></a>\u663e\u5f0f\u521b\u5efa\u7684\u7edf\u8ba1\u4fe1\u606f\u3001\u6269\u5c55\u6dfb\u52a0\u7684\u81ea\u5b9a\u4e49\u7edf\u8ba1\u4fe1\u606f\uff0c\u6216\u7531\u7d2f\u79ef\u7edf\u8ba1\u7cfb\u7edf\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002</p>\n<p>\u7531\u4e8e\u5e76\u975e\u6240\u6709\u7edf\u8ba1\u4fe1\u606f\u90fd\u4f1a\u7531 <code class=\"command\">pg_upgrade</code> \u4f20\u8f93\uff0c\u5347\u7ea7\u7ed3\u675f\u65f6\u4f60\u4f1a\u88ab\u8981\u6c42\u8fd0\u884c\u547d\u4ee4\u6765\u91cd\u65b0\u751f\u6210\u8fd9\u4e9b\u4fe1\u606f\u3002\u4f60\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u8fde\u63a5\u53c2\u6570\u4ee5\u5339\u914d\u65b0\u96c6\u7c07\u3002</p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-in-stages --missing-stats-only</code> \u4e3a\u5c1a\u65e0\u7edf\u8ba1\u4fe1\u606f\u7684\u5173\u7cfb\u5feb\u901f\u751f\u6210\u6700\u57fa\u672c\u7684\u4f18\u5316\u5668\u7edf\u8ba1\u4fe1\u606f\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code class=\"command\">vacuumdb --all --analyze-only</code> \u4ee5\u786e\u4fdd\u6240\u6709\u5173\u7cfb\u90fd\u62e5\u6709\u6700\u65b0\u7684\u7d2f\u79ef\u7edf\u8ba1\u4fe1\u606f\uff0c\u7528\u4e8e\u89e6\u53d1 vacuum \u548c analyze\u3002\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff0c\u4f7f\u7528 <code class=\"option\">--jobs</code> \u90fd\u53ef\u4ee5\u52a0\u5feb\u901f\u5ea6\u3002\u5982\u679c <code class=\"varname\">vacuum_cost_delay</code> \u88ab\u8bbe\u7f6e\u4e3a\u975e\u96f6\u503c\uff0c\u53ef\u4ee5\u901a\u8fc7 <code class=\"envar\">PGOPTIONS</code> \u8986\u76d6\u5b83\u6765\u52a0\u5feb\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\uff0c\u4f8b\u5982 <code class=\"literal\">PGOPTIONS='-c vacuum_cost_delay=0' vacuumdb ...</code>\u3002</p>\n</li>\n<li class=\"step\" lang=\"zh\">\n<p class=\"title\"><strong>\u5220\u9664\u65e7\u96c6\u7c07</strong></p>\n<p>\u4e00\u65e6\u4f60\u786e\u8ba4\u5347\u7ea7\u7ed3\u679c\u4ee4\u4eba\u6ee1\u610f\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u5b8c\u6210\u65f6\u63d0\u5230\u7684\u811a\u672c\uff0c\u5220\u9664\u65e7\u96c6\u7c07\u7684\u6570\u636e\u76ee\u5f55\u3002\uff08\u5982\u679c\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u5305\u542b\u7528\u6237\u5b9a\u4e49\u7684\u8868\u7a7a\u95f4\uff0c\u5219\u65e0\u6cd5\u81ea\u52a8\u5220\u9664\u3002\uff09\u4f60\u4e5f\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5b89\u88c5\u76ee\u5f55\uff08\u4f8b\u5982 <code class=\"filename\">bin</code>\u3001<code class=\"filename\">share</code>\uff09\u3002</p>\n</li>\n<li class=\"step\" id=\"PGUPGRADE-STEP-REVERT\" lang=\"zh\">\n<p class=\"title\"><strong>\u6062\u590d\u5230\u65e7\u96c6\u7c07</strong></p>\n<p>\u5982\u679c\u5728\u8fd0\u884c <code class=\"command\">pg_upgrade</code> \u4e4b\u540e\uff0c\u4f60\u60f3\u6062\u590d\u5230\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: disc;\">\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--check</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u65e2\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--link</code>\uff0c\u4e5f\u6ca1\u6709\u4f7f\u7528 <code class=\"option\">--swap</code>\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--link</code> \u9009\u9879\uff0c\u6570\u636e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5728\u65b0\u65e7\u96c6\u7c07\u4e4b\u95f4\u5171\u4eab\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u4e4b\u524d\u5c31\u5df2\u4e2d\u6b62\uff0c\u65e7\u96c6\u7c07\u4e0d\u4f1a\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60<span class=\"emphasis\"><em>\u6ca1\u6709</em></span>\u542f\u52a8\u65b0\u96c6\u7c07\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u53ea\u662f\u5728\u5f00\u59cb\u5efa\u7acb\u94fe\u63a5\u65f6\uff0c\u4f1a\u628a\u4e00\u4e2a <code class=\"literal\">.old</code> \u540e\u7f00\u9644\u52a0\u5230 <code class=\"filename\">$PGDATA/global/pg_control</code>\u3002\u8981\u91cd\u65b0\u4f7f\u7528\u65e7\u96c6\u7c07\uff0c\u8bf7\u79fb\u9664 <code class=\"filename\">.old</code> \u8fd9\u4e2a\u9644\u52a0\u5728 <code class=\"filename\">$PGDATA/global/pg_control</code> \u4e0a\u7684\u540e\u7f00\uff1b\u968f\u540e\u5373\u53ef\u91cd\u65b0\u542f\u52a8\u65e7\u96c6\u7c07\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f60\u542f\u52a8\u4e86\u65b0\u96c6\u7c07\uff0c\u5b83\u5c31\u5df2\u7ecf\u5199\u5165\u4e86\u5171\u4eab\u6587\u4ef6\uff0c\u6b64\u65f6\u518d\u4f7f\u7528\u65e7\u96c6\u7c07\u662f\u4e0d\u5b89\u5168\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c\u4f7f\u7528\u4e86 <code class=\"option\">--swap</code> \u9009\u9879\uff0c\u65e7\u96c6\u7c07\u53ef\u80fd\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\uff1a</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\" style=\"list-style-type: circle;\">\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5728\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\u4e4b\u524d\u4e2d\u6b62\uff0c\u5219\u65e7\u96c6\u7c07\u6ca1\u6709\u88ab\u4fee\u6539\uff1b\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u3002</p>\n</li>\n<li class=\"listitem\">\n<p>\u5982\u679c <code class=\"command\">pg_upgrade</code> \u5df2\u62a5\u544a\u65e7\u96c6\u7c07\u4e0d\u518d\u80fd\u5b89\u5168\u542f\u52a8\uff0c\u5219\u65e7\u96c6\u7c07\u5df2\u7ecf\u88ab\u7834\u574f\u6027\u4fee\u6539\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e7\u96c6\u7c07\u5fc5\u987b\u4ece\u5907\u4efd\u6062\u590d\u3002</p>\n</li>\n</ul>\n</div>\n</li>\n</ul>\n</div>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.8\">\n<h2 lang=\"zh\">\u73af\u5883</h2>\n<p lang=\"zh\">\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u4e3a\u547d\u4ee4\u884c\u9009\u9879\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff1a</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGBINOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-b</code>/<code class=\"option\">--old-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGBINNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0 PostgreSQL \u53ef\u6267\u884c\u6587\u4ef6\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-B</code>/<code class=\"option\">--new-bindir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATAOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-d</code>/<code class=\"option\">--old-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATANEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u6570\u636e\u5e93\u96c6\u7c07\u914d\u7f6e\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-D</code>/<code class=\"option\">--new-datadir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTOLD</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65e7\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-p</code>/<code class=\"option\">--old-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGPORTNEW</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u65b0\u96c6\u7c07\u7aef\u53e3\u53f7\uff1b\u9009\u9879 <code class=\"option\">-P</code>/<code class=\"option\">--new-port</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGSOCKETDIR</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u5347\u7ea7\u671f\u95f4\u7528\u4e8e postmaster \u5957\u63a5\u5b57\u7684\u76ee\u5f55\uff1b\u9009\u9879 <code class=\"option\">-s</code>/<code class=\"option\">--socketdir</code>\u3002</p>\n</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p lang=\"zh\">\n<p>\u96c6\u7c07\u5b89\u88c5\u7528\u6237\u540d\u79f0\uff1b\u9009\u9879 <code class=\"option\">-U</code>/<code class=\"option\">--username</code>\u3002</p>\n</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.9\">\n<h2 lang=\"zh\">\u6ce8\u89e3</h2>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u521b\u5efa\u5404\u79cd\u5de5\u4f5c\u6587\u4ef6\uff0c\u4f8b\u5982\u6a21\u5f0f\u8f6c\u50a8\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u653e\u5728\u65b0\u96c6\u7c07\u76ee\u5f55\u4e0b\u7684 <code class=\"filename\">pg_upgrade_output.d</code> \u4e2d\u3002\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a\u4ee5 ISO 8601 \u683c\u5f0f\u65f6\u95f4\u6233\uff08<code class=\"literal\">%Y%m%dT%H%M%S</code>\uff09\u547d\u540d\u7684\u5b50\u76ee\u5f55\uff0c\u5176\u4e2d\u4fdd\u5b58\u8be5\u6b21\u8fd0\u884c\u751f\u6210\u7684\u5168\u90e8\u6587\u4ef6\u3002<code class=\"filename\">pg_upgrade_output.d</code> \u53ca\u5176\u4e2d\u7684\u6587\u4ef6\u4f1a\u5728 <span class=\"application\">pg_upgrade</span> \u6210\u529f\u5b8c\u6210\u540e\u88ab\u81ea\u52a8\u5220\u9664\uff1b\u4f46\u5982\u679c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u91cc\u7684\u6587\u4ef6\u53ef\u80fd\u63d0\u4f9b\u6709\u7528\u7684\u8c03\u8bd5\u4fe1\u606f\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4f1a\u5728\u65b0\u65e7\u6570\u636e\u76ee\u5f55\u4e2d\u542f\u52a8\u77ed\u751f\u547d\u5468\u671f\u7684 postmaster\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0e\u8fd9\u4e9b postmaster \u901a\u4fe1\u6240\u9700\u7684\u4e34\u65f6 Unix \u5957\u63a5\u5b57\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u524d\u76ee\u5f55\u7684\u8def\u5f84\u540d\u53ef\u80fd\u592a\u957f\uff0c\u65e0\u6cd5\u4f5c\u4e3a\u6709\u6548\u7684\u5957\u63a5\u5b57\u540d\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 <code class=\"option\">-s</code> \u9009\u9879\uff0c\u5c06\u5957\u63a5\u5b57\u6587\u4ef6\u653e\u5230\u8def\u5f84\u8f83\u77ed\u7684\u76ee\u5f55\u4e2d\u3002\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u52a1\u5fc5\u786e\u4fdd\u8be5\u76ee\u5f55\u5bf9\u5176\u4ed6\u4efb\u4f55\u7528\u6237\u90fd\u4e0d\u53ef\u8bfb\u4e5f\u4e0d\u53ef\u5199\u3002\uff08Windows \u4e0d\u652f\u6301\u6b64\u529f\u80fd\u3002\uff09</p>\n<p lang=\"zh\">\u51e1\u662f\u4f1a\u5f71\u54cd\u4f60\u5b89\u88c5\u73af\u5883\u7684\u5931\u8d25\u3001\u91cd\u5efa\u548c\u91cd\u65b0\u7d22\u5f15\u60c5\u51b5\uff0c<span class=\"application\">pg_upgrade</span> \u90fd\u4f1a\u62a5\u544a\uff1b\u7528\u4e8e\u91cd\u5efa\u8868\u548c\u7d22\u5f15\u7684\u5347\u7ea7\u540e\u811a\u672c\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5982\u679c\u4f60\u8bd5\u56fe\u81ea\u52a8\u5316\u5347\u7ea7\u5f88\u591a\u96c6\u7c07\uff0c\u4f60\u4f1a\u53d1\u73b0\u5177\u6709\u76f8\u540c\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u96c6\u7c07\u5728\u6240\u6709\u5347\u7ea7\u4e2d\u9700\u8981\u76f8\u540c\u7684\u5347\u7ea7\u540e\u6b65\u9aa4\uff1b\u8fd9\u662f\u56e0\u4e3a\u5347\u7ea7\u540e\u6b65\u9aa4\u4f9d\u636e\u7684\u662f\u6570\u636e\u5e93\u6a21\u5f0f\uff0c\u800c\u4e0d\u662f\u7528\u6237\u6570\u636e\u3002</p>\n<p lang=\"zh\">\u4e3a\u4e86\u6d4b\u8bd5\u90e8\u7f72\uff0c\u8bf7\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u7eaf\u6a21\u5f0f\u526f\u672c\uff0c\u63d2\u5165\u865a\u62df\u6570\u636e\uff0c\u7136\u540e\u5bf9\u5176\u5347\u7ea7\u3002</p>\n<p lang=\"zh\"><span class=\"application\">pg_upgrade</span> \u4e0d\u652f\u6301\u5347\u7ea7\u5305\u542b\u4f7f\u7528\u4e0b\u5217 <code class=\"type\">reg*</code> OID \u5f15\u7528\u7cfb\u7edf\u6570\u636e\u7c7b\u578b\u7684\u8868\u5217\u7684\u6570\u636e\u5e93\uff1a</p>\n<table class=\"simplelist\">\n<tbody><tr>\n<td><code class=\"type\">regcollation</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regconfig</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regdictionary</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regnamespace</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoper</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regoperator</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regproc</code></td>\n</tr>\n<tr>\n<td><code class=\"type\">regprocedure</code></td>\n</tr>\n</tbody></table>\n<p lang=\"zh\">\uff08<code class=\"type\">regclass</code>\u3001<code class=\"type\">regrole</code> \u548c <code class=\"type\">regtype</code> \u53ef\u4ee5\u5347\u7ea7\u3002\uff09</p>\n<p lang=\"zh\">\u5982\u679c\u4f60\u60f3\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\uff0c\u53c8\u4e0d\u5e0c\u671b\u5728\u542f\u52a8\u65b0\u96c6\u7c07\u65f6\u4fee\u6539\u65e7\u96c6\u7c07\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u514b\u9686\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u53ef\u7528\uff0c\u53ef\u4ee5\u5148\u590d\u5236\u65e7\u96c6\u7c07\uff0c\u518d\u5bf9\u8be5\u526f\u672c\u4f7f\u7528\u94fe\u63a5\u6a21\u5f0f\u5347\u7ea7\u3002\u8981\u521b\u5efa\u65e7\u96c6\u7c07\u7684\u6709\u6548\u526f\u672c\uff0c\u53ef\u5728\u670d\u52a1\u5668\u8fd0\u884c\u65f6\u4f7f\u7528 <code class=\"command\">rsync</code> \u521b\u5efa\u65e7\u96c6\u7c07\u7684\u810f\u62f7\u8d1d\uff0c\u7136\u540e\u5173\u95ed\u65e7\u670d\u52a1\u5668\uff0c\u518d\u8fd0\u884c <code class=\"command\">rsync --checksum</code>\uff0c\u628a\u6240\u6709\u53d8\u66f4\u540c\u6b65\u5230\u8be5\u526f\u672c\uff0c\u4f7f\u5176\u8fbe\u5230\u4e00\u81f4\u72b6\u6001\u3002\uff08\u4e4b\u6240\u4ee5\u9700\u8981 <code class=\"option\">--checksum</code>\uff0c\u662f\u56e0\u4e3a <code class=\"command\">rsync</code> \u5bf9\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u7684\u7c92\u5ea6\u53ea\u6709\u4e00\u79d2\u3002\uff09\u4f60\u53ef\u80fd\u8fd8\u60f3\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff0c\u4f8b\u5982 <code class=\"filename\">postmaster.pid</code>\uff0c\u5982<a class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4.\u00a0\u4f7f\u7528\u4f4e\u7ea7 API \u8fdb\u884c\u57fa\u7840\u5907\u4efd\">\u7b2c\u00a025.3.4\u00a0\u8282</a>\u6240\u8ff0\u3002\u5982\u679c\u4f60\u7684\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167\u6216\u5199\u65f6\u590d\u5236\u6587\u4ef6\u526f\u672c\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e9b\u65b9\u5f0f\u5907\u4efd\u65e7\u96c6\u7c07\u548c\u8868\u7a7a\u95f4\uff0c\u4e0d\u8fc7\u5feb\u7167\u548c\u526f\u672c\u5fc5\u987b\u540c\u65f6\u521b\u5efa\uff0c\u6216\u8005\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u5173\u95ed\u65f6\u521b\u5efa\u3002</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.13.10\">\n<h2 lang=\"zh\">\u53e6\u89c1</h2><span class=\"simplelist\"><a class=\"xref\" href=\"https://pg.center/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-pg-ctl.html\" title=\"pg_ctl\"><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-pgdump.html\" title=\"pg_dump\"><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></a>, <a class=\"xref\" href=\"https://pg.center/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "pgupgrade.html", "localization": {"status": "complete", "sources": [{"url": "/docs/18/pgupgrade.html", "method": "same-major semantic node", "sha256": "453b23176fbf9a379c9763866fbeb98542dd17b4d315dec77a3ad0197edb11eb", "language": "zh", "matched_nodes": ["#PGUPGRADE/div[2]/p[1]", "#PGUPGRADE/div[3]/h2[0]", "#PGUPGRADE/div[4]/div[5]/h3[0]", "#PGUPGRADE/div[4]/div[5]/p[1]", "#PGUPGRADE/div[4]/p[2]", "#PGUPGRADE/div[4]/p[3]", "#PGUPGRADE/div[4]/p[4]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[17]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[19]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[21]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[23]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[25]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[27]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[29]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[31]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[33]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[35]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[37]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[39]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[41]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/div[4]/ul[0]/li[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[43]/p[3]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[45]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[0]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[1]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[47]/p[2]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[49]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[5]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[5]/p[1]", "#PGUPGRADE/div[6]/div[2]/h3[0]", "#PGUPGRADE/div[6]/div[2]/p[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[0]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[10]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[11]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[12]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[13]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[14]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[15]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[16]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[1]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[2]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[3]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[4]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[5]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[6]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[7]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[8]", "#PGUPGRADE/div[6]/div[3]/ol[0]/li[9]", "#PGUPGRADE/div[6]/h2[0]", "#PGUPGRADE/div[6]/p[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[11]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[13]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[15]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[1]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[3]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[5]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[7]", "#PGUPGRADE/div[7]/div[2]/dl[0]/dd[9]", "#PGUPGRADE/div[7]/h2[0]", "#PGUPGRADE/div[7]/p[1]", "#PGUPGRADE/div[8]/h2[0]", "#PGUPGRADE/div[8]/p[1]", "#PGUPGRADE/div[8]/p[2]", "#PGUPGRADE/div[8]/p[3]", "#PGUPGRADE/div[8]/p[4]", "#PGUPGRADE/div[8]/p[5]", "#PGUPGRADE/div[8]/p[7]", "#PGUPGRADE/div[8]/p[8]", "#PGUPGRADE/div[9]/h2[0]"]}], "language": "zh", "original_text": {"/versions/18/description/0": "pg_upgrade \u2014 upgrade a PostgreSQL server instance", "/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/1/title": "Environment variables", "/versions/18/tables/0/rows/0/summary": "the old PostgreSQL executable directory; environment variable PGBINOLD", "/versions/18/tables/0/rows/1/summary": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW", "/versions/18/tables/0/rows/2/summary": "check clusters only, don't change any data", "/versions/18/tables/0/rows/3/summary": "the old database cluster configuration directory; environment variable PGDATAOLD", "/versions/18/tables/0/rows/4/summary": "the new database cluster configuration directory; environment variable PGDATANEW", "/versions/18/tables/0/rows/5/summary": "number of simultaneous connections and processes/threads to use", "/versions/18/tables/0/rows/6/summary": "use hard links instead of copying files to the new cluster", "/versions/18/tables/0/rows/7/summary": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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/8/summary": "options to be passed directly to the old postgres command; multiple option invocations are appended", "/versions/18/tables/0/rows/9/summary": "options to be passed directly to the new postgres command; multiple option invocations are appended", "/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": "the old cluster port number; environment variable PGPORTOLD", "/versions/18/tables/0/rows/11/summary": "the new cluster port number; environment variable PGPORTNEW", "/versions/18/tables/0/rows/12/summary": "retain SQL and log files even after successful completion", "/versions/18/tables/0/rows/13/summary": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR", "/versions/18/tables/0/rows/14/summary": "cluster's install user name; environment variable PGUSER", "/versions/18/tables/0/rows/15/summary": "enable verbose internal logging", "/versions/18/tables/0/rows/16/summary": "display version information, then exit", "/versions/18/tables/0/rows/17/summary": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched.", "/versions/18/tables/0/rows/18/summary": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)", "/versions/18/tables/0/rows/19/summary": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD.", "/versions/18/tables/0/rows/20/summary": "Do not restore statistics from the old cluster into the new cluster.", "/versions/18/tables/0/rows/21/summary": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned .", "/versions/18/tables/0/rows/22/summary": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations.", "/versions/18/tables/0/rows/23/summary": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's data directory. The search for files will follow symbolic links for the WAL directory and each configured tablespace.", "/versions/18/tables/0/rows/24/summary": "show help, then exit", "/versions/18/tables/1/columns/0/label": "Variable", "/versions/18/tables/1/columns/1/label": "Meaning", "/versions/18/tables/1/rows/0/description": "The old PostgreSQL executable directory; option -b / --old-bindir .", "/versions/18/tables/1/rows/1/description": "The new PostgreSQL executable directory; option -B / --new-bindir .", "/versions/18/tables/1/rows/2/description": "The old database cluster configuration directory; option -d / --old-datadir .", "/versions/18/tables/1/rows/3/description": "The new database cluster configuration directory; option -D / --new-datadir .", "/versions/18/tables/1/rows/4/description": "The old cluster port number; option -p / --old-port .", "/versions/18/tables/1/rows/5/description": "The new cluster port number; option -P / --new-port .", "/versions/18/tables/1/rows/6/description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir .", "/versions/18/tables/1/rows/7/description": "Cluster's install user name; option -U / --username ."}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "589d6202e3155f69fc4b7a8185a73def2535f63c2ea5ec3eff1c60d2319d0546"}, "comparison_data": {"options": [{"names": ["-b", "--old-bindir="], "signature": "-b bindir --old-bindir= bindir", "description": "the old PostgreSQL executable directory; environment variable PGBINOLD"}, {"names": ["-B", "--new-bindir="], "signature": "-B bindir --new-bindir= bindir", "description": "the new PostgreSQL executable directory; default is the directory where pg_upgrade resides; environment variable PGBINNEW"}, {"names": ["-c", "--check"], "signature": "-c --check", "description": "check clusters only, don't change any data"}, {"names": ["-d", "--old-datadir="], "signature": "-d configdir --old-datadir= configdir", "description": "the old database cluster configuration directory; environment variable PGDATAOLD"}, {"names": ["-D", "--new-datadir="], "signature": "-D configdir --new-datadir= configdir", "description": "the new database cluster configuration directory; environment variable PGDATANEW"}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "number of simultaneous connections and processes/threads to use"}, {"names": ["-k", "--link"], "signature": "-k --link", "description": "use hard links instead of copying files to the new cluster"}, {"names": ["-N", "--no-sync"], "signature": "-N --no-sync", "description": "By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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": ["-o", "--old-options"], "signature": "-o options --old-options options", "description": "options to be passed directly to the old postgres command; multiple option invocations are appended"}, {"names": ["-O", "--new-options"], "signature": "-O options --new-options options", "description": "options to be passed directly to the new postgres command; multiple option invocations are appended"}, {"names": ["-p", "--old-port="], "signature": "-p port --old-port= port", "description": "the old cluster port number; environment variable PGPORTOLD"}, {"names": ["-P", "--new-port="], "signature": "-P port --new-port= port", "description": "the new cluster port number; environment variable PGPORTNEW"}, {"names": ["-r", "--retain"], "signature": "-r --retain", "description": "retain SQL and log files even after successful completion"}, {"names": ["-s", "--socketdir="], "signature": "-s dir --socketdir= dir", "description": "directory to use for postmaster sockets during upgrade; default is current working directory; environment variable PGSOCKETDIR"}, {"names": ["-U", "--username="], "signature": "-U username --username= username", "description": "cluster's install user name; environment variable PGUSER"}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "enable verbose internal logging"}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "display version information, then exit"}, {"names": ["--clone"], "signature": "--clone", "description": "Use efficient file cloning (also known as \u201c reflinks \u201d on some systems) instead of copying files to the new cluster. This can result in near-instantaneous copying of the data files, giving the speed advantages of -k / --link while leaving the old cluster untouched. File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_upgrade run will error. At present, it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS."}, {"names": ["--copy"], "signature": "--copy", "description": "Copy files to the new cluster. This is the default. (See also --link , --clone , --copy-file-range , and --swap .)"}, {"names": ["--copy-file-range"], "signature": "--copy-file-range", "description": "Use the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone , sharing physical disk blocks, while on others it may still copy blocks, but do so via an optimized path. At present, it is supported on Linux and FreeBSD."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not restore statistics from the old cluster into the new cluster."}, {"names": ["--set-char-signedness="], "signature": "--set-char-signedness= option", "description": "Manually set the default char signedness of new clusters. Possible values are signed and unsigned . In the C language, the default signedness of the char type (when not explicitly specified) varies across platforms. For example, char defaults to signed char on x86 CPUs but to unsigned char on ARM CPUs. Starting from PostgreSQL 18, database clusters maintain their own default char signedness setting, which can be used to ensure consistent behavior across platforms with different default char signedness. By default, pg_upgrade preserves the char signedness setting when upgrading from an existing cluster. However, when upgrading from PostgreSQL 17 or earlier, pg_upgrade adopts the char signedness of the platform on which it was built. This option allows you to explicitly set the default char signedness for the new cluster, overriding any inherited values. There are two specific scenarios where this option is relevant: If you are planning to migrate to a different platform after the upgrade, you should not use this option. The default behavior is right in this case. Instead, perform the upgrade on the original platform without this flag, and then migrate the cluster afterward. This is the recommended and safest approach. If you have already migrated the cluster to a platform with different char signedness (for example, from an x86-based system to an ARM-based system), you should use this option to specify the signedness matching the original platform's default char signedness. Additionally, it's essential not to modify any data files between migrating data files and running pg_upgrade . pg_upgrade should be the first operation that starts the cluster on the new platform."}, {"names": ["--swap"], "signature": "--swap", "description": "Move the data directories from the old cluster to the new cluster. Then, replace the catalog files with those generated for the new cluster. This mode can outperform --link , --clone , --copy , and --copy-file-range , especially on clusters with many relations. However, this mode creates many garbage files in the old cluster, which can prolong the file synchronization step if --sync-method=syncfs is used. Therefore, it is recommended to use --sync-method=fsync with --swap . Additionally, once the file transfer step begins, the old cluster will be destructively modified and therefore will no longer be safe to start. See Step 17 for details."}, {"names": ["--sync-method="], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_upgrade will recursively open and synchronize all files in the upgraded cluster's 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 upgraded cluster's data directory, its 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": ["-?", "--help"], "signature": "-? --help", "description": "show help, then exit"}], "synopsis": ["pg_upgrade -b oldbindir [ -B newbindir ] -d oldconfigdir -D newconfigdir [ option ...]"], "environment": [{"name": "PGBINOLD", "description": "The old PostgreSQL executable directory; option -b / --old-bindir ."}, {"name": "PGBINNEW", "description": "The new PostgreSQL executable directory; option -B / --new-bindir ."}, {"name": "PGDATAOLD", "description": "The old database cluster configuration directory; option -d / --old-datadir ."}, {"name": "PGDATANEW", "description": "The new database cluster configuration directory; option -D / --new-datadir ."}, {"name": "PGPORTOLD", "description": "The old cluster port number; option -p / --old-port ."}, {"name": "PGPORTNEW", "description": "The new cluster port number; option -P / --new-port ."}, {"name": "PGSOCKETDIR", "description": "Directory to use for postmaster sockets during upgrade; option -s / --socketdir ."}, {"name": "PGUSER", "description": "Cluster's install user name; option -U / --username ."}]}, "comparison_hash": "ed8c09156ba62bb3138b603b905750e0ebd88baadd61089e3fe1a1e8186934e5", "manual_language": "zh"}, "comparison": {"left": "14", "right": "15", "status": "changed", "diff": "--- PostgreSQL 14\n+++ PostgreSQL 15\n@@ -56,6 +56,14 @@\n         \"--link\"\n       ],\n       \"signature\": \"-k --link\"\n+    },\n+    {\n+      \"description\": \"By default, pg_upgrade will wait for all files of the upgraded cluster to be written safely to disk. This option causes pg_upgrade 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+      ],\n+      \"signature\": \"-N --no-sync\"\n     },\n     {\n       \"description\": \"options to be passed directly to the old postgres command; multiple option invocations are appended\","}}