zoukankan      html  css  js  c++  java
  • PostgreSQL安装后需要调整的参数

    修改监听的IP和端口

    修改postgresql.conf文件
    listen_addresses = '' # what IP address(es) to listen on; defaults to 'localhost'; use '' for all
    port = 5432 # (change requires restart)

    与数据库log相关的参数

    修改postgresql.conf文件
    logging_collector = on # Enable capturing of stderr and csvlog into log files. Required to be on for csvlogs.
    log_directory = 'pg_log' # directory where log files are written, can be absolute or relative to PGDATA

    日志切换与是否覆盖

    log_filename:# log file name pattern, can include strftime() escapes
    log_truncate_on_rotation:# If on, an existing log file with the same name as the new log file will be truncated rather than appended to. But such truncation only occurs on time-driven rotation, not on restarts or size-driven rotation. Default is off, meaning append to existing files in all cases.
    log_rotation_age:# Automatic rotation of logfiles will happen after that time. 0 disables.
    log_rotation_size:# Automatic rotation of logfiles will happen after that much log output. 0 disables.

    每天生成一个新的日志文件

    log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
    log_truncate_on_rotation = off
    log_rotation_age = 1d
    log_rotation_size = 0

    每当日志写满一定的大小(如10MB空间),则切换一个日志

    log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
    log_truncate_on_rotation = off
    log_rotation_age = 0
    log_rotation_size = 10M

    只保留7天的日志,进行循环覆盖

    log_filename = 'postgresql-%a.log'
    log_truncate_on_rotation = on
    log_rotation_age = 1d
    log_rotation_size = 0

    内存参数的设置

    shared_buffers:默认32MB,共享内存的大小,主要用于共享数据块。设置得大一些,当读取数据时,就可以从共享内存中读,而不需要再从文件上读取。
    work_mem:默认1MB,单个SQL执行时,排序、hash join所使用的内存,SQL运行完后,内存就释放了。设置大一些,会让排序操作快一些。

  • 相关阅读:
    全国各地DNS(电信,移动,联通,教育网)
    全国各地电信DNS服务器地址
    免费公共 DNS 大全
    免费公共DNS服务器 全球DNS服务器 国内DNS服务器
    AT指令发送短信
    OpenWrt 定期检测进程是否存在并重启
    OpenWrt 计划任务使用方法
    openwrt-mt7688 修改默认的WIFI SSID
    在MT7628实现wan、wwan与4G动态切换
    Unix常用命令之修改密码
  • 原文地址:https://www.cnblogs.com/nolanchan/p/12275307.html
Copyright © 2011-2022 走看看