{"id":4653,"date":"2025-11-22T21:44:43","date_gmt":"2025-11-22T13:44:43","guid":{"rendered":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/?p=4653"},"modified":"2025-11-22T21:44:43","modified_gmt":"2025-11-22T13:44:43","slug":"archlinux%e4%b8%8a%e7%9a%84postgresql%e5%8d%87%e7%b4%9a","status":"publish","type":"post","link":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2025\/11\/archlinux%e4%b8%8a%e7%9a%84postgresql%e5%8d%87%e7%b4%9a\/","title":{"rendered":"Archlinux\u4e0a\u7684postgresql\u5347\u7d1a"},"content":{"rendered":"\n<p>\u5b98\u65b9\u6709\u8aaa\u660e\uff0c\u4f9d\u7167\u8aaa\u660e\u9032\u884c\u5c31\u53ef\u4ee5\uff1a<a href=\"https:\/\/wiki.archlinux.org\/title\/PostgreSQL#Upgrading_PostgreSQL\">https:\/\/wiki.archlinux.org\/title\/PostgreSQL#Upgrading_PostgreSQL<\/a><\/p>\n\n\n\n<p>\u4f46\uff0c\u6211\u592a\u4e45\u6c92\u53bb\u6ce8\u610f\uff0c\u6240\u4ee5\u4f9d\u7167\u7a0b\u5e8f\u9032\u884c\u6642\uff0c\u767c\u73fe\u6211\u820a\u7684\u8cc7\u6599\u5eab\u662f 16\uff0c\u76ee\u524d\u7248\u672c\u662f 18\u3002\u5347\u7d1a\u7a0b\u5e8f\u9700\u8981\u820a\u7684 16 \u7684\u6a94\u6848\u624d\u53ef\u4ee5\uff0c\u6240\u4ee5\u9019\u908a\u7d00\u9304\u904e\u7a0b\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53d6\u5f97\u8cc7\u6599\u5eab\u6a94\u6848\u6240\u4f7f\u7528\u7684\u7248\u672c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/var\/lib\/postgres\/data\/PG_VERSION<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u505c\u6b62\u670d\u52d9<\/h3>\n\n\n\n<p>\u56e0\u70ba\u662f\u670d\u52d9\u7121\u6cd5\u555f\u52d5\u624d\u767c\u73fe postgresql \u9700\u8981\u5347\u7d1a\uff0c\u6240\u4ee5\u5c31\u4e0d\u9700\u8981\u505c\u6b62\u670d\u52d9\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88dd\u65b0\u7248\u7684\u6a94\u6848<\/h3>\n\n\n\n<p>\u9019\u6b65\u9a5f\u4e5f\u8df3\u904e\u4e86\uff0c\u56e0\u70ba\u6bcf\u6b21\u90fd\u662f\u5168\u6a5f\u5347\u7d1a\uff0c\u6240\u4ee5\u5df2\u7d93\u5b89\u88dd\u597d\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u642c\u79fb\u6a94\u6848<\/h3>\n\n\n\n<p>\u4e3b\u8981\u662f\u628a\u539f\u4f86\u7684 <code>\/var\/lib\/postgres\/data<\/code> \u66f4\u540d\uff0c\u4e26\u5efa\u7acb\u65b0\u7684\u8cc7\u6599\u76ee\u9304\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mv \/var\/lib\/postgres\/data \/var\/lib\/postgres\/olddata\nsudo mkdir \/var\/lib\/postgres\/data \/var\/lib\/postgres\/tmp\nsudo chown postgres:postgres \/var\/lib\/postgres\/data \/var\/lib\/postgres\/tmp<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6539\u7528 postgres \u4f7f\u7528\u8005\u8eab\u4efd\u5efa\u7acb\u8cc7\u6599\u5eab<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres -H \/bin\/bash\ncd \/var\/lib\/postgres\/tmp\ninitdb -D \/var\/lib\/postgres\/data --locale=C.UTF-8 --encoding=UTF8 --data-checksums<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5347\u7d1a<\/h3>\n\n\n\n<p>\u4e00\u6a23\u662f postgres \u4f7f\u7528\u8005\u8eab\u4efd\uff0c\u57f7\u884c pg_upgrade \u4f86\u5347\u7d1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pg_upgrade -b \/opt\/pgsql-16\/bin -B \/usr\/bin -d \/var\/lib\/postgres\/olddata -D \/var\/lib\/postgres\/data<\/code><\/pre>\n\n\n\n<p>\u6211\u662f\u5728\u9019\u6b65\u9a5f\u51fa\u932f\u7684\uff0c\u56e0\u70ba\u6211\u5df2\u7d93\u5347\u7d1a\u5230 18\u3002 <code>\/opt\/pgsql-16\/bin<\/code> \u9019\u500b\u76ee\u9304\u662f\u5b89\u88dd postgresql-old-upgrade \u5957\u4ef6\u624d\u6703\u6709\u7684\uff0c\u901a\u5e38\u5b89\u88dd\u4e86 postgresql 18\uff0cpostgresql-old-upgrade \u88e1\u9762\u7684\u6a94\u6848\u5c31\u662f <code>\/opt\/pgsql-17\/bin<\/code> <\/p>\n\n\n\n<p>\u53c3\u8003\u4e86 Grok \u7684\u56de\u7b54\uff0c\u5c0d postgresql-old-upgrade \u9032\u884c\u964d\u7d1a\u4e86\uff0c\u5148\u5230 <a href=\"https:\/\/archive.archlinux.org\/packages\/p\/postgresql-old-upgrade\/\">https:\/\/archive.archlinux.org\/packages\/p\/postgresql-old-upgrade\/<\/a> \u4e0b\u8f09\u820a\u7248\u7684\u6a94\u6848 postgresql-old-upgrade-16.10-1-x86_64.pkg.tar.zst \uff0c\u7136\u5f8c\u5b89\u88dd<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pacman -U postgresql-old-upgrade-16.10-1-x86_64.pkg.tar.zst<\/code><\/pre>\n\n\n\n<p>\u518d\u6b21\u57f7\u884c pg_upgrade\uff0c\u6703\u767c\u73fe\u6709\u4ee5\u4e0b\u932f\u8aa4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>error while loading shared libraries: libicui18n.so.76\nerror while loading shared libraries: libicuuc.so.76<\/code><\/pre>\n\n\n\n<p>\u53ea\u80fd\u518d\u6b21\u5b89\u88dd icu76\uff0cGrok \u8aaa\u53ef\u4ee5\u7528 yay \u5b89\u88dd\uff0c\u6b64\u6642\u8981\u96e2\u958b postgres \u8eab\u4efd\u4f86\u5b89\u88dd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yay -Ss icu76<\/code><\/pre>\n\n\n\n<p>\u5b89\u88dd\u5f8c\uff0c\u518d\u6b21\u5207\u63db\u70ba postgres \u4f7f\u7528\u8005\u5e33\u865f\u57f7\u884c pg_upgrade\uff0c\u9019\u6642\u5019\u662f\u8aaa\u5c11\u4e86 libLLVM.so.20.1\u3002\u53c8\u518d\u96e2\u958b postgres \u8eab\u4efd\uff0c\u7528\u4ee5\u4e0b\u6307\u4ee4\u5b89\u88dd llvm 20 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yay -Syu llvm20<\/code><\/pre>\n\n\n\n<p>\u518d\u5207\u63db\u70ba postgres \u8eab\u4efd\uff0c\u57f7\u884c pg_upgrade\uff0c\u5c31\u9806\u5229\u5b8c\u6210\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u555f\u52d5\u670d\u52d9<\/h3>\n\n\n\n<p>\u57f7\u884c <code>exit<\/code> \u96e2\u958b postgres \u8eab\u4efd\uff0c\u6aa2\u67e5\u4ee5\u4e0b\u6a94\u6848\uff0c\u4e3b\u8981\u662f\u8ddf\u4e4b\u524d <code>\/var\/lib\/postgres\/olddata<\/code> \u76ee\u9304\u4e0b\u7684\u505a\u6bd4\u5c0d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/var\/lib\/postgres\/data\/postgresql.conf\n\/var\/lib\/postgres\/data\/pg_hba.conf<\/code><\/pre>\n\n\n\n<p>\u8a2d\u5b9a\u6539\u597d\u4ee5\u5f8c\uff0c\u555f\u52d5 postgresql \u670d\u52d9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start postgresql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6e05\u7406<\/h3>\n\n\n\n<p>\u5207\u63db\u70ba postgres \u8eab\u4efd\uff0c\u57f7\u884c\u6e05\u7406<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/bin\/vacuumdb --all --analyze-in-stages --missing-stats-only\n\/usr\/bin\/vacuumdb --all --analyze-only\n<\/code><\/pre>\n\n\n\n<p>\u4f9d\u7167\u5347\u7d1a\u5f8c\u7684\u6307\u4ee4\uff0c\u57f7\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/delete_old_cluster.sh<\/code><\/pre>\n\n\n\n<p>\u522a\u9664 olddata \u8ddf tmp<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm -rf \/var\/lib\/postgres\/olddata\nsudo rm -rf \/var\/lib\/postgres\/tmp<\/code><\/pre>\n\n\n\n<p>\u81f3\u6b64\uff0c\u5927\u529f\u544a\u6210\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u6709\u8aaa\u660e\uff0c\u4f9d\u7167\u8aaa\u660e\u9032\u884c\u5c31\u53ef\u4ee5\uff1ahttps:\/\/wiki.archlinux.org\/title\/PostgreSQL#Upgrading_PostgreSQL \u4f46\uff0c\u6211\u592a\u4e45\u6c92\u53bb\u6ce8\u610f\uff0c\u6240\u4ee5\u4f9d\u7167\u7a0b\u5e8f\u9032\u884c\u6642\uff0c\u767c\u73fe\u6211\u820a\u7684\u8cc7\u6599\u5eab\u662f 16\uff0c\u76ee\u524d\u7248\u672c\u662f 18\u3002\u5347\u7d1a\u7a0b\u5e8f\u9700\u8981\u820a\u7684 16 \u7684\u6a94\u6848\u624d\u53ef\u4ee5\uff0c\u6240\u4ee5\u9019\u908a\u7d00\u9304\u904e\u7a0b\uff1a \u53d6\u5f97\u8cc7\u6599\u5eab\u6a94\u6848\u6240\u4f7f\u7528\u7684\u7248\u672c \u505c\u6b62\u670d\u52d9 \u56e0\u70ba\u662f\u670d\u52d9\u7121\u6cd5\u555f\u52d5\u624d\u767c\u73fe postgresql \u9700\u8981\u5347\u7d1a\uff0c\u6240\u4ee5\u5c31\u4e0d\u9700\u8981\u505c\u6b62\u670d\u52d9\u3002 \u5b89\u88dd\u65b0\u7248\u7684\u6a94\u6848 \u9019\u6b65\u9a5f\u4e5f\u8df3\u904e\u4e86\uff0c\u56e0\u70ba\u6bcf\u6b21\u90fd\u662f\u5168\u6a5f\u5347\u7d1a\uff0c\u6240\u4ee5\u5df2\u7d93\u5b89\u88dd\u597d\u4e86\u3002 \u642c\u79fb\u6a94\u6848 \u4e3b\u8981\u662f\u628a\u539f\u4f86\u7684 \/var\/lib\/postgres\/data \u66f4\u540d\uff0c\u4e26\u5efa\u7acb\u65b0\u7684\u8cc7\u6599\u76ee\u9304\u3002 \u6539\u7528 postgres \u4f7f\u7528\u8005\u8eab\u4efd\u5efa\u7acb\u8cc7\u6599\u5eab \u5347\u7d1a \u4e00\u6a23\u662f postgres \u4f7f\u7528\u8005\u8eab\u4efd\uff0c\u57f7\u884c pg_upgrade \u4f86\u5347\u7d1a \u6211\u662f\u5728\u9019\u6b65\u9a5f\u51fa\u932f\u7684\uff0c\u56e0\u70ba\u6211\u5df2\u7d93\u5347\u7d1a\u5230 18\u3002 \/opt\/pgsql-16\/bin \u9019\u500b\u76ee\u9304\u662f\u5b89\u88dd postgresql-old-upgrade \u5957\u4ef6\u624d\u6703\u6709\u7684\uff0c\u901a\u5e38\u5b89\u88dd\u4e86 postgresql 18\uff0cpostgresql-old-upgrade \u88e1\u9762\u7684\u6a94\u6848\u5c31\u662f \/opt\/pgsql-17\/bin \u53c3\u8003\u4e86 Grok \u7684\u56de\u7b54\uff0c\u5c0d postgresql-old-upgrade \u9032\u884c\u964d\u7d1a\u4e86\uff0c\u5148\u5230 https:\/\/archive.archlinux.org\/packages\/p\/postgresql-old-upgrade\/ \u4e0b\u8f09\u820a\u7248\u7684\u6a94\u6848 postgresql-old-upgrade-16.10-1-x86_64.pkg.tar.zst \uff0c\u7136\u5f8c\u5b89\u88dd \u518d\u6b21\u57f7\u884c pg_upgrade\uff0c\u6703\u767c\u73fe\u6709\u4ee5\u4e0b\u932f\u8aa4 \u53ea\u80fd\u518d\u6b21\u5b89\u88dd icu76\uff0cGrok \u8aaa\u53ef\u4ee5\u7528 yay \u5b89\u88dd\uff0c\u6b64\u6642\u8981\u96e2\u958b postgres \u8eab\u4efd\u4f86\u5b89\u88dd\u3002 \u5b89\u88dd\u5f8c\uff0c\u518d\u6b21\u5207\u63db\u70ba &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2025\/11\/archlinux%e4%b8%8a%e7%9a%84postgresql%e5%8d%87%e7%b4%9a\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Archlinux\u4e0a\u7684postgresql\u5347\u7d1a&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[30,246],"class_list":["post-4653","post","type-post","status-publish","format-standard","hentry","category-linux-","tag-archlinux","tag-postgresql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2MOxp-1d3","_links":{"self":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/4653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/comments?post=4653"}],"version-history":[{"count":1,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/4653\/revisions"}],"predecessor-version":[{"id":4654,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/4653\/revisions\/4654"}],"wp:attachment":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/media?parent=4653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/categories?post=4653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/tags?post=4653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}