viv*_*lan 27 postgresql openproject ubuntu-18.04
我的 OpenProject 管理软件安装了默认的 postgresql 10。目前 postgresql DB 是 12,它有很多新功能。
我想在不丢失数据库中的数据的情况下升级我的 Postgres 数据库。我的系统是 ubuntu 18.04 并托管了 openproject。
我在网上搜索,找不到升级 postgresql 的步骤。
你能指导我安装新数据库吗,所有数据都应该在新数据库中。谢谢你的帮助。
Pav*_*ani 74
A) 首先为此创建所有数据库的备份(如果不需要备份,可以从 B 继续)
sudo su postgres
Run Code Online (Sandbox Code Playgroud)
pg_dumpall > backup.sql
Run Code Online (Sandbox Code Playgroud)
B) 升级到 PostgreSQL12
sudo apt-get update
sudo apt-get install postgresql-12 postgresql-server-dev-12
Run Code Online (Sandbox Code Playgroud)
sudo systemctl stop postgresql.service
Run Code Online (Sandbox Code Playgroud)
/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'
Run Code Online (Sandbox Code Playgroud)
exit
Run Code Online (Sandbox Code Playgroud)
sudo vim /etc/postgresql/12/main/postgresql.conf
#change port to 5432
sudo vim /etc/postgresql/10/main/postgresql.conf
#change port to 5433
Run Code Online (Sandbox Code Playgroud)
sudo systemctl start postgresql.service
Run Code Online (Sandbox Code Playgroud)
sudo su postgres
Run Code Online (Sandbox Code Playgroud)
psql -c "SELECT version();"
Run Code Online (Sandbox Code Playgroud)
./analyze_new_cluster.sh
Run Code Online (Sandbox Code Playgroud)
sudo apt-get remove postgresql-10 postgresql-server-dev-10
#uninstalls postgres packages
sudo rm -rf /etc/postgresql/10/
#removes the old postgresql directory
sudo su postgres
#login as postgres user
./delete_old_cluster.sh
#delete the old cluster data
Run Code Online (Sandbox Code Playgroud)
注意:根据您的要求更改 postgresql.conf 和 pg_hba.conf
PS:请随意评论您的问题、建议或您想提出的任何其他修改
viv*_*lan 21
psql --version sudo -u postgres psql pg_dumpall > alldbs.sql
Run Code Online (Sandbox Code Playgroud)
(此命令将从 postgresql db 备份所有数据库)然后从 postgres 用户退出,然后:
在终端内运行这些命令:
psql --version sudo -u postgres psql pg_dumpall > alldbs.sql
Run Code Online (Sandbox Code Playgroud)
重启 postgresql 服务:
sudo systemctl restart postgresql
Run Code Online (Sandbox Code Playgroud)
登录postgres:
su - postgres
Run Code Online (Sandbox Code Playgroud)
检查版本:
psql --version
Run Code Online (Sandbox Code Playgroud)
我已经完成了上述步骤,我可以更新 DBand 恢复所有数据。
| 归档时间: |
|
| 查看次数: |
29345 次 |
| 最近记录: |