エラー発生前の操作や設定など
『エラーの園』昨日までのお話
昔出したエラーを元に記事を書こうと、psql --version
を
実行したらエラーになった。
別の(正確には誤った順番で)操作をしたばかりに
(dyld: Library not loaded:〜)https://blog.hatena.ne.jp/kuroneko-r011117/error-garden.hateblo.jp/edit?entry=26006613563320295を(仮)解決手順としなければならなかった。
真実その1
そこで、バージョンが古いと思い、参考サイト1. を参考に
brew postgresql-upgrade-database
を実行した。
※同サイトには親切に注意書きとして、今回のエラーも記載されていた。
感謝😌
エラー内容
エラー1
Error: /usr/local/var/postgres.old already exists! Remove it if you want to upgrade data automatically.
↓エラー1解決後に、再びエラーがこれ↓
エラー2
ver.10から11にupgradeする時は、ご機嫌さんに乾杯🍻までしたのに。。。
$ brew postgresql-upgrade-database ==> brew install postgresql@11 ==> Installing dependencies for postgresql@11: icu4c ==> Installing postgresql@11 dependency: icu4c ==> Downloading https://homebrew.bintray.com/bottles/icu4c-66.1.catalina.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/f0/f01dbe4266d1180c1da01d973200ed897cfa8ec8bf5 ######################################################################## 100.0% ==> Pouring icu4c-66.1.catalina.bottle.tar.gz ...(中略)... ==> Summary 🍺 /usr/local/Cellar/icu4c/66.1: 258 files, 70.4MB ==> Installing postgresql@11
おおー、ver11からver.12までupgrade一気にするのか! 見上げたものだ🤓
...(中略)... To have launchd start postgresql@11 now and restart at login: brew services start postgresql@11 Or, if you don't want/need a background service you can just run: pg_ctl -D /usr/local/var/postgresql@11 start ==> Upgrading postgresql data from 11 to 12... waiting for server to start....2020-05-07 12:53:21.116 JST [3621] LOG: listening on IPv6 address "::1", port 5432 2020-05-07 12:53:21.116 JST [3621] LOG: listening on IPv4 address "127.0.0.1", port 5432 2020-05-07 12:53:21.120 JST [3621] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2020-05-07 12:53:21.143 JST [3622] LOG: database system was shut down at 2019-08-12 02:13:58 JST 2020-05-07 12:53:21.157 JST [3621] LOG: database system is ready to accept connections done server started
あれあれ。。。息切れか?(↓下記、続き)
waiting for server to shut down....2020-05-07 12:53:21.378 JST [3621] LOG: received fast shutdown request 2020-05-07 12:53:21.380 JST [3621] LOG: aborting any active transactions 2020-05-07 12:53:21.382 JST [3621] LOG: background worker "logical replication launcher" (PID 3628) exited with exit code 1 2020-05-07 12:53:21.382 JST [3623] LOG: shutting down 2020-05-07 12:53:21.393 JST [3621] LOG: database system is shut down done server stopped ==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.old... ==> Creating database... Error: Upgrading postgresql data from 11 to 12 failed! ==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/postgres... Error: Failure while executing; `/usr/local/Cellar/postgresql/12.2_1/bin/initdb --lc-collate=C --lc-ctype=C --lc-messages=C --lc-monetary=C --lc-numeric=C --lc-time=C -E\ UTF8 /usr/local/var/postgres` exited with 1.
また、エラーですか。。。😔
新鮮なエラー、あがったよー!
採れ採れ、ピチピチ、ふふ、ふふ、ふーん♪
参考サイト
1. upgradeに関する情報
qiita.com
↑
ありがとうございます! 参考になりました 😊
2. brewのupdateとupgradeの違い
qiita.com
ありがとうございます! なるほど🧐
……これをすれば、PostgresSQLのupgrade不要?
しかし、今回、余計なこといろいろしたので、
真実の物語を続けようと思う。
原因
・Homebrewが古かった。
・$ brew upgrade
でHomebrewでインストールしたパッケージも
upgradeする必要があった。(Homebrewもupdateしてくれるらしい。
参考サイト2参照。
作業環境
$ sw_vers ProductName: Mac OS X ProductVersion: 10.15.4
PostgreSQL Version: 10 -> 12
解決手順
【準備】
・DBのバックアップは、忘れずに取っておいてください。
エラー1の解決
1.URLを参考に、bacディレクトリを作成して移動。
$ mkdir /usr/local/var/bac $ mv /usr/local/var/postgres.old /usr/local/var/bac
エラー2の解決
1.HomebrewとHomebrewでインストールしたパッケージをupdate。
$ brew upgrade
。。。dyld: Library not loaded:〜の真実2につづく。