include

一个用于指定要包含的配置文件名称的指令

include 是一个配置文件指令,用于指定要包含在 postgresql.conf 中的另一个配置文件的名称。

includePostgreSQL 8.2 中被添加。

用法

指定的文件可以是相对于当前配置文件的相对路径,也可以是绝对文件路径。

如果指定的文件不存在,在正在运行的服务器上重新加载 PostgreSQL 配置将会失败,并且将保留现有配置。如果尝试启动或重启服务器,该操作将会失败。使用 include_if_exists 来确保缺失的配置文件不会导致此类错误。

变更历史

示例

postgresql.conf 中的示例用法

# server-specific configuration files

include 'postgresql.replication.conf'
include 'postgresql.local.conf'

如果指定的文件不存在,当重新加载配置时,日志中会显示类似以下的条目:

[2022-08-02 12:19:59 UTC]    LOG:  00000: received SIGHUP, reloading configuration files
[2022-08-02 12:19:59 UTC]    LOG:  58P01: could not open configuration file "/var/lib/pgsql/data/foo.conf": No such file or directory
[2022-08-02 12:19:59 UTC]    LOG:  F0000: configuration file "/var/lib/pgsql/data/postgresql.conf" contains errors; no changes were applied

如果配置文件包含无效的 include 指令,并且尝试启动或重启服务器,操作将失败并出现类似以下错误:

$ pg_ctl -D /var/lib/pgsql/data start
waiting for server to start....
2022-08-02 11:26:22.175 GMT [1695] LOG: could not open configuration file "/var/lib/pgsql/data/foo.conf": No such file or directory 2022-08-02 11:26:22.175 GMT [1695] FATAL: configuration file "/var/lib/pgsql/data/postgresql.conf" contains errors stopped waiting pg_ctl: could not start server Examine the log output.

分类

配置

另请参阅

include_if_exists, include_dir

反馈

提交任何关于“include”的评论、建议或更正请 在此处