系統CentOS 6.4 64bit,pgsql9.2版本數據庫目錄爲 /data/pgsql/data sql
安裝pgsql9.3: shell
# 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
# 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直接複製或者同步更新到新版數據庫集羣目錄中 centos
相關升級文檔 /usr/share/doc/postgresql93-9.3.0/README.rpm-dist bash
升級完成 ide
Add: pg_hba.conf的設置可能會使得pg_upgrade執行時報沒法鏈接數據庫錯誤。這時候能夠把local小節暫時改成trust來解決 post