- メジャーバージョンアップなのでデータのアップグレード作業をやらないといけない
- PostGISを導入している場合は注意が必要
環境
- MacOSX Yosemite 10.10.1
- homebrew 0.9.5
注意点
pg_upgrade実行前に brew reinstall postgis
を実行しろ
手順
PostgreSQLのアップグレード
brew upgrade postgresql
PostGISの再インストール
brew reinstall postgis
これやっとくと新たにインストールされたPostgreSQLにpostgisをインストールしてくれる。
やっとかないとpg_upgradeの途中でライブラリが見当たらないみたいなエラーが出る。
# エラー例
$ pg_upgrade -b /usr/local/Cellar/postgresql/9.3.5_1/bin -B /usr/local/Cellar/postgresql/9.4.0/bin -d /usr/local/var/postgres-9.3 -D /usr/local/var/postgres
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
Checking for invalid "line" user columns ok
Creating dump of global objects ok
Creating dump of database schemas
ok
Checking for presence of required libraries fatal
Your installation references loadable libraries that are missing from the
new installation. You can add these libraries to the new installation,
or remove the functions using them from the old installation. A list of
problem libraries is in the file:
loadable_libraries.txt
Failure, exiting
$ cat loadable_libraries.txt
Could not load library "$libdir/rtpostgis-2.1"
ERROR: could not access file "$libdir/rtpostgis-2.1": No such file or directory
Could not load library "$libdir/postgis-2.1"
ERROR: could not access file "$libdir/postgis-2.1": No such file or directory
データのアップグレード
いままで使用していたデータディレクトリをコピー
cp -r /usr/local/var/postgres /usr/local/var/postgres-9.3
データディレクトリを初期化
rm -rf /usr/local/var/postgres/*
initdb /usr/local/var/postgres
pg_upgradeでデータを移行
pg_upgrade -b /usr/local/Cellar/postgresql/9.3.5_1/bin -B /usr/local/Cellar/postgresql/9.4.0/bin -d /usr/local/var/postgres-9.3 -D /usr/local/var/postgres