Post AzKaHr3TSWYMmmRO88 by XYenon@pleroma.xyenon.bid
(DIR) More posts by XYenon@pleroma.xyenon.bid
(DIR) Post #AzKaHr3TSWYMmmRO88 by XYenon@pleroma.xyenon.bid
2025-10-18T10:37:19.466671Z
1 likes, 0 repeats
成功将 PostgreSQL 从 16 升级到 17 了,在 NixOS 上大概是如下操作的:记录正在运行的 postgres 16 的路径,如 /nix/store/5wnxrk9la0s8dqhd75scgn96vd4ij2c8-postgresql-and-plugins-16.10/bin将配置里的 services.postgresql.package 修改为 17,用到数据库的服务全部 enable = falsenh os switch停止 postgres:sudo systemctl stop postgresql.servicesudo -iu postgrescd /var/lib/postgresqlpg_upgrade -b "/nix/store/5wnxrk9la0s8dqhd75scgn96vd4ij2c8-postgresql-and-plugins-16.10/bin" -B /run/current-system/sw/bin -d /var/lib/postgresql/16 -D /var/lib/postgresql/17 --jobs=$(nproc) --clone --check没有问题的话去掉 --check 再跑一遍数据就迁移好了然后启动 postgres (sudo systemctl start postgresql.service),根据输出的提示运行:psql < update_extensions.sql/run/current-system/sw/bin/vacuumdb --all --analyze-in-stages最后再将第 2 步里 enable = false 的服务改回来,nh os switch 就好啦