NYC*_*yes 13 sql postgresql wal
在正在运行的 PostgreSQL 13 实例上,我尝试按如下方式修改其wal_level系统设置,但它没有得到尊重:
postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level |
|-------------|
| replica |
+-------------+
SHOW
Time: 0.021s
postgres@localhost:postgres> ALTER SYSTEM SET wal_level = logical;
ALTER SYSTEM
Time: 0.007s
postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level |
|-------------|
| replica |
+-------------+
SHOW
Time: 0.021s
postgres@localhost:postgres>
Run Code Online (Sandbox Code Playgroud)
不幸的是,这是由 Postgres 人员在 DockerHub 映像中设置的,因此仅修改配置文件并重新启动并不简单。事实上,解决方法是可以完成的,但我希望社区能够建议一种通过 Postgres 客户端会话实时完成此操作的方法。
编辑(下面的评论补充):
postgres@localhost:postgres> select * from pg_settings where name ='wal_level';
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+
| enumvals | boot_val | reset_val | sourcefile | sourceline | pending_restart |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------|
| ['minimal', 'replica', 'logical'] | replica | replica | <null> | <null> | False |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+
Run Code Online (Sandbox Code Playgroud)
小智 16
如果您使用 Postgresql 14,则无需更改 docker 映像/容器。
赶紧跑
ALTER SYSTEM SET wal_level = logical;
Run Code Online (Sandbox Code Playgroud)
并重新启动容器。
请参阅 https://www.postgresql.org/docs/current/sql-altersystem.html
ALTER SYSTEM 将给定的参数设置写入 postgresql.auto.conf 文件,该文件除了 postgresql.conf 之外还被读取。
使用此值检查上下文字段select * from pg_settings where name ='wal_level';
,您可以看到您需要什么“重新启动”级别
更多信息https://www.postgresql.org/docs/current/view-pg-settings.html
但是,在文档中,对于 wal_level 说:
wal_level(枚举)
wal_level 决定写入 WAL 的信息量。默认值是replica,它写入足够的数据来支持WAL归档和复制,包括在备用服务器上运行只读查询。最小删除除从崩溃或立即关闭中恢复所需的信息之外的所有日志记录。最后,逻辑添加支持逻辑解码所需的信息。每个级别都包含所有较低级别记录的信息。该参数只能在服务器启动时设置。
https://www.postgresql.org/docs/current/runtime-config-wal.html
| 归档时间: |
|
| 查看次数: |
36212 次 |
| 最近记录: |