PostgreSQL can be upgrade can be done in following two methods.
A. using pg_upgrade
B. using pg_dump and pg_restore
Detail steps are as explained bellow
A) pg_upgrade 9.3 from 9.1
1. Take full system downtime and stop streaming replication
2. Take full dump of database from Old 9.1 version.
3. Install New version PostgreSQL9.3 under new location say /usr/lib/postgresql/9.3/
4. Stop both(V9.1 and 9.3) the databases.
$/usr/lib/postgresql/ 9.1 /bin/pg_ctl -D /usr/lib/postgresql/ 9.1 /main stop $/usr/lib/postgresql/ 9.3 /bin/pg_ctl -D /usr/lib/postgresql/ 9.3 /main stop |
5. Run pg_upgrade
- Please make sure that the port no. 50432 is free and no other process is using it. 50432 is used for pg_upgread.
- Command format
pg_upgrade -b oldbindir -B newbindir -d olddatadir -D newdatadir [option...] |
- Consider old as 9.1 database and new as 9.3 database directory
/usr/lib/postgresql/
9.3
/bin/pg_upgrade -b /usr/lib/postgresql/
9.1
/bin -B /usr/lib/postgresql/
9.3
/bin -d /var/lib/postgresql/
9.1
/main/ -D /var/lib/postgresql/
9.3
/main/ -O
"-c config_file=/etc/postgresql/9.3/main/postgresql.conf"
-o
"-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
6. Restore pg_hba.conf from old installation to new.
7. Start new v9.3 database.
8. Post-Upgrade processing: If any post-upgrade processing is required, pg_upgrade will issue warnings as it completes. It will also generate script files that must be run by the administrator. The script files will connect to each database that needs post-upgrade processing. Each script should be run using:
psql --username postgres --file script.sql postgres |
9. Statistics : Because optimizer statistics are not transferred by pg_upgrade, you will be instructed to run a command to regenerate that information at the end of the upgrade. You might need to set connection parameters to match your new cluster.
10. Configure: streaming replication
10. Configure: streaming replication
Reference:
B) pg_dump 9.1 and pg_restore in 9.3
1. Take full system down time and stop Streaming replication
2. Take full database dump from old 9.1 server
3. Stop 9.1 server
4. Install New version 9.3.
5. Create all required role and databases.
6. Restore the 9.1 database dump on 9.3
7. Restore pg_hba.conf from old installation to new.
Reference:
Awesome!!
ReplyDeleteThanks for sharing.
Thanks for sharing this useful Information !!
ReplyDeleteRead How to Install and configure PostgreSQL-9.3 in CentOS 6.6