我的OpenProject管理软件安装了默认的postgresql 10.
我想升级我的Postgres数据库而不丢失数据库中的数据.
我在网上搜索,找不到一个逐步升级postgresql的方法.
请你指导我安装新的数据库,所有数据都应该在新的数据库中.
我的OpenProject管理软件安装了默认的postgresql 10.
我想升级我的Postgres数据库而不丢失数据库中的数据.
我在网上搜索,找不到一个逐步升级postgresql的方法.
请你指导我安装新的数据库,所有数据都应该在新的数据库中.
A) First create a backup of all the databases for that (You can continue from B if you dont need a backup)
sudo su postgres
pg_dumpall > backup.sql
B) Upgrade to PostgreSQL12
sudo apt-get update
sudo apt-get install postgresql-12 postgresql-server-dev-12
sudo systemctl stop postgresql.service
/usr/lib/postgresql/12/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/10/main \
--new-datadir=/var/lib/postgresql/12/main \
--old-bindir=/usr/lib/postgresql/10/bin \
--new-bindir=/usr/lib/postgresql/12/bin \
--old-options '-c config_file=/etc/postgresql/10/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf'
exit
#change port to 5432
sudo vim /etc/postgresql/12/main/postgresql.conf
#change port to 5433
sudo vim /etc/postgresql/10/main/postgresql.conf
sudo systemctl start postgresql.service
sudo su postgres
psql -c "SELECT version();"
./analyze_new_cluster.sh
#uninstalls postgres packages
sudo apt-get remove postgresql-10 postgresql-server-dev-10
#removes the old postgresql directory
sudo rm -rf /etc/postgresql/10/
#login as postgres user
sudo su postgres
#delete the old cluster data
./delete_old_cluster.sh
NOTE:.更改postgresql.形态和pg_hba.按您的要求配置
PS:请随意 comments 您的问题、建议或任何其他您想建议的修改