Skip to content

Instantly share code, notes, and snippets.

@tokumine
Created September 30, 2011 01:37
Show Gist options
  • Save tokumine/1252442 to your computer and use it in GitHub Desktop.
Save tokumine/1252442 to your computer and use it in GitHub Desktop.
OSX notes on postgres 9.0 + postgis 1.5.3 -> postgres 9.1.1 + postgis 2.0.0 SVN
The aim here:
1. upgrade postgres
2. then upgrade postgis
For [1], we'll use pg_upgrade to migrate our data.
on OSX, postgres is installed in usr/local using a symlinked pgsql pointing to pgsql-9.0
1. brew install postgresql (9.1.1 = https://github.com/fragility/homebrew/blob/pgsql/Library/Formula/postgresql.rb)
2. brew install postgis (installs 1.5.3 which you will need for migration)
3. remove old usr/local/pgsql -> pgsql-9.0 symlink
4. create new symlink: pgsql -> /usr/local/Cellar/postgresql/9.1.1/
5. ensure postgres is running: launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
6. initdb --encoding=UTF8 --locale=en_US (this must match locale of your 9.0 DB for pg_upgrade to work)
7. stop postgres: launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
8. ensure old postgres doesn't have stray postmaster.pids anywhere and all the postgres processes are cleared out
9. you should have a fresh install at /usr/local/pgsql and old install at /usr/local/pgsql-9.0. All servers should be turned off and the new server should be initialised.
10. migrate data: pg_upgrade -d /usr/local/pgsql-9.0/data -D /usr/local/pgsql/data -b /usr/local/pgsql-9.0/bin -B /usr/local/pgsql/bin
11. Check output and fix any errors. Should eventually look like [1]
12. start db (+ verify in htop): launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
13. vacuum analyze new database: vacuumdb --all --analyze-only
14. check with your apps. this should be a like for like update to 9.1.1. postgis 2 next up.
upgrade pgadmin: http://wwwmaster.postgresql.org/download/mirrors-ftp/pgadmin3/release/v1.14.0/osx/pgadmin3-1.14.0.dmg
[1] pg_upgrade output
Performing Consistency Checks
-----------------------------
Checking current, bin, and data directories ok
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 catalog dump ok
Checking for prepared transactions ok
Checking for presence of required libraries ok
| If pg_upgrade fails after this point, you must
| re-initdb the new cluster before continuing.
| You will also need to remove the ".old" suffix
| from /usr/local/pgsql-9.0/data/global/pg_control.old.
Performing Upgrade
------------------
Adding ".old" suffix to old global/pg_control ok
Analyzing all rows in the new cluster ok
Freezing all rows on the new cluster ok
Deleting new commit clogs ok
Copying old commit clogs to new server ok
Setting next transaction id for new cluster ok
Resetting WAL archives ok
Setting frozenxid counters in new cluster ok
Creating databases in the new cluster ok
Adding support functions to new cluster ok
Restoring database schema to new cluster psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:48955: WARNING: column "iso" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:48955: WARNING: column "name_0" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:48955: WARNING: column "name_1" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:48955: WARNING: column "name_2" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:103324: WARNING: column "iso" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:103324: WARNING: column "name_0" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:103324: WARNING: column "name_1" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
psql:/usr/local/Cellar/postgresql/9.1.1/pg_upgrade_dump_db.sql:103324: WARNING: column "name_2" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
ok
Removing support functions from new cluster ok
Restoring user relation files
ok
Setting next oid for new cluster ok
Creating script to delete old cluster ok
Upgrade complete
----------------
| Optimizer statistics are not transferred by pg_upgrade
| so consider running:
| vacuumdb --all --analyze-only
| on the newly-upgraded cluster.
| Running this script will delete the old cluster's data files:
| /usr/local/Cellar/postgresql/9.1.1/delete_old_cluster.sh
@mischa
Copy link

mischa commented Feb 14, 2012

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment