postgresql v9.2升级到9.3步骤

前端之家收集整理的这篇文章主要介绍了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.f2er.com/postgresql/196085.html

猜你在找的Postgre SQL相关文章