在Ubuntu上升级PostgreSQL,可参考以下步骤:
pg_dumpall -U postgres -f backup.sql命令备份所有数据库。sudo apt update。sudo apt install postgresql-15。sudo systemctl restart postgresql。pg_dumpall -U postgres -f backup.sql命令。sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list',然后导入密钥wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -,并更新包列表sudo apt update。sudo apt install postgresql-15。sudo systemctl stop postgresql。sudo /usr/lib/postgresql/15/bin/pg_ctl initdb -D /var/lib/postgresql/15/main/。sudo -u postgres /usr/lib/postgresql/15/bin/pg_upgrade -c -b /usr/lib/postgresql/14/bin -B /usr/lib/postgresql/15/bin -d /var/lib/postgresql/14/main -D /var/lib/postgresql/15/main。sudo -u postgres /usr/lib/postgresql/15/bin/pg_upgrade -b /usr/lib/postgresql/14/bin -B /usr/lib/postgresql/15/bin -d /var/lib/postgresql/14/main -D /var/lib/postgresql/15/main -o '-c config_file=/etc/postgresql/14/main/postgresql.conf' -O '-c config_file=/etc/postgresql/15/main/postgresql.conf'。sudo -u postgres /usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages。sudo systemctl start postgresql@15-main。升级完成后,可使用psql -V检查版本,确保升级成功。