Migrating Postgres cluster from one version to another version (8.4 to 9.0)
Below steps must be performed on the source cluster
o Ensure that the Applications are down for all the databases in the production cluster o Take a backup each database (in binary format) parallely in the cluster with the below command from the Postgres bin directory. This will help perform parallel backups and finish the backup faster. pg_dump -Fc -U pgsql -f /backup/dbname.dmp -v -p 5432 dbname >> /logs/dbname.log 2>> /logs/dbname.log check the status of pg_dump in dbname.log o Take a global dump of the cluster using the below command pg_dumpall -U <superusername> -p 5432 -g > /backup/global.sql o Copy the contents of /etc/sysctl.conf file o Copy the postgresql.conf file o Copy the pg_hba.conf file o Copy pg_ident.conf file (if exists) o If you have ldap configured. Copy the /etc/ldap.conf contents. To find if there any LDAP connections and pg_ident.conf connections, pg_hba.conf file must be checked o Take the list of contrib modules installed o If there is a replication setup like Slony. Stop the slon processes and take a copy of Slon.conf files and slon logfiles (just for reference) o At the database, take the list of schemas, count of tables, count of Indexes and count of functions. Use the following queries after connecting to the database Select pg_size_pretty(pg_database_size(dbname)); -- database size Select distinct schemaname from pg_tables; -- number of schemas in the database Select schemaname, count(tablename) from pg_tables group by schemaname; -- number of tables in a schema Select schemaname, count(indexname) from pg_indexes group by schemaname; -- number of Indexes in the schema Select count(proname) from pg_proc group by proowner; -- number of procedures in the database by o Copy both the backups to the target server Below steps must be performed in the target server o Ensure that Postgresql-8.4 (Solaris 64-bit version) is installed with the necessary options same as the source server. Use pg_config in the source server to the get the installation options. pg_config configure (this is not required if you are untarring and unzipping the installer. This is only helpful when you are using make or gmake to install)
o o o
o o o
o o
Make the entries similar to /etc/sysctl.conf
Create a directory for the data directory with postgres user as the owner with 700 permissions Create a new cluster using ./initdb command. Include options according to source cluster ./initdb D data dir l <logfilename> Copy the postgresql.conf file from the source data directory or make the similar entries Copy the pg_hba.conf from the source directory or make the similar entries Restore each database individually (and parallely) by using the following command from postgres bin ./pg_restore -C -d twitter_oltp -p 5445 v Compare the number of objs with the same queries fired in the source database Change the entries according to source postgresql.conf file and source pg_hba.conf file Note : from pg_proc we can get to know if we are missing any contrib modules