PostgreSQLサービスの停止処理に失敗して「server does not shut down」というエラーになる時の対処方法

PostgreSQLサービスを停止するために、pg_ctlコマンドで「stop」(停止処理)を実行しても停止できない時がある。

《例》pg_ctlコマンドでstop(停止処理)を実行するが、失敗してしまう場合のエラーメッセージ
$ /usr/local/postgresql8/bin/pg_ctl -D /usr/local/postgresql8/data/ stop
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down

《例》pg_ctlコマンドのヘルプを確認
$ /usr/local/postgresql8/bin/pg_ctl --help
pg_ctl is a utility to start, stop, restart, reload configuration files,
report the status of a PostgreSQL server, or signal a PostgreSQL process.

Usage:
pg_ctl start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"]
pg_ctl stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
pg_ctl restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
[-o "OPTIONS"]
pg_ctl reload [-D DATADIR] [-s]
pg_ctl status [-D DATADIR]
pg_ctl kill SIGNALNAME PID

Common options:
-D, --pgdata DATADIR location of the database storage area
-s, --silent only print errors, no informational messages
-t SECS seconds to wait when using -w option
-w wait until operation completes
-W do not wait until operation completes
--help show this help, then exit
--version output version information, then exit
(The default is to wait for shutdown, but not for start or restart.)

If the -D option is omitted, the environment variable PGDATA is used.

Options for start or restart:
-l, --log FILENAME write (or append) server log to FILENAME
-o OPTIONS command line options to pass to postgres
(PostgreSQL server executable)
-p PATH-TO-POSTGRES normally not necessary
-c, --core-files allow postgres to produce core files

Options for stop or restart:
-m SHUTDOWN-MODE can be "smart", "fast", or "immediate"

Shutdown modes are:
smart quit after all clients have disconnected
fast quit directly, with proper shutdown
immediate quit without complete shutdown; will lead to recovery on restart

Allowed signal names for kill:
HUP INT QUIT ABRT TERM USR1 USR2

Report bugs to <pgsql-bugs@postgresql.org>.

PostgreSQLコマンド「pg_ctl」でシャットダウンモードを指定し、PostgreSQLサービスを停止
pg_ctlコマンドのヘルプで「Options for stop or restart:」(停止または再起動用のオプション)という項目を見るとSHUTDOWN-MODE(シャットダウンモード)を指定できることが分かった。
「-m SHUTDOWN-MODE can be "smart", "fast", or "immediate"」を見ると、シャットダウンモードには、smart、fast、immediateの3種類があるようだ。

「Shutdown modes are:」(シャットダウンモードは以下の通り)という項目を見ると、シャットダウンモード3種類の説明もあったので、分かりやすい。
smart quit after all clients have disconnected
fast quit directly, with proper shutdown
immediate quit without complete shutdown; will lead to recovery on restart

immediateは、「will lead to recovery on restart」(再起動時にリカバリが必要になる)といったちょっとよく分からない怖そうな説明が書かれており、私には実行する勇気がなかったので、fastで実行することに決めた。

$ /usr/local/postgresql8/bin/pg_ctl -D /usr/local/postgresql8/data/ -m fast stop
waiting for server to shut down..................................... done
server stopped

停止できた!

「pg_ctl」で単に「stop」と指定しただけの停止処理ではPostgreSQLサービスの停止に失敗していて、どうしようか、と困っていたのだが、「-m fast stop」とオプション付で停止処理を実行すれば、停止できたので、大変嬉しかった。

前へ

コンフォートホテル岡山の当日限定プランは、23時前に新規に出ることがあるかも!?

次へ

iPod touchをiOS 5.0.1にアップデートした(バッテリーの持続時間が改善されるといいなあ)