データベースの壊れ方は、いろいろあるけど、1つ復旧できたケースがあったので、備忘録として、残しておきます。
- CentOS release 5.7 (Final)
- PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu
エラーの内容は (/opt/PostgreSQL/9.1/data/pg_log/startup.log)
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for “localhost”
FATAL: could not create any TCP/IP sockets
LOG: database system was shut down at 2012-03-18 17:37:33 JST
FATAL: the database system is starting up
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
FATAL: database “sample-db” does not exist
FATAL: database “sample-db” does not exist
FATAL: database “sample-db” does not exist
FATAL: database “sample-db” does not exist
。。。
こんな感じ。sample-dbのデータベースが壊れてしまった。
ちなみに create dabase sample-db は実行できた。 とうぜん、中は空っぽ。
データファイルはどうなっているか、確認した。
(/opt/PostgreSQL/9.1/data/base/)
# du -sk *
6120 1
6112 12691
9420 12699
749232 17761 ←ここにあったっぽい。
6112 4277958
6112 6364733 ←create database sample-db でできたディレクトリ
※ファイルの更新日付とデータサイズから、予測してみました。
postgres を止めて、
# mv 6364733 6364733.bk
# cp -rp 17761 6364733
として、postgres を起動したら、復活できた。
構成のみで、データの中身は無事だったみたい。良かったよかった。