一、公司PG11
二、postgresql.conf
postgresql.conf
listen_addresses = '0.0.0.0' # what IP address(es) to listen on;
port = 1921 # (change requires restart)
max_connections = 20000 # (change requires restart)
superuser_reserved_connections = 13 # (change requires restart)
unix_socket_directories = '.' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
unix_socket_permissions = 0700 # begin with 0 to use octal notation
# (change requires restart)
shared_buffers = 192GB # min 128kB
work_mem = 10MB # min 64kB
maintenance_work_mem = 10240MB # min 1MB
#max_stack_depth = 2MB # min 100kB
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
# - Cost-Based Vacuum Delay -
#vacuum_cost_page_hit = 1 # 0-10000 credits
#vacuum_cost_page_miss = 10 # 0-10000 credits
#vacuum_cost_page_dirty = 20 # 0-10000 credits
vacuum_cost_limit = 10000 # 1-10000 credits
# - Background Writer -
bgwriter_delay = 10ms # 10-10000ms between rounds
#bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round
wal_level = hot_standby # minimal, archive, or hot_standby
# (change requires restart)
#fsync = on # turns forced synchronization on or off
synchronous_commit = off # synchronization level;
# off, local, remote_write, or on
#wal_sync_method = fsync # the default is the first option
# supported by the operating system:
# open_datasync
# fdatasync (default on Linux)
# fsync
# fsync_writethrough
# open_sync
#full_page_writes = on # recover from partial page writes
wal_buffers = 16384kB # min 32kB, -1 sets based on shared_buffers
# (change requires restart)
wal_writer_delay = 10ms # 1-10000 milliseconds
archive_mode = on # allows archiving to be done
# (change requires restart)
archive_command = 'DIR=/data/arch/`date +%F`; test ! -d $DIR && mkdir -p $DIR; chmod 755 $DIR; test ! -f $DIR/%f && cp %p $DIR/%f; chmod 755 $DIR/%f' # command to use to archive a logfile segment
#archive_command = '/bin/true' # command to use to archive a logfile segment
# placeholders: %p = path of file to archive
# %f = file name only
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
#archive_timeout = 0 # force a logfile segment switch after this
# number of seconds; 0 disables
max_wal_senders = 32 # max number of walsender processes
# (change requires restart)
#wal_sender_timeout = 60s # in milliseconds; 0 disables
# - Master Server -
# These settings are ignored on a standby server.
#synchronous_standby_names = '' # standby servers that provide sync rep
# comma-separated list of application_name
# from standby(s); '*' = all
#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
# - Standby Servers -
# These settings are ignored on a master server.
hot_standby = on # "on" allows queries during recovery
# (change requires restart)
max_standby_archive_delay = 300s # max delay before canceling queries
# when reading WAL from archive;
# -1 allows indefinite delay
max_standby_streaming_delay = 300s # max delay before canceling queries
# when reading streaming WAL;
# -1 allows indefinite delay
wal_receiver_status_interval = 1s # send replies at least this often
# 0 disables
hot_standby_feedback = on # send info from standby to prevent
# query conflicts
#wal_receiver_timeout = 60s # time that receiver waits for
# communication from master
# in milliseconds; 0 disables
effective_cache_size = 400GB
log_destination = 'csvlog' # Valid values are combinations of
logging_collector = on # Enable capturing of stderr and csvlog
log_directory = 'pg_log' # directory where log files are written,
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
log_truncate_on_rotation = on # If on, an existing log file with the
log_rotation_age = 1d # Automatic rotation of logfiles will
log_rotation_size = 1024MB # Automatic rotation of logfiles will
log_min_duration_statement = 1s # -1 is disabled, 0 logs all statements
log_checkpoints = on
log_connections = on
log_disconnections = on
#log_duration = off
log_error_verbosity = verbose # terse, default, or verbose messages
#log_hostname = off
log_line_prefix = '< %m >' # special values:
log_lock_waits = on # log lock waits >= deadlock_timeout
log_statement = 'all' # none, ddl, mod, all
#log_temp_files = -1 # log temporary files equal or larger
# than the specified size in kilobytes;
# -1 disables, 0 logs all temp files
log_timezone = 'Asia/Shanghai'
autovacuum = on # Enable autovacuum subprocess? 'on'
# requires track_counts to also be on.
log_autovacuum_min_duration = 0 # -1 disables, 0 logs all actions and
# their durations, > 0 logs only
# actions running at least this number
datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
timezone = 'PRC'
lc_messages = 'C' # locale for system error message
# strings
lc_monetary = 'C' # locale for monetary formatting
lc_numeric = 'C' # locale for number formatting
lc_time = 'C' # locale for time formatting
# default configuration for text search
default_text_search_config = 'pg_catalog.english'
####add by cstech for pg11 ####
tcp_keepalives_idle = 5
tcp_keepalives_interval = 5
tcp_keepalives_count = 3
max_prepared_transactions=20000
vacuum_cost_delay=2
bgwriter_lru_maxpages=1000
wal_compression=on
temp_file_limit=20GB
autovacuum_max_workers=10
autovacuum_vacuum_threshold=500
autovacuum_analyze_threshold=500
autovacuum_vacuum_cost_delay=2ms
lock_timeout=600000
track_io_timing=on
track_functions=all
pg_stat_statements.max=10000
pg_stat_statements.track = all
max_wal_size = 50GB
min_wal_size = 4GB
wal_keep_segments=3200
wal_log_hints=on
full_page_writes=on
track_activity_query_size = 4096
checkpoint_completion_target = 0.1
huge_pages = on
三、recovery.conf
#restore_command = 'scp root@172.31.205.159:/data/nfs_storage/coupon/arch_primary/%f %p'
standby_mode = 'on'
#recovery_target_timeline = 'latest'
recovery_target_timeline = 'latest'
primary_conninfo = 'application_name=172.25.113.102 host=172.21.13.101 port=1921 user=replica password=PostGRESQL.replica keepalives_idle=60'
四、postgres用户环境变量
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export PGPORT=1921
export PGDATA=/data/postgres/pgdata
export LANG=en_US.utf8
export PGHOME=/usr/pgsql-11/
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGHOST=$PGDATA
export PGDATABASE=postgres
alias ll="ls -l"