将postgresql群集从9.1升级到9.2时出错

将postgresql群集从9.1升级到9.2时出错,postgresql,postgresql-9.2,Postgresql,Postgresql 9.2,我在亚马逊EC2上使用Ubuntu 12.04 64位。 正在尝试将postgresql从9.1升级到9.2 $ uname -a Linux db2 3.2.0-32-virtual #51-Ubuntu SMP Wed Sep 26 21:53:42 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux $ apt-cache policy postgresql postgresql: Installed: 9.1+136~precise Candidat

我在亚马逊EC2上使用Ubuntu 12.04 64位。 正在尝试将postgresql从9.1升级到9.2

$ uname -a
Linux db2 3.2.0-32-virtual #51-Ubuntu SMP Wed Sep 26 21:53:42 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$ apt-cache policy postgresql
postgresql:
  Installed: 9.1+136~precise
  Candidate: 9.1+136~precise
  Version table:
 *** 9.1+136~precise 0
    500 http://ppa.launchpad.net/pitti/postgresql/ubuntu/ precise/main amd64                 Packages
    100 /var/lib/dpkg/status
 9.1+129ubuntu1 0
    500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
 9.1+129 0
    500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
我所遵循的升级过程是:

$ sudo add-apt-repository ppa:pitti/postgresql
$ sudo apt-get update
$ sudo apt-get install postgres-9.2
$ sudo pg_dropcluster --stop 9.2 main
$ sudo pg_upgradecluster 9.1 main /var/lib/postgresql/9.2
Stopping old cluster...
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
Creating new cluster (configuration: /etc/postgresql/9.2/main, data: /var/lib/postgresql/9.2)...
Moving configuration file /var/lib/postgresql/9.2/postgresql.conf to /etc/postgresql/9.2/main...
Moving configuration file /var/lib/postgresql/9.2/pg_hba.conf to /etc/postgresql/9.2/main...
Moving configuration file /var/lib/postgresql/9.2/pg_ident.conf to /etc/postgresql/9.2/main...
Configuring postgresql.conf to use port 5433...
Disabling connections to the new cluster during upgrade...
Roles, databases, schemas, ACLs...
Fixing hardcoded library paths for stored procedures...
ERROR:  cannot set transaction read-write mode during recovery
Error: Could not fix library paths
Re-enabling connections to the old cluster...
Re-enabling connections to the new cluster...
Error during cluster dumping, removing new cluster
任何帮助都将不胜感激。
谢谢。

问题的根本原因是postgresql.conf中打开了热备份,因此服务器是只读的

通常,如果您在使用通常打包在Debian和Ubuntu中的pg_包装工具时遇到pg_upgradecluster问题,您可以进行手动群集升级:

启动旧服务器 sudo-i-u博士后 对于$psql-tuples only template1-c中的db,请从pg_数据库中选择datname,其中datname不在'template0'、'template1'、'postgres'、'template_postgis'中;;执行pg_dump-Fc-f$db.backup$db;完成 pg_dumpall-globals only>globals.sql 停止旧服务器 initdb在新服务器上创建一个新集群(如果已将其删除)。有了pg_包装器,我想您可以使用pg_createcluster来实现这一点。 启动新服务器;作为postgres用户: psql-f globals.sql 用于*.backup中的备份;执行pg_restore-dbname postgres-create$backup;完成 或者,使用pg_升级工具就地转换数据库,但这可能会混淆pg_包装器


通过使用pg_dumpall命令生成整个集群转储,可以简化这些步骤,但我不太喜欢它。我认为恢复pg_dumpall转储在错误处理方面还有很多需要改进的地方,很难从转储中提取单个数据库或表,而且不能在单个事务中全部恢复。我强烈建议仅对用户/组/角色这样的全局对象使用pg_dumpall,并对单个数据库使用pg_dump per database自定义格式备份,如上所示。

如果需要,请执行升级的一般步骤

就我而言,从第11页到第12页:

sudoapt更新 sudo apt安装postgresql-12 sudo系统控制站postgresql@12-主停止自动创建/自动启动的 pg_dropcluster 12主下降it sudo-u博士后pg_升级集群-v 12 11主 sudo系统控制启动postgresql@12-主要 sudo-u postgres psql启动并测试它
这很奇怪,看起来像是pg_升级问题。如果你在这里没有得到任何回应,我建议你在网上询问。有没有可能从ps say中找到实际的pg_升级命令行?@CraigRinger:pg_upgradecluster是一个Perl脚本。我可能会介入。感谢您的邮件列表建议。这似乎是pg_upgradecluster,pg_包装的一部分。执行实际工作的命令称为pg_upgrade。这是一个用PostgreSQL发布的C程序。pg_upgrade群集应该调用pg_upgrade,但在到达该点之前,它可能会失败。第421行看起来像是您的错误点。错误:从Pg恢复期间无法设置事务读写模式表明它正在热备用模式下运行,这似乎很奇怪。旧集群上的postgresql.conf中的hot_standby是否设置为on?看@CraigRinger:哎哟!你说得对。9.1实例是一个复制从机。嗯。对不起,再次感谢。将重新配置并发回此处。或将服务器从热备份中取出。就像你怀疑的那样。现在偷偷溜出房间。。。