Postgresql 13.7 postgresql.conf配置文件详解

postgresql.conf是PostgreSQL数据库服务器的主要配置文件之一,它包含了许多重要的参数,用于配置数据库服务器的各种行为。下面是一些常用的参数的详细说明:

  1. listen_addresses:这个参数指定PostgreSQL服务器监听的IP地址。默认情况下,它设置为localhost,只允许本地连接。如果你想允许来自其他IP地址的连接,你需要将它设置为你的服务器的公共IP地址。

  2. port:这个参数指定PostgreSQL服务器监听的端口号。默认情况下,它设置为5432。

  3. max_connections:这个参数指定PostgreSQL服务器允许的最大连接数。默认情况下,它设置为100。

  4. shared_buffers:这个参数指定PostgreSQL服务器用于缓存数据的内存大小。默认情况下,它设置为128MB。

  5. work_mem:这个参数指定每个查询可用的内存量。默认情况下,它设置为4MB。

  6. maintenance_work_mem:这个参数指定PostgreSQL服务器用于维护操作的内存量。默认情况下,它设置为64MB。

  7. effective_cache_size:这个参数指定PostgreSQL服务器可以使用的系统缓存的大小。默认情况下,它设置为4GB。

  8. checkpoint_timeout:这个参数指定PostgreSQL服务器执行自动检查点的时间间隔。默认情况下,它设置为5分钟。

  9. wal_level:这个参数指定PostgreSQL服务器记录事务日志的级别。默认情况下,它设置为minimal。

  10. max_wal_size:这个参数指定PostgreSQL服务器允许的最大事务日志文件大小。默认情况下,它设置为1GB。

  11. min_wal_size:这个参数指定PostgreSQL服务器允许的最小事务日志文件大小。默认情况下,它设置为80MB。

  12. max_worker_processes:这个参数指定PostgreSQL服务器允许的最大后台工作进程数。默认情况下,它设置为8

  13. log_line_prefix: 这个参数指定日志信息的前缀,可以包括时间、用户名、数据库名、进程ID等信息。默认情况下,它设置为"%t [%p]: [%l-1] user=%u,db=%d,",表示输出日志信息的时间、进程ID、日志级别减1、用户名和数据库名等信息。

  14. log_destination:这个参数指定PostgreSQL服务器的日志输出目的地,可以是stderr、syslog、csvlog等。默认情况下,它设置为stderr。

  15. log_min_messages:这个参数指定日志输出的最小级别。默认情况下,它设置为WARNING,表示只输出警告级别及以上的日志信息。

  16. datestyle:这个参数指定日期的格式。默认情况下,它设置为ISO,表示使用ISO标准的日期格式。

  17. timezone:这个参数指定时区。默认情况下,它设置为UTC。

  18. default_statistics_target:这个参数指定查询优化器在收集统计信息时使用的样本数目。默认情况下,它设置为100。

  19. autovacuum:这个参数指定是否启用自动VACUUM。默认情况下,它设置为on。

  20. vacuum_cost_limit:这个参数指定VACUUM操作的成本限制,当VACUUM操作的成本超过该限制时,它将停止执行。默认情况下,它设置为200。

  21. autovacuum_vacuum_scale_factor: 这个参数指定自动VACUUM操作的触发阈值,当表中已删除行的占比达到该阈值时,自动触发VACUUM操作。默认情况下,它设置为0.2。

  22. autovacuum_analyze_scale_factor: 这个参数指定自动VACUUM操作的触发阈值,当表中新增行的占比达到该阈值时,自动触发ANALYZE操作。默认情况下,它设置为0.1。

  23. autovacuum_vacuum_cost_limit: 这个参数指定自动VACUUM操作的成本限制,当VACUUM操作的成本超过该限制时,它将停止执行。默认情况下,它设置为-1,表示不设置成本限制。

  24. autovacuum_vacuum_scale_factor: 这个参数指定自动VACUUM操作的触发阈值,当表中已删除行的占比达到该阈值时,自动触发VACUUM操作。默认情况下,它设置为0.2。

  25. checkpoint_completion_target: 这个参数指定执行检查点操作时,需要将多少缓存中的数据写入磁盘。默认情况下,它设置为0.5。

  26. default_text_search_config: 这个参数指定全文搜索使用的默认配置。默认情况下,它设置为pg_catalog.simple。

  27. max_parallel_workers: 这个参数指定允许的最大并行工作进程数。默认情况下,它设置为8。

  28. max_parallel_workers_per_gather: 这个参数指定每个查询允许的最大并行工作进程数。默认情况下,它设置为2。

  29. jit: 这个参数指定是否启用JIT(即时编译)优化。默认情况下,它设置为off。

  30. jit_above_cost: 这个参数指定在哪些查询成本高于该阈值时,JIT优化将被启用。默认情况下,它设置为100000。

