【问题标题】:Can't get new postgres config file settings to take effect无法使新的 postgres 配置文件设置生效
【发布时间】:2020-01-17 18:23:40
【问题描述】:

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

我的 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)

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

【问题讨论】:

  • 你运行的是什么版本?可以分享SELECT * FROM pg_settings吗?我想知道ALTER SYSTEM 有没有找到你……
  • 配置文件不一定位于数据目录中。 show config_file; 带给你什么?
  • @richyen 我的版本是10.9 (Ubuntu 10.9-0ubuntu0.18.04.1)。我更新了帖子以添加SELECT * FROM pg_settings
  • @a_horse_with_no_name SHOW config_file; 给我/etc/postgresql/10/main/postgresql.conf

标签: postgresql wal


【解决方案1】:

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

  • 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 已被修改或构建,因此这些值是默认值。

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

【讨论】:

  • hmm 所以我只看到default 的所有来源。请查看更新后的帖子——现在包括来自g_settings 的所有列以获取感兴趣的参数。
  • 我已经修改了答案。
  • 再次感谢您的回答。我想我会尝试建议的方法。但是我仍然无法理解一件事:在这种情况下,SHOW config_file; 不是给了我默认的配置文件吗?为什么我不应该期望更改此文件中的参数也会更改默认设置?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-21
  • 1970-01-01
相关资源
最近更新 更多