微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql v9.2升级到9.3步骤

系统CentOS 6.4 64bit,pgsql9.2版本数据库目录为 /data/pgsql/data

安装pgsql9.3:

# rpm -ivh http://yum.pgrpms.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

# yum install postgresql93 postgresql93-libs postgresql93-server postgresql93-contrib postgresql93-devel postgresql93-test

更新环境变量 ~/.bash_profile:

PATH=$PATH:$HOME/bin:/usr/pgsql-9.3/bin
编辑 /etc/init.d/postgresql-9.3
修改为预期路径
PGDATA=/data/pgsql/data93
PGLOG=/data/pgsql/pgstartup.log

创建新数据库集群目录
# mkdir /data/psql/data93
# chown postgres:postgres /data/psql/data93
初始化新数据库集群
# su - postgres
-bash-4.1$ /usr/pgsql-9.3/bin/initdb -E utf8 --locale=zh_CN.UTF8 -D /data/pgsql/data93/
停止当先数据库服务,然后执行升级数据库命令
-bash-4.1$ /usr/pgsql-9.3/bin/pg_upgrade -d /data/pgsql/data -D /data/pgsql/data93/ \
  -b /usr/pgsql-9.2/bin -B /usr/pgsql-9.3/bin
过程信息如下
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is a superuser                       ok
Checking for prepared transactions                          ok
Checking for reg* system OID user data types                ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok
Checking for presence of required libraries                 ok
Checking database user is a superuser                       ok
Checking for prepared transactions                          ok

If pg_upgrade fails after this point,you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows on the new cluster                        ok
Deleting files from new pg_clog                             ok
copying old pg_clog to new server                           ok
Setting next transaction ID for new cluster                 ok
Setting oldest multixact ID on new cluster                  ok
Resetting WAL archives                                      ok
Setting frozenxid counters in new cluster                   ok
Restoring global objects in the new cluster                 ok
Adding support functions to new cluster                     ok
Restoring database schemas in the new cluster
                                                            ok
Removing support functions from new cluster                 ok
copying user relation files
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to analyze new cluster                      ok
Creating script to delete old cluster                       ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,once you start the new server,consider running:
    analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    delete_old_cluster.sh

把老版本的配置文件,如pg_hba.conf,pg_ident.conf,postgresql.conf直接复制或者同步更新到新版数据库集群目录中

相关升级文档 /usr/share/doc/postgresql93-9.3.0/README.rpm-dist

升级完成

Add: pg_hba.conf的设置可能会使得pg_upgrade执行时报无法连接数据库错误。这时候可以把local小节暂时改为trust来解决

原文地址:https://www.jb51.cc/postgresql/196085.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