如何为ubuntu18.04升级到Postgres 11?

nic*_*lom 6 postgresql ubuntu

如标题所示,我想将Postgresql-10升级到Postgresql-11。我正在使用ubuntu-18.04。

小智 10

您可以在Ubuntu上按照此博客设置Postgresql-11进行操作。我发现这很简单。

在Ubuntu机器上添加PostgreSQL软件包存储库

echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main 11" | sudo tee /etc/apt/sources.list.d/pgsql.list
Run Code Online (Sandbox Code Playgroud)

添加PostgreSQL软件包存储库的GPG密钥:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Run Code Online (Sandbox Code Playgroud)

更新APT并安装postgresql-11

sudo apt update && sudo apt install postgresql-11
Run Code Online (Sandbox Code Playgroud)

  • 这不只是安装将与第一个实例一起运行的第二个实例吗? (3认同)
  • @dangel会的。我遵循了有关如何删除第一个教程的指南:https://www.paulox.net/2019/05/28/upgrading-postgresql-from-version-10-to-11-on-ubuntu-19-04-disco -dingo / (2认同)

Sam*_*ody 9

将 Postgres 升级到最新版本(当前为 13)或中间版本(例如 11),应通过运行:

sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
Run Code Online (Sandbox Code Playgroud)

这记录在https://wiki.postgresql.org/wiki/Apt
这会在您的计算机上运行 bash 脚本。如果您想手动运行这些步骤,请查看那里。

安装 Postgres 后,在 Ubuntu 上升级的最简单方法是使用pg_upgradecluster

  1. 备份您的数据。你将删除数据库,所以没有游戏!
sudo -u postgres pg_dumpall > all.sql
Run Code Online (Sandbox Code Playgroud)
  1. 升级。
// Install latest Postgres. Use `postgresql-11` for v11 instead of `postgresql` for latest.   
sudo apt-get install -y postgresql
    
// The install sets up a cluster, which needs then to be removed for the upgrade. 
// Stop and remove the newly installed cluster. Use `11` instead of `13` for v11
sudo pg_dropcluster 13 main --stop
    
// Upgrade the db. Takes the OLD version and OLD schema as required arguments
sudo pg_upgradecluster 10 main
    
// Test. Once you are satisfied, remove OLD cluster.
sudo pg_dropcluster 10 main
Run Code Online (Sandbox Code Playgroud)