Help us understand the problem. What is going on with this article?

homebrewで PostgreSQL 9.3へバージョンアップ方法

More than 5 years have passed since last update.

勝手にbrew updgrade postgresqlを実行してしまったら、下記のエラーで起動出来なくなりました

/usr/local/var/postgres/server.log
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.0.

解決方法

参照リンクのままですが

  • サービスを停止する
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  • 9.3バージョンのデータフォルダを作成する
initdb /usr/local/var/postgres9.3 -E utf8
  • アップグレードを実行する
pg_upgrade \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.3 \
-b /usr/local/Cellar/postgresql/9.2.4/bin/ \
-B /usr/local/Cellar/postgresql/9.3.0/bin/ \
-v
  • 前回異常終了だった場合はpidファイルが残されているので、それを削除する必要があります
rm /usr/local/var/postgres/postmaster.pid
  • 下記のメッセージが表示されれば、正常終了
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
  • データフォルダを変更
cd /usr/local/var
mv postgres postgres9.2.4
mv postgres9.3 postgres
  • サービスを起動
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  • 下記コマンドでアップグレード結果を確認
psql postgres -c "select version()"
...
PostgreSQL 9.3.0 on x86_64-apple-darwin13.0.0, compiled by Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn), 64-bit
(1 row)

psql -l
...
  • クリーンアップ
brew cleanup postgresql
gem uninstall pg #すべてのバージョンを削除する
gem install pg

参考リンク

http://blog.55minutes.com/2013/09/postgresql-93-brew-upgrade/

blueplanet
ブロックチェーンエンジニア
https://chainbow.io
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした