Stopping the server safely and quickly
There are several modes you can use to stop the server, depending on the level of urgency. We’ll compare the effects in each mode.
How to do it…
There are two variants: with and without system
. This is similar to the previous recipe, Starting the database server manually, which we’ll refer to for further information. For example, what is the exact name of the systemd
service unit for a given database server on a given GNU/Linux distribution?
When using systemd
, you can stop PostgreSQL using fast mode by issuing the following, after replacing SERVICEUNIT
with the appropriate system
service unit name:
sudo systemctl stop SERVICEUNIT
If systemd
is not available and you are using Debian or Ubuntu the command is as follows, which applies to the default version 16 instance:
pg_ctlcluster 16 main stop -m fast
Fast mode has been the default since PostgreSQL 9.5 the previous default was to use smart
mode...