PostgreSQL参数文件位置及生效方式与不生效的检查

编程入门 行业动态 更新时间:2024-10-17 08:27:07

PostgreSQL参数文件<a href=https://www.elefans.com/category/jswz/34/1771147.html style=位置及生效方式与不生效的检查"/>

PostgreSQL参数文件位置及生效方式与不生效的检查

作者:瀚高PG实验室 (Highgo PG Lab)- 徐云鹤
PostgreSQL服务器参数文件的位置在$PGDATA下,通常在数据目录下。
该文件遵循如下规则:
每一行指定一个参数。这意味着不能出现如下情况:

listen_addresses = '*' log_destination = 'csvlog'

等号是可选的,空白是没有任何意义的,这意味着如下也是正确的:

log_rotation_age'2d'
log_rotation_size =     '0'

井号(#)指示该行的剩余部分是一个注释。
如果要在参数值里嵌入单引号, 或者写两个单引号或者在引号前放反斜线,推荐前者。
除postgresql.conf之外,PostgreSQL 数据目录还包含一个文件 postgresql.auto.conf,它具有和postgresql.conf相同的格式,但是不应该被手工编辑。这个文件保存了通过ALTER SYSTEM命令提供的设置。每当postgresql.conf被读取时这个文件会被自动读取,并且它的设置会以同样的方式生效。 postgresql.auto.conf中的设置会覆盖postgresql.conf中的设置。

当不明确参数在哪个参数文件生效的话,可以检查系统表pg_file_settings,通过该表可以直观体现出目前生效的参数及参数文件。

highgo=# select * from pg_file_settings ;sourcefile                  | sourceline | seqno |             name             |      setting       | applied | error 
----------------------------------------------+------------+-------+------------------------------+--------------------+---------+-------/data/highgo/4.3.2/data/postgresql.conf      |         63 |     1 | port                         | 5866               | t       | /data/highgo/4.3.2/data/postgresql.conf      |         64 |     2 | max_connections              | 150                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        117 |     3 | shared_buffers               | 512MB              | t       | /data/highgo/4.3.2/data/postgresql.conf      |        126 |     4 | work_mem                     | 3495kB             | t       | /data/highgo/4.3.2/data/postgresql.conf      |        127 |     5 | maintenance_work_mem         | 128MB              | t       | /data/highgo/4.3.2/data/postgresql.conf      |        130 |     6 | dynamic_shared_memory_type   | posix              | t       | /data/highgo/4.3.2/data/postgresql.conf      |        191 |     7 | wal_buffers                  | 16MB               | t       | /data/highgo/4.3.2/data/postgresql.conf      |        201 |     8 | max_wal_size                 | 4GB                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        202 |     9 | min_wal_size                 | 2GB                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        203 |    10 | checkpoint_completion_target | 0.9                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        293 |    11 | effective_cache_size         | 1536MB             | t       | /data/highgo/4.3.2/data/postgresql.conf      |        307 |    12 | default_statistics_target    | 100                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        446 |    13 | log_timezone                 | PRC                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        539 |    14 | datestyle                    | iso, mdy           | t       | /data/highgo/4.3.2/data/postgresql.conf      |        541 |    15 | timezone                     | PRC                | t       | /data/highgo/4.3.2/data/postgresql.conf      |        554 |    16 | lc_messages                  | C                  | t       | /data/highgo/4.3.2/data/postgresql.conf      |        556 |    17 | lc_monetary                  | C                  | t       | /data/highgo/4.3.2/data/postgresql.conf      |        557 |    18 | lc_numeric                   | C                  | t       | /data/highgo/4.3.2/data/postgresql.conf      |        558 |    19 | lc_time                      | C                  | t       | /data/highgo/4.3.2/data/postgresql.conf      |        561 |    20 | default_text_search_config   | pg_catalog.english | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          3 |    21 | listen_addresses             | *                  | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          4 |    22 | log_destination              | csvlog             | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          5 |    23 | logging_collector            | on                 | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          6 |    24 | log_directory                | hgdb_log           | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          7 |    25 | log_filename                 | highgodb-%a.log    | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          8 |    26 | log_rotation_age             | 1d                 | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |          9 |    27 | log_rotation_size            | 0                  | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |         10 |    28 | log_truncate_on_rotation     | on                 | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |         11 |    29 | log_hostname                 | on                 | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |         12 |    30 | log_line_prefix              | %m                 | t       | /data/highgo/4.3.2/data/postgresql.auto.conf |         13 |    31 | log_statement                | ddl                | t       | 















更多推荐

PostgreSQL参数文件位置及生效方式与不生效的检查

本文发布于:2024-02-06 15:33:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749886.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   参数   方式   文件   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!