我如何在 ubuntu 16.04 上将我的 Postgresql 9.5 升级到 Postgresql 10
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47029055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i upgrade my Postgresql 9.5 to Postgresql 10 on ubuntu 16.04
提问by Manish Yadav
I had a ubuntu machine on which postgresql 9.5 is running with approximately 12 GB of data. Now i want to upgrade my postgresql version from 9.5 to 10. I googled some articals but unable to upgrade and one more thing i do not want to completely uninstall postgres 9.5 and install postgres 10. My postgresql 9.5 settings are:
我有一台运行 postgresql 9.5 的 ubuntu 机器,大约有 12 GB 的数据。现在我想将我的 postgresql 版本从 9.5 升级到 10。我在谷歌上搜索了一些文章但无法升级还有一件事我不想完全卸载 postgres 9.5 并安装 postgres 10。我的 postgresql 9.5 设置是:
1-Postgresql config files are at:
1-Postgresql 配置文件位于:
/opt/PostgreSQL/9.5/
2- Postgresql 10 installed location
2- Postgresql 10 安装位置
/etc/postgresql/10
回答by Hervé Piedvache
The normal process to upgrade on Debian or Ubuntu is this one :
在 Debian 或 Ubuntu 上升级的正常过程是这样的:
Stop the new updated version of PostreSQL :
停止 PostreSQL 的新更新版本:
service postgresql stop
Drop the new updated version cluster to be sure nothing is inside :
删除新的更新版本集群以确保里面没有任何东西:
pg_dropcluster --stop 10 main
Then data migration :
然后数据迁移:
pg_upgradecluster -m upgrade 9.5 main
Then stop previous version of PotsgreSQL :
然后停止以前版本的 PotsgreSQL :
pg_dropcluster 9.5 main --stop
Remove the old version :
删除旧版本:
apt-get autoremove --purge postgresql-9.5
Then just restart PostgreSQL, the new version with database migrated :
然后只需重新启动 PostgreSQL,新版本的数据库已迁移:
service postgresql start
回答by Rajat Srivastava
As already been suggested to use pg_clusters There is no need to stop postgresql when updating to pg10
正如已经建议使用 pg_clusters 更新到 pg10 时无需停止 postgresql
In Ubuntu terminal, Write following commands-
sudo apt-get install postgresql-10
sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
在 Ubuntu 终端中,编写以下命令-
sudo apt-get install postgresql-10
sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
This would firstly install postgresql-10 on your system and then tries to update the server side postgresql using pg_upgradecluster
这将首先在您的系统上安装 postgresql-10,然后尝试使用 pg_upgradecluster 更新服务器端 postgresql
This would also solve your problem that you do not want to remove pg-9.5
这也可以解决您不想删除 pg-9.5 的问题
回答by jira
What do you mean by "unable to upgrade" exactly? Generally you can use pg_upgradeutility to in-place upgrade. You need to have the old and new versions installed separatelly at the same time.
“无法升级”究竟是什么意思?通常,您可以使用pg_upgrade实用程序进行就地升级。您需要同时安装新旧版本。
The pg_upgrade documentation I linked gives exact instructions.
我链接的 pg_upgrade 文档给出了确切的说明。