| PostgreSQL Reference Manual - Volume 3 - Server Administration Guide by The PostgreSQL Global Development Group Paperback (6"x9"), 204 pages ISBN 0954612043 RRP £13.95 ($24.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
3.5 Shutting Down the Server
There are several ways to shut down the database server. You control
the type of shutdown by sending different signals to the master
postgres process.
SIGTERM-
After receiving
SIGTERM, the server disallows new connections, but lets existing sessions end their work normally. It shuts down only after all of the sessions terminate normally. This is the Smart Shutdown. SIGINT-
The server disallows new connections and sends all existing
server processes
SIGTERM, which will cause them to abort their current transactions and exit promptly. It then waits for the server processes to exit and finally shuts down. This is the Fast Shutdown. SIGQUIT-
This is the Immediate Shutdown, which
will cause the master
postgresprocess to send aSIGQUITto all child processes and exit immediately, without properly shutting itself down. The child processes likewise exit immediately upon receivingSIGQUIT. This will lead to recovery (by replaying the WAL log) upon next start-up. This is recommended only in emergencies.
The pg_ctl program provides a convenient
interface for sending these signals to shut down the server.
Alternatively, you can send the signal directly using kill.
The PID of the postgres process can be
found using the ps program, or from the file
‘postmaster.pid’ in the data directory. For
example, to do a fast shutdown:
$ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`
Important: It is best not to use
SIGKILLto shut down the server. Doing so will prevent the server from releasing shared memory and semaphores, which may then have to be done manually before a new server can be started. Furthermore,SIGKILLkills thepostgresprocess without letting it relay the signal to its subprocesses, so it will be necessary to kill the individual subprocesses by hand as well.
| ISBN 0954612043 | PostgreSQL Reference Manual - Volume 3 - Server Administration Guide | See the print edition |