4.4. Configuring PostgreSQL
In a PostgreSQL database, all data and configuration files are stored in a single directory called a database cluster. Red Hat recommends storing all data, including configuration files, in the default /var/lib/pgsql/data/
directory.
PostgreSQL configuration consists of the following files:
-
postgresql.conf
- is used for setting the database cluster parameters. -
postgresql.auto.conf
- holds basic PostgreSQL settings similarly topostgresql.conf
. However, this file is under the server control. It is edited by theALTER SYSTEM
queries, and cannot be edited manually. -
pg_ident.conf
- is used for mapping user identities from external authentication mechanisms into the PostgreSQL user identities. -
pg_hba.conf
- is used for configuring client authentication for PostgreSQL databases.
To change the PostgreSQL configuration, use the following procedure.
Procédure
-
Edit the respective configuration file, for example,
/var/lib/pgsql/data/postgresql.conf
. Restart the
postgresql
service so that the changes become effective:# systemctl restart postgresql.service
Exemple 4.2. Configuring PostgreSQL database cluster parameters
This example shows basic settings of the database cluster parameters in the /var/lib/pgsql/data/postgresql.conf
file.
# This is a comment log_connections = yes log_destination = 'syslog' search_path = '"$user", public' shared_buffers = 128MB password_encryption = scram-sha-256
Exemple 4.3. Setting client authentication in PostgreSQL
This example demonstrates how to set client authentication in the /var/lib/pgsql/data/pg_hba.conf
file.
# TYPE DATABASE USER ADDRESS METHOD local all all trust host postgres all 192.168.93.0/24 ident host all all .example.com scram-sha-256