这些参数是PostgreSQL配置文件中的一部分。在修改配置文件时,需要谨慎处理,避免对数据库的正常运行造成影响。如果不确定如何配置,可以参考PostgreSQL官方文档或寻求专业的帮助。
下面是关于Postgresql 13.7 postgresql.conf配置文件详解部分:

# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
# 该文件由如下格式的行组成:
#   name = value
#
# (The "=" is optional.)  Whitespace may be used.  Comments are introduced with
# "#" anywhere on a line.  The complete list of parameter names and allowed
# values can be found in the PostgreSQL documentation.
# (=是可选的。)可以使用空格。注释在一行中的任意位置用“#”引入。参数名称和允许的值的完整列表可以在PostgreSQL文档中找到。

# The commented-out settings shown in this file represent the default values.
# Re-commenting a setting is NOT sufficient to revert it to the default value;
# you need to reload the server.
# 该文件中显示的带注释的设置表示默认值。重新注释一个设置不足以将其恢复为默认值;您需要重新加载服务器。

# This file is read on server startup and when the server receives a SIGHUP
# signal.  If you edit the file on a running system, you have to SIGHUP the
# server for the changes to take effect, run "pg_ctl reload", or execute
# "SELECT pg_reload_conf()".  Some parameters, which are marked below,
# require a server shutdown and restart to take effect.
# 该文件在服务器启动和服务器接收到SIGHUP信号时读取。如果你在一个正在运行的系统上编辑这个文件,你必须SIGHUP服务器以便修改生效,运行"pg_ctl reload",或者执行"SELECT pg_reload_conf()"。下面标记的一些参数需要服务器关闭和重新启动才能生效。

# Any parameter can also be given as a command-line option to the server, e.g.,
# "postgres -c log_connections=on".  Some parameters can be changed at run time
# with the "SET" SQL command.
# 任何参数也可以作为命令行选项提供给服务器,例如,"postgres -c log_connections=on"。一些参数可以在运行时使用“SET”SQL命令更改。

# Memory units:  B  = bytes            Time units:  us  = microseconds
#                kB = kilobytes                     ms  = milliseconds
#                MB = megabytes                     s   = seconds
#                GB = gigabytes                     min = minutes
#                TB = terabytes                     h   = hours
#                                                   d   = days


#------------------------------------------------------------------------------
# FILE LOCATIONS 文件位置
#------------------------------------------------------------------------------

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
# 这些变量的默认值由-D命令行选项或PGDATA环境变量驱动,在这里表示为ConfigDir。

#data_directory = 'ConfigDir'		# use data in another directory 使用其他目录中的数据
					# (change requires restart) 改变需要重新启动数据库
#hba_file = 'ConfigDir/pg_hba.conf'	# host-based authentication file 基于主机的认证文件
					# (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf'	# ident configuration file 识别配置文件
					# (change requires restart)

# If external_pid_file is not explicitly set, no extra PID file is written.
# 如果没有显式地设置external_pid_file,则不会写入额外的PID文件。
#external_pid_file = ''			# write an extra PID file 写一个额外的PID文件
					# (change requires restart)


#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION 连接和身份验证
#------------------------------------------------------------------------------

# - Connection Settings - 连接设置

listen_addresses = '*'		# what IP address(es) to listen on; 侦听的IP地址是什么;
					# comma-separated list of addresses; 逗号分隔的地址列表;
					# defaults to 'localhost'; use '*' for all 默认为'localhost';全部使用“*”
					# (change requires restart)
