无法使新的 postgres 配置文件设置生效

Can't get new postgres config file settings to take effect

我的数据库中的 table 有点大,我正在向其中插入新记录。随着记录数量的增加,我开始遇到问题,无法插入。

我的 postgresql 日志文件建议我增加 WAL 大小:

[700] LOG: checkpoints are occurring too frequently (6 seconds apart)
[700] HINT: Consider increasing the configuration parameter "max_wal_size".

我用 =# show config_file; 得到了我的配置文件的路径,并用 vim:

做了一些修改
max_wal_senders = 0
wal_level = minimal
max_wal_size = 4GB

当我检查文件时,我看到了我所做的更改。
然后我尝试重新加载并重新启动数据库: (我用 =# show data_directory ; 获取数据目录)

我试过重新加载:

pg_ctl reload -D path
server signaled

我试过重启

pg_ctl restart -D path
waiting for server to shut down.... done
server stopped
waiting for server to start....
2020-01-17 13:08:19.063 EST [16913] LOG:  listening on IPv4 address 
2020-01-17 13:08:19.063 EST [16913] LOG:  listening on IPv6 address 
2020-01-17 13:08:19.079 EST [16913] LOG:  listening on Unix socket 
2020-01-17 13:08:19.117 EST [16914] LOG:  database system was shut down at 2020-01-17 13:08:18 EST
2020-01-17 13:08:19.126 EST [16913] LOG:  database system is ready to accept connections
 done
server started

但是当我连接到数据库并检查我的设置时:

      name       | setting | unit |           category            |                               short_desc                                | extra_desc |  context   | vartype | source  | min_val |  max_val   |         enumvals          | boot_val | reset_val | sourcefile | sourceline | pending_restart
-----------------+---------+------+-------------------------------+-------------------------------------------------------------------------+------------+------------+---------+---------+---------+------------+---------------------------+----------+-----------+------------+------------+-----------------
 max_wal_senders | 10      |      | Replication / Sending Servers | Sets the maximum number of simultaneously running WAL sender processes. |            | postmaster | integer | default | 0       | 262143     |                           | 10       | 10        |            |            | f
 max_wal_size    | 1024    | MB   | Write-Ahead Log / Checkpoints | Sets the WAL size that triggers a checkpoint.                           |            | sighup     | integer | default | 2       | 2147483647 |                           | 1024     | 1024      |            |            | f
 wal_level       | replica |      | Write-Ahead Log / Settings    | Set the level of information written to the WAL.                        |            | postmaster | enum    | default |         |            | {minimal,replica,logical} | replica  | replica   |            |            | f
(3 rows)

我仍然看到旧的默认设置。
我在这里错过了什么?如何让这些设置生效?

配置设置可以来自多个来源:

  • postgresql.conf
  • postgresql.auto.conf(用ALTER SYSTEM设置)
  • 服务器启动时的命令行参数
  • 设置为ALTER DATABASEALTER USER

此外,如果一个参数在配置文件中出现两次,则第二次出现。

要弄清楚你的设置是从哪里来的,运行

SELECT name, source, sourcefile, sourceline, pending_restart
FROM pg_settings
WHERE name IN ('wal_level', 'max_wal_size', 'max_wal_senders');

如果sourcedatabaseuser,您可以使用psql命令\drds来了解详情。


查询结果显示您的 PostgreSQL 已被修改或构建,因此这些值为默认值。

您必须使用上面显示的任何方法覆盖这些默认值。