2012-10-17 50 views
3

我在Amazon EC2上的Ubuntu 12.04 64位上。 尝试将postgresql从9.1升级到9.2。将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 

任何帮助,将不胜感激。 谢谢。

+0

这很奇怪,看起来像一个'pg_upgrade'问题。如果你在这里没有得到任何答复,我会建议在[pgsql-general mailing list](http://archives.postgresql.org/pgsql-general/)上提问。你可以从'ps'中找出实际的'pg_upgrade'命令行吗? –

+0

@CraigRinger:pg_upgradecluster是一个Perl脚本。 https://gist.github.com/3909063我可以介入它。感谢您的邮件列表建议。 – onk

+0

似乎是'pg_upgradecluster',是'pg_wrapper'的一部分。执行实际工作的命令称为“pg_upgrade”。这是一个使用PostgreSQL分发的C程序。 'pg_upgradecluster'应该调用'pg_upgrade',但它看起来可能会在它到达该点之前失败。 –

回答

4

您的问题的根本原因是hot_standbyonpostgresql.conf,所以服务器是只读的。

一般情况下,如果你从通常打包在Debian和Ubuntu的pg_wrapper工具具有pg_upgradecluster问题,你可以做一个人工集群,而不是升级:

  • 启动旧服务器
  • sudo -i -u postgres
  • for db in $(psql --tuples-only template1 -c "select datname from pg_database where datname not in ('template0','template1','postgres','template_postgis');"); do pg_dump -Fc -f $db.backup $db; done
  • pg_dumpall --globals-only > globals.sql
  • 停止旧的服务器
  • initdb如果删除了新服务器上的新群集,与pg_wrapper我想你使用pg_createcluster为此。
  • 启动新服务器;并且还为postgres用户:
  • psql -f globals.sql
  • for backup in *.backup; do pg_restore --dbname postgres --create $backup; done

或者,使用pg_upgrade工具工具就地转换您的数据库,但可能会混淆pg_wrapper

可以通过使用pg_dumpall命令来完成整个群集转储来简化这些步骤,但我不太喜欢它。我认为恢复pg_dumpall转储在错误处理方面有很多不足之处,很难从转储中提取单个数据库或表,并且它不能在单个事务中恢复。如上所示,我强烈希望仅将pg_dumpall用于全局用户/用户/组/角色,以及针对单个数据库的每个数据库自定义格式备份的pg_dump

+0

或者让服务器退出hot_standby。像你怀疑的一样。 (现在偷偷溜出房间......) – onk

相关问题