19.2. Расположения файлов
В дополнение к вышеупомянутому postgresql.conf, PostgreSQL обрабатывает два редактируемых вручную файла конфигурации, в которых настраивается аутентификация клиентов (их использование рассматривается в Главе 20). По умолчанию все три файла конфигурации размещаются в каталоге данных кластера БД. Параметры, описанные в этом разделе, позволяют разместить их и в любом другом месте. (Это позволяет упростить администрирование, в частности, выполнять резервное копирование этих файлов обычно проще, когда они хранятся отдельно.)
data_directory(string)Задаёт каталог, в котором хранятся данные. Этот параметр можно задать только при запуске сервера.
config_file(string)Задаёт основной файл конфигурации сервера (его стандартное имя —
postgresql.conf). Этот параметр можно задать только в командной строкеpostgres.hba_file(string)Задаёт файл конфигурации для аутентификации по сетевым узлам (его стандартное имя —
pg_hba.conf). Этот параметр можно задать только при старте сервера.ident_file(string)Задаёт файл конфигурации для сопоставлений имён пользователей (его стандартное имя —
pg_ident.conf). Этот параметр можно задать только при запуске сервера. См. также Раздел 20.2.external_pid_file(string)Задаёт имя дополнительного файла с идентификатором процесса (PID), который будет создавать сервер для использования программами администрирования. Этот параметр можно задать только при запуске сервера.
При стандартной установке ни один из этих параметров не задаётся явно. Вместо них задаётся только каталог данных, аргументом командной строки -D или переменной окружения PGDATA, и все необходимые файлы конфигурации загружаются из этого каталога.
Если вы хотите разместить файлы конфигурации не в каталоге данных, то аргумент командной строки postgres -D или переменная окружения PGDATA должны указывать на каталог, содержащий файлы конфигурации, а в postgresql.conf (или в командной строке) должен задаваться параметр data_directory, указывающий, где фактически находятся данные. Учтите, что data_directory переопределяет путь, задаваемый в -D или PGDATA как путь каталога данных, но не расположение файлов конфигурации.
При желании вы можете задать имена и пути файлов конфигурации по отдельности, воспользовавшись параметрами config_file, hba_file и/или ident_file. Параметр config_file можно задать только в командной строке postgres, тогда как остальные можно задать и в основном файле конфигурации. Если явно заданы все три эти параметра плюс data_directory, то задавать -D или PGDATA не нужно.
Во всех этих параметрах относительный путь должен задаваться от каталога, в котором запускается postgres.
19.2. File Locations
In addition to the postgresql.conf file already mentioned, PostgreSQL uses two other manually-edited configuration files, which control client authentication (their use is discussed in Chapter 20). By default, all three configuration files are stored in the database cluster's data directory. The parameters described in this section allow the configuration files to be placed elsewhere. (Doing so can ease administration. In particular it is often easier to ensure that the configuration files are properly backed-up when they are kept separate.)
data_directory(string)Specifies the directory to use for data storage. This parameter can only be set at server start.
config_file(string)Specifies the main server configuration file (customarily called
postgresql.conf). This parameter can only be set on thepostgrescommand line.hba_file(string)Specifies the configuration file for host-based authentication (customarily called
pg_hba.conf). This parameter can only be set at server start.ident_file(string)Specifies the configuration file for user name mapping (customarily called
pg_ident.conf). This parameter can only be set at server start. See also Section 20.2.external_pid_file(string)Specifies the name of an additional process-ID (PID) file that the server should create for use by server administration programs. This parameter can only be set at server start.
In a default installation, none of the above parameters are set explicitly. Instead, the data directory is specified by the -D command-line option or the PGDATA environment variable, and the configuration files are all found within the data directory.
If you wish to keep the configuration files elsewhere than the data directory, the postgres -D command-line option or PGDATA environment variable must point to the directory containing the configuration files, and the data_directory parameter must be set in postgresql.conf (or on the command line) to show where the data directory is actually located. Notice that data_directory overrides -D and PGDATA for the location of the data directory, but not for the location of the configuration files.
If you wish, you can specify the configuration file names and locations individually using the parameters config_file, hba_file and/or ident_file. config_file can only be specified on the postgres command line, but the others can be set within the main configuration file. If all three parameters plus data_directory are explicitly set, then it is not necessary to specify -D or PGDATA.
When setting any of these parameters, a relative path will be interpreted with respect to the directory in which postgres is started.