Command to validate a postgresql configuration file?
I am generating postgresql configuration files via ansible, and putting them in
/etc/postgresql/XX/main/conf.d/whatever.conf. I accidentally made a syntax error and broke my postgresql, requiring manual fixing.
Is there any postgresql command to validate that a file is a valid postgresql.conf file?
sudoersfiles can be validates with
/usr/sbin/visudo -cf path/to/file. Is there anything for postgresql?
I'm currently running Ubuntu 18.04 & 20.04, with PostgreSQL 10, 12 etc (yes several different versions).
The only program that I know is
postgres, the database server.
I have two approaches to deal with that problem:
After you edit
postgresql.confand reload, examine the PostgreSQL log file. If there was a problem, you will see that in the log, an the server will keep running with the previous configuration (no outage). Fix the file and try again until it the reload is successful.
ALTER SYSTEMrather than
postgresql.confto change configuration parameters. That works just as well, and
ALTER SYSTEMwill catch most of the possible syntax errors. Of course, you should still look at the PostgreSQL log after reloading.
As an alternative to checking the log file, you may use the
pg_file_settingsview as described in the other answer.