- PostgreSQL 10 Administration Cookbook
- Simon Riggs Gianni Ciolli
- 328字
- 2021-06-25 22:04:07
How to do it…
Some of the parameters take effect only when the server is first started. A typical example might be shared_buffers, which defines the size of the shared memory cache.
Many of the parameters can be changed while the server is still running. After changing the required parameters, we issue a reload command to the server, forcing PostgreSQL to reread the postgresql.conf file (and all other configuration files). There are a number of ways to do that, depending on your distribution and OS. The most common is to issue the following command, with the same OS user that runs the PostgreSQL server process:
pg_ctl reload
This assumes the default data directory; otherwise, you have to specify the correct data directory with the -D option.
As previously noted, Debian and Ubuntu have a different multiversion architecture, so you should issue the following command instead:
pg_ctlcluster 10 main reload
On modern distributions, you can also use systemd, as follows:
sudo systemctl reload postgresql@10-main
See the Starting the database server manually recipe, in Chapter 4, Server Control, for more details on how to manage PostgreSQL via systemd; the Reloading the server configuration files recipe, also in Chapter 4, Server Control, shows more ways to reload configuration files.
Some other parameters require a restart of the server for changes to take effect; for instance, max_connections, listen_addresses, and so on. The syntax is very similar to a reload operation, as shown here:
pg_ctl restart
For Debian and Ubuntu, use this command:
pg_ctlcluster 10 main restart
With system, use this command:
sudo systemctl restart postgresql@10-main
Of course, a restart also has some impact on existing connections. See the Restarting the server quickly recipe in Chapter 4, Server Control, for further details.
The postgresql.conf file is a normal text file that can be simply edited. Most of the parameters are listed in the file, so you can just search for them and then insert the desired value in the right place.