port = 5432				# (change requires restart)  #端口
max_connections = 100			# (change requires restart) # 数据库最大连接数
#superuser_reserved_connections = 3	# (change requires restart)
#unix_socket_directories = '/var/run/postgresql, /tmp'	# comma-separated list of directories 以逗号分隔的目录列表
					# (change requires restart)
#unix_socket_group = ''			# (change requires restart)
#unix_socket_permissions = 0777		# begin with 0 to use octal notation 以0开始使用八进制表示法
					# (change requires restart)
#bonjour = off				# advertise server via Bonjour 通过Bonjour广告服务器
					# (change requires restart)
#bonjour_name = ''			# defaults to the computer name 默认为计算机名
					# (change requires restart)

# - TCP settings -
# see "man tcp" for details

#tcp_keepalives_idle = 0		# TCP_KEEPIDLE, in seconds; TCP_KEEPIDLE,单位为秒;
					# 0 selects the system default 0选择系统默认值
#tcp_keepalives_interval = 0		# TCP_KEEPINTVL, in seconds;
					# 0 selects the system default
#tcp_keepalives_count = 0		# TCP_KEEPCNT;
					# 0 selects the system default
#tcp_user_timeout = 0			# TCP_USER_TIMEOUT, in milliseconds; TCP_USER_TIMEOUT,以毫秒为单位;
					# 0 selects the system default

# - Authentication - 身份验证

#authentication_timeout = 1min		# 1s-600s
password_encryption = scram-sha-256		# md5 or scram-sha-256
#db_user_namespace = off

# GSSAPI using Kerberos 使用Kerberos的GSSAPI
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
#krb_caseins_users = off

# - SSL -

#ssl = off
#ssl_ca_file = ''
#ssl_cert_file = 'server.crt'
#ssl_crl_file = ''
#ssl_key_file = 'server.key'
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
#ssl_prefer_server_ciphers = on
#ssl_ecdh_curve = 'prime256v1'
#ssl_min_protocol_version = 'TLSv1.2'
#ssl_max_protocol_version = ''
#ssl_dh_params_file = &
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PostgreSQL 10 中,`postgresql.conf` 文件用于指定 PostgreSQL 数据库服务器的全局配置选项。以下是一些常见的配置选项: 1. `listen_addresses`:指定数据库服务器要监听的 IP 地址或主机名。如果要允许来自所有 IP 地址的连接,则可以将其设置为 `*`。 ``` listen_addresses = '*' ``` 2. `port`:指定数据库服务器要监听的端口号。 ``` port = 5432 ``` 3. `max_connections`:指定数据库服务器同时处理的最大客户端连接数。 ``` max_connections = 100 ``` 4. `shared_buffers`:指定 PostgreSQL 要使用的共享内存缓冲区大小。该值应该足够大,以便在内存中缓存常用的数据。 ``` shared_buffers = 1GB ``` 5. `work_mem`:指定 PostgreSQL 中每个排序和哈希操作使用的内存缓冲区大小。该值应该足够大,以便在内存中缓存排序和哈希操作所需的数据。 ``` work_mem = 64MB ``` 6. `maintenance_work_mem`:指定 PostgreSQL 执行维护操作时使用的内存缓冲区大小。例如,当执行 VACUUM 操作时,该值应该足够大,以便在内存中缓存需要清理的数据。 ``` maintenance_work_mem = 256MB ``` 7. `effective_cache_size`:指定 PostgreSQL 估计的系统缓存大小。该值应该足够大,以便 PostgreSQL 可以利用系统缓存中的数据。 ``` effective_cache_size = 4GB ``` 8. `wal_level`:指定 WAL 日志的详细程度。可以设置为 `minimal`、`replica` 或 `logical`。 ``` wal_level = replica ``` 9. `max_wal_senders`:指定主服务器能够向从服务器发送 WAL 日志的最大数量。 ``` max_wal_senders = 10 ``` 以上是 PostgreSQL 10 中 `postgresql.conf` 文件的一些常见配置选项。这些选项可以根据具体的需求进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值