Commit f2b08f1c35600795e39070ed17b243e070f06fe0

Authored by Neenad Ingole
1 parent 2fe2dead
Exists in master

Postgres logical replication configs

postgres/docker-compose-replication.yml 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +version: "3.9"
  2 +
  3 +services:
  4 + master:
  5 + image: postgres:13.3
  6 + restart: always
  7 + environment:
  8 + POSTGRES_PASSWORD: password
  9 + POSTGRES_DB: data_service
  10 + volumes:
  11 + - ./master.conf:/etc/postgresql/postgresql.conf
  12 + - ./pg_hba.conf:/etc/postgresql/pg_hba.conf
  13 + - ./setup-master.sh:/docker-entrypoint-initdb.d/init-user-db.sh
  14 + ports:
  15 + - "5432:5432"
  16 + command:
  17 + - "postgres"
  18 + - "-c"
  19 + - "config_file=/etc/postgresql/postgresql.conf"
  20 +
  21 + slave:
  22 + image: postgres:13.3
  23 + restart: always
  24 + environment:
  25 + POSTGRES_PASSWORD: password
  26 + POSTGRES_DB: data_service
  27 + volumes:
  28 + - ./slave.conf:/etc/postgresql/postgresql.conf
  29 + - ./pg_hba.conf:/etc/postgresql/pg_hba.conf
  30 + - ./setup-slave.sh:/docker-entrypoint-initdb.d/init-user-db.sh
  31 + ports:
  32 + - "54321:5432"
  33 + command:
  34 + - "postgres"
  35 + - "-c"
  36 + - "config_file=/etc/postgresql/postgresql.conf"
... ...
postgres/master.conf 0 → 100644
... ... @@ -0,0 +1,798 @@
  1 +# -----------------------------
  2 +# PostgreSQL configuration file
  3 +# -----------------------------
  4 +#
  5 +# This file consists of lines of the form:
  6 +#
  7 +# name = value
  8 +#
  9 +# (The "=" is optional.) Whitespace may be used. Comments are introduced with
  10 +# "#" anywhere on a line. The complete list of parameter names and allowed
  11 +# values can be found in the PostgreSQL documentation.
  12 +#
  13 +# The commented-out settings shown in this file represent the default values.
  14 +# Re-commenting a setting is NOT sufficient to revert it to the default value;
  15 +# you need to reload the server.
  16 +#
  17 +# This file is read on server startup and when the server receives a SIGHUP
  18 +# signal. If you edit the file on a running system, you have to SIGHUP the
  19 +# server for the changes to take effect, run "pg_ctl reload", or execute
  20 +# "SELECT pg_reload_conf()". Some parameters, which are marked below,
  21 +# require a server shutdown and restart to take effect.
  22 +#
  23 +# Any parameter can also be given as a command-line option to the server, e.g.,
  24 +# "postgres -c log_connections=on". Some parameters can be changed at run time
  25 +# with the "SET" SQL command.
  26 +#
  27 +# Memory units: B = bytes Time units: us = microseconds
  28 +# kB = kilobytes ms = milliseconds
  29 +# MB = megabytes s = seconds
  30 +# GB = gigabytes min = minutes
  31 +# TB = terabytes h = hours
  32 +# d = days
  33 +
  34 +
  35 +#------------------------------------------------------------------------------
  36 +# FILE LOCATIONS
  37 +#------------------------------------------------------------------------------
  38 +
  39 +# The default values of these variables are driven from the -D command-line
  40 +# option or PGDATA environment variable, represented here as ConfigDir.
  41 +
  42 +#data_directory = 'ConfigDir' # use data in another directory
  43 + # (change requires restart)
  44 +#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
  45 + # (change requires restart)
  46 +#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
  47 + # (change requires restart)
  48 +
  49 +# If external_pid_file is not explicitly set, no extra PID file is written.
  50 +#external_pid_file = '' # write an extra PID file
  51 + # (change requires restart)
  52 +
  53 +
  54 +#------------------------------------------------------------------------------
  55 +# CONNECTIONS AND AUTHENTICATION
  56 +#------------------------------------------------------------------------------
  57 +
  58 +# - Connection Settings -
  59 +
  60 +listen_addresses = '*'
  61 + # comma-separated list of addresses;
  62 + # defaults to 'localhost'; use '*' for all
  63 + # (change requires restart)
  64 +#port = 5432 # (change requires restart)
  65 +#max_connections = 100 # (change requires restart)
  66 +#superuser_reserved_connections = 3 # (change requires restart)
  67 +#unix_socket_directories = '/tmp' # comma-separated list of directories
  68 + # (change requires restart)
  69 +#unix_socket_group = '' # (change requires restart)
  70 +#unix_socket_permissions = 0777 # begin with 0 to use octal notation
  71 + # (change requires restart)
  72 +#bonjour = off # advertise server via Bonjour
  73 + # (change requires restart)
  74 +#bonjour_name = '' # defaults to the computer name
  75 + # (change requires restart)
  76 +
  77 +# - TCP settings -
  78 +# see "man tcp" for details
  79 +
  80 +#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
  81 + # 0 selects the system default
  82 +#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
  83 + # 0 selects the system default
  84 +#tcp_keepalives_count = 0 # TCP_KEEPCNT;
  85 + # 0 selects the system default
  86 +#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds;
  87 + # 0 selects the system default
  88 +
  89 +#client_connection_check_interval = 0 # time between checks for client
  90 + # disconnection while running queries;
  91 + # 0 for never
  92 +
  93 +# - Authentication -
  94 +
  95 +#authentication_timeout = 1min # 1s-600s
  96 +#password_encryption = scram-sha-256 # scram-sha-256 or md5
  97 +#db_user_namespace = off
  98 +
  99 +# GSSAPI using Kerberos
  100 +#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
  101 +#krb_caseins_users = off
  102 +
  103 +# - SSL -
  104 +
  105 +#ssl = off
  106 +#ssl_ca_file = ''
  107 +#ssl_cert_file = 'server.crt'
  108 +#ssl_crl_file = ''
  109 +#ssl_crl_dir = ''
  110 +#ssl_key_file = 'server.key'
  111 +#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
  112 +#ssl_prefer_server_ciphers = on
  113 +#ssl_ecdh_curve = 'prime256v1'
  114 +#ssl_min_protocol_version = 'TLSv1.2'
  115 +#ssl_max_protocol_version = ''
  116 +#ssl_dh_params_file = ''
  117 +#ssl_passphrase_command = ''
  118 +#ssl_passphrase_command_supports_reload = off
  119 +
  120 +
  121 +#------------------------------------------------------------------------------
  122 +# RESOURCE USAGE (except WAL)
  123 +#------------------------------------------------------------------------------
  124 +
  125 +# - Memory -
  126 +
  127 +#shared_buffers = 32MB # min 128kB
  128 + # (change requires restart)
  129 +#huge_pages = try # on, off, or try
  130 + # (change requires restart)
  131 +#huge_page_size = 0 # zero for system default
  132 + # (change requires restart)
  133 +#temp_buffers = 8MB # min 800kB
  134 +#max_prepared_transactions = 0 # zero disables the feature
  135 + # (change requires restart)
  136 +# Caution: it is not advisable to set max_prepared_transactions nonzero unless
  137 +# you actively intend to use prepared transactions.
  138 +#work_mem = 4MB # min 64kB
  139 +#hash_mem_multiplier = 1.0 # 1-1000.0 multiplier on hash table work_mem
  140 +#maintenance_work_mem = 64MB # min 1MB
  141 +#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
  142 +#logical_decoding_work_mem = 64MB # min 64kB
  143 +#max_stack_depth = 2MB # min 100kB
  144 +#shared_memory_type = mmap # the default is the first option
  145 + # supported by the operating system:
  146 + # mmap
  147 + # sysv
  148 + # windows
  149 + # (change requires restart)
  150 +#dynamic_shared_memory_type = posix # the default is the first option
  151 + # supported by the operating system:
  152 + # posix
  153 + # sysv
  154 + # windows
  155 + # mmap
  156 + # (change requires restart)
  157 +#min_dynamic_shared_memory = 0MB # (change requires restart)
  158 +
  159 +# - Disk -
  160 +
  161 +#temp_file_limit = -1 # limits per-process temp file space
  162 + # in kilobytes, or -1 for no limit
  163 +
  164 +# - Kernel Resources -
  165 +
  166 +#max_files_per_process = 1000 # min 64
  167 + # (change requires restart)
  168 +
  169 +# - Cost-Based Vacuum Delay -
  170 +
  171 +#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables)
  172 +#vacuum_cost_page_hit = 1 # 0-10000 credits
  173 +#vacuum_cost_page_miss = 2 # 0-10000 credits
  174 +#vacuum_cost_page_dirty = 20 # 0-10000 credits
  175 +#vacuum_cost_limit = 200 # 1-10000 credits
  176 +
  177 +# - Background Writer -
  178 +
  179 +#bgwriter_delay = 200ms # 10-10000ms between rounds
  180 +#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables
  181 +#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
  182 +#bgwriter_flush_after = 0 # measured in pages, 0 disables
  183 +
  184 +# - Asynchronous Behavior -
  185 +
  186 +#backend_flush_after = 0 # measured in pages, 0 disables
  187 +#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching
  188 +#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching
  189 +#max_worker_processes = 8 # (change requires restart)
  190 +#max_parallel_workers_per_gather = 2 # taken from max_parallel_workers
  191 +#max_parallel_maintenance_workers = 2 # taken from max_parallel_workers
  192 +#max_parallel_workers = 8 # maximum number of max_worker_processes that
  193 + # can be used in parallel operations
  194 +#parallel_leader_participation = on
  195 +#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate
  196 + # (change requires restart)
  197 +
  198 +
  199 +#------------------------------------------------------------------------------
  200 +# WRITE-AHEAD LOG
  201 +#------------------------------------------------------------------------------
  202 +
  203 +# - Settings -
  204 +
  205 +wal_level = logical # minimal, replica, or logical
  206 + # (change requires restart)
  207 +#fsync = on # flush data to disk for crash safety
  208 + # (turning this off can cause
  209 + # unrecoverable data corruption)
  210 +#synchronous_commit = on # synchronization level;
  211 + # off, local, remote_write, remote_apply, or on
  212 +#wal_sync_method = fsync # the default is the first option
  213 + # supported by the operating system:
  214 + # open_datasync
  215 + # fdatasync (default on Linux and FreeBSD)
  216 + # fsync
  217 + # fsync_writethrough
  218 + # open_sync
  219 +#full_page_writes = on # recover from partial page writes
  220 +#wal_log_hints = off # also do full page writes of non-critical updates
  221 + # (change requires restart)
  222 +#wal_compression = off # enable compression of full-page writes
  223 +#wal_init_zero = on # zero-fill new WAL files
  224 +#wal_recycle = on # recycle WAL files
  225 +#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
  226 + # (change requires restart)
  227 +#wal_writer_delay = 200ms # 1-10000 milliseconds
  228 +#wal_writer_flush_after = 1MB # measured in pages, 0 disables
  229 +#wal_skip_threshold = 2MB
  230 +
  231 +#commit_delay = 0 # range 0-100000, in microseconds
  232 +#commit_siblings = 5 # range 1-1000
  233 +
  234 +# - Checkpoints -
  235 +
  236 +#checkpoint_timeout = 5min # range 30s-1d
  237 +#checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
  238 +#checkpoint_flush_after = 0 # measured in pages, 0 disables
  239 +#checkpoint_warning = 30s # 0 disables
  240 +#max_wal_size = 1GB
  241 +#min_wal_size = 80MB
  242 +
  243 +# - Archiving -
  244 +
  245 +#archive_mode = off # enables archiving; off, on, or always
  246 + # (change requires restart)
  247 +#archive_command = '' # command to use to archive a logfile segment
  248 + # placeholders: %p = path of file to archive
  249 + # %f = file name only
  250 + # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
  251 +#archive_timeout = 0 # force a logfile segment switch after this
  252 + # number of seconds; 0 disables
  253 +
  254 +# - Archive Recovery -
  255 +
  256 +# These are only used in recovery mode.
  257 +
  258 +#restore_command = '' # command to use to restore an archived logfile segment
  259 + # placeholders: %p = path of file to restore
  260 + # %f = file name only
  261 + # e.g. 'cp /mnt/server/archivedir/%f %p'
  262 +#archive_cleanup_command = '' # command to execute at every restartpoint
  263 +#recovery_end_command = '' # command to execute at completion of recovery
  264 +
  265 +# - Recovery Target -
  266 +
  267 +# Set these only when performing a targeted recovery.
  268 +
  269 +#recovery_target = '' # 'immediate' to end recovery as soon as a
  270 + # consistent state is reached
  271 + # (change requires restart)
  272 +#recovery_target_name = '' # the named restore point to which recovery will proceed
  273 + # (change requires restart)
  274 +#recovery_target_time = '' # the time stamp up to which recovery will proceed
  275 + # (change requires restart)
  276 +#recovery_target_xid = '' # the transaction ID up to which recovery will proceed
  277 + # (change requires restart)
  278 +#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed
  279 + # (change requires restart)
  280 +#recovery_target_inclusive = on # Specifies whether to stop:
  281 + # just after the specified recovery target (on)
  282 + # just before the recovery target (off)
  283 + # (change requires restart)
  284 +#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID
  285 + # (change requires restart)
  286 +#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
  287 + # (change requires restart)
  288 +
  289 +
  290 +#------------------------------------------------------------------------------
  291 +# REPLICATION
  292 +#------------------------------------------------------------------------------
  293 +
  294 +# - Sending Servers -
  295 +
  296 +# Set these on the primary and on any standby that will send replication data.
  297 +
  298 +max_wal_senders = 2 # max number of walsender processes
  299 + # (change requires restart)
  300 +#max_replication_slots = 10 # max number of replication slots
  301 + # (change requires restart)
  302 +#wal_keep_size = 0 # in megabytes; 0 disables
  303 +#max_slot_wal_keep_size = -1 # in megabytes; -1 disables
  304 +#wal_sender_timeout = 60s # in milliseconds; 0 disables
  305 +#track_commit_timestamp = off # collect timestamp of transaction commit
  306 + # (change requires restart)
  307 +
  308 +# - Primary Server -
  309 +
  310 +# These settings are ignored on a standby server.
  311 +
  312 +#synchronous_standby_names = '' # standby servers that provide sync rep
  313 + # method to choose sync standbys, number of sync standbys,
  314 + # and comma-separated list of application_name
  315 + # from standby(s); '*' = all
  316 +#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
  317 +
  318 +# - Standby Servers -
  319 +
  320 +# These settings are ignored on a primary server.
  321 +
  322 +#primary_conninfo = '' # connection string to sending server
  323 +#primary_slot_name = '' # replication slot on sending server
  324 +#promote_trigger_file = '' # file name whose presence ends recovery
  325 +hot_standby = on # "off" disallows queries during recovery
  326 + # (change requires restart)
  327 +#max_standby_archive_delay = 30s # max delay before canceling queries
  328 + # when reading WAL from archive;
  329 + # -1 allows indefinite delay
  330 +#max_standby_streaming_delay = 30s # max delay before canceling queries
  331 + # when reading streaming WAL;
  332 + # -1 allows indefinite delay
  333 +#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name
  334 + # is not set
  335 +#wal_receiver_status_interval = 10s # send replies at least this often
  336 + # 0 disables
  337 +#hot_standby_feedback = off # send info from standby to prevent
  338 + # query conflicts
  339 +#wal_receiver_timeout = 60s # time that receiver waits for
  340 + # communication from primary
  341 + # in milliseconds; 0 disables
  342 +#wal_retrieve_retry_interval = 5s # time to wait before retrying to
  343 + # retrieve WAL after a failed attempt
  344 +#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery
  345 +
  346 +# - Subscribers -
  347 +
  348 +# These settings are ignored on a publisher.
  349 +
  350 +max_logical_replication_workers = 4 # taken from max_worker_processes
  351 + # (change requires restart)
  352 +max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers
  353 +
  354 +
  355 +#------------------------------------------------------------------------------
  356 +# QUERY TUNING
  357 +#------------------------------------------------------------------------------
  358 +
  359 +# - Planner Method Configuration -
  360 +
  361 +#enable_async_append = on
  362 +#enable_bitmapscan = on
  363 +#enable_gathermerge = on
  364 +#enable_hashagg = on
  365 +#enable_hashjoin = on
  366 +#enable_incremental_sort = on
  367 +#enable_indexscan = on
  368 +#enable_indexonlyscan = on
  369 +#enable_material = on
  370 +#enable_memoize = on
  371 +#enable_mergejoin = on
  372 +#enable_nestloop = on
  373 +#enable_parallel_append = on
  374 +#enable_parallel_hash = on
  375 +#enable_partition_pruning = on
  376 +#enable_partitionwise_join = off
  377 +#enable_partitionwise_aggregate = off
  378 +#enable_seqscan = on
  379 +#enable_sort = on
  380 +#enable_tidscan = on
  381 +
  382 +# - Planner Cost Constants -
  383 +
  384 +#seq_page_cost = 1.0 # measured on an arbitrary scale
  385 +#random_page_cost = 4.0 # same scale as above
  386 +#cpu_tuple_cost = 0.01 # same scale as above
  387 +#cpu_index_tuple_cost = 0.005 # same scale as above
  388 +#cpu_operator_cost = 0.0025 # same scale as above
  389 +#parallel_setup_cost = 1000.0 # same scale as above
  390 +#parallel_tuple_cost = 0.1 # same scale as above
  391 +#min_parallel_table_scan_size = 8MB
  392 +#min_parallel_index_scan_size = 512kB
  393 +#effective_cache_size = 4GB
  394 +
  395 +#jit_above_cost = 100000 # perform JIT compilation if available
  396 + # and query more expensive than this;
  397 + # -1 disables
  398 +#jit_inline_above_cost = 500000 # inline small functions if query is
  399 + # more expensive than this; -1 disables
  400 +#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if
  401 + # query is more expensive than this;
  402 + # -1 disables
  403 +
  404 +# - Genetic Query Optimizer -
  405 +
  406 +#geqo = on
  407 +#geqo_threshold = 12
  408 +#geqo_effort = 5 # range 1-10
  409 +#geqo_pool_size = 0 # selects default based on effort
  410 +#geqo_generations = 0 # selects default based on effort
  411 +#geqo_selection_bias = 2.0 # range 1.5-2.0
  412 +#geqo_seed = 0.0 # range 0.0-1.0
  413 +
  414 +# - Other Planner Options -
  415 +
  416 +#default_statistics_target = 100 # range 1-10000
  417 +#constraint_exclusion = partition # on, off, or partition
  418 +#cursor_tuple_fraction = 0.1 # range 0.0-1.0
  419 +#from_collapse_limit = 8
  420 +#jit = on # allow JIT compilation
  421 +#join_collapse_limit = 8 # 1 disables collapsing of explicit
  422 + # JOIN clauses
  423 +#plan_cache_mode = auto # auto, force_generic_plan or
  424 + # force_custom_plan
  425 +
  426 +
  427 +#------------------------------------------------------------------------------
  428 +# REPORTING AND LOGGING
  429 +#------------------------------------------------------------------------------
  430 +
  431 +# - Where to Log -
  432 +
  433 +#log_destination = 'stderr' # Valid values are combinations of
  434 + # stderr, csvlog, syslog, and eventlog,
  435 + # depending on platform. csvlog
  436 + # requires logging_collector to be on.
  437 +
  438 +# This is used when logging to stderr:
  439 +#logging_collector = off # Enable capturing of stderr and csvlog
  440 + # into log files. Required to be on for
  441 + # csvlogs.
  442 + # (change requires restart)
  443 +
  444 +# These are only used if logging_collector is on:
  445 +#log_directory = 'log' # directory where log files are written,
  446 + # can be absolute or relative to PGDATA
  447 +#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
  448 + # can include strftime() escapes
  449 +#log_file_mode = 0600 # creation mode for log files,
  450 + # begin with 0 to use octal notation
  451 +#log_rotation_age = 1d # Automatic rotation of logfiles will
  452 + # happen after that time. 0 disables.
  453 +#log_rotation_size = 10MB # Automatic rotation of logfiles will
  454 + # happen after that much log output.
  455 + # 0 disables.
  456 +#log_truncate_on_rotation = off # If on, an existing log file with the
  457 + # same name as the new log file will be
  458 + # truncated rather than appended to.
  459 + # But such truncation only occurs on
  460 + # time-driven rotation, not on restarts
  461 + # or size-driven rotation. Default is
  462 + # off, meaning append to existing files
  463 + # in all cases.
  464 +
  465 +# These are relevant when logging to syslog:
  466 +#syslog_facility = 'LOCAL0'
  467 +#syslog_ident = 'postgres'
  468 +#syslog_sequence_numbers = on
  469 +#syslog_split_messages = on
  470 +
  471 +# This is only relevant when logging to eventlog (Windows):
  472 +# (change requires restart)
  473 +#event_source = 'PostgreSQL'
  474 +
  475 +# - When to Log -
  476 +
  477 +#log_min_messages = warning # values in order of decreasing detail:
  478 + # debug5
  479 + # debug4
  480 + # debug3
  481 + # debug2
  482 + # debug1
  483 + # info
  484 + # notice
  485 + # warning
  486 + # error
  487 + # log
  488 + # fatal
  489 + # panic
  490 +
  491 +#log_min_error_statement = error # values in order of decreasing detail:
  492 + # debug5
  493 + # debug4
  494 + # debug3
  495 + # debug2
  496 + # debug1
  497 + # info
  498 + # notice
  499 + # warning
  500 + # error
  501 + # log
  502 + # fatal
  503 + # panic (effectively off)
  504 +
  505 +#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
  506 + # and their durations, > 0 logs only
  507 + # statements running at least this number
  508 + # of milliseconds
  509 +
  510 +#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements
  511 + # and their durations, > 0 logs only a sample of
  512 + # statements running at least this number
  513 + # of milliseconds;
  514 + # sample fraction is determined by log_statement_sample_rate
  515 +
  516 +#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding
  517 + # log_min_duration_sample to be logged;
  518 + # 1.0 logs all such statements, 0.0 never logs
  519 +
  520 +
  521 +#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements
  522 + # are logged regardless of their duration; 1.0 logs all
  523 + # statements from all transactions, 0.0 never logs
  524 +
  525 +# - What to Log -
  526 +
  527 +#debug_print_parse = off
  528 +#debug_print_rewritten = off
  529 +#debug_print_plan = off
  530 +#debug_pretty_print = on
  531 +#log_autovacuum_min_duration = -1 # log autovacuum activity;
  532 + # -1 disables, 0 logs all actions and
  533 + # their durations, > 0 logs only
  534 + # actions running at least this number
  535 + # of milliseconds.
  536 +#log_checkpoints = off
  537 +#log_connections = off
  538 +#log_disconnections = off
  539 +#log_duration = off
  540 +#log_error_verbosity = default # terse, default, or verbose messages
  541 +#log_hostname = off
  542 +#log_line_prefix = '%m [%p] ' # special values:
  543 + # %a = application name
  544 + # %u = user name
  545 + # %d = database name
  546 + # %r = remote host and port
  547 + # %h = remote host
  548 + # %b = backend type
  549 + # %p = process ID
  550 + # %P = process ID of parallel group leader
  551 + # %t = timestamp without milliseconds
  552 + # %m = timestamp with milliseconds
  553 + # %n = timestamp with milliseconds (as a Unix epoch)
  554 + # %Q = query ID (0 if none or not computed)
  555 + # %i = command tag
  556 + # %e = SQL state
  557 + # %c = session ID
  558 + # %l = session line number
  559 + # %s = session start timestamp
  560 + # %v = virtual transaction ID
  561 + # %x = transaction ID (0 if none)
  562 + # %q = stop here in non-session
  563 + # processes
  564 + # %% = '%'
  565 + # e.g. '<%u%%%d> '
  566 +#log_lock_waits = off # log lock waits >= deadlock_timeout
  567 +#log_recovery_conflict_waits = off # log standby recovery conflict waits
  568 + # >= deadlock_timeout
  569 +#log_parameter_max_length = -1 # when logging statements, limit logged
  570 + # bind-parameter values to N bytes;
  571 + # -1 means print in full, 0 disables
  572 +#log_parameter_max_length_on_error = 0 # when logging an error, limit logged
  573 + # bind-parameter values to N bytes;
  574 + # -1 means print in full, 0 disables
  575 +#log_statement = 'none' # none, ddl, mod, all
  576 +#log_replication_commands = off
  577 +#log_temp_files = -1 # log temporary files equal or larger
  578 + # than the specified size in kilobytes;
  579 + # -1 disables, 0 logs all temp files
  580 +#log_timezone = 'GMT'
  581 +
  582 +
  583 +#------------------------------------------------------------------------------
  584 +# PROCESS TITLE
  585 +#------------------------------------------------------------------------------
  586 +
  587 +#cluster_name = '' # added to process titles if nonempty
  588 + # (change requires restart)
  589 +#update_process_title = on
  590 +
  591 +
  592 +#------------------------------------------------------------------------------
  593 +# STATISTICS
  594 +#------------------------------------------------------------------------------
  595 +
  596 +# - Query and Index Statistics Collector -
  597 +
  598 +#track_activities = on
  599 +#track_activity_query_size = 1024 # (change requires restart)
  600 +#track_counts = on
  601 +#track_io_timing = off
  602 +#track_wal_io_timing = off
  603 +#track_functions = none # none, pl, all
  604 +#stats_temp_directory = 'pg_stat_tmp'
  605 +
  606 +
  607 +# - Monitoring -
  608 +
  609 +#compute_query_id = auto
  610 +#log_statement_stats = off
  611 +#log_parser_stats = off
  612 +#log_planner_stats = off
  613 +#log_executor_stats = off
  614 +
  615 +
  616 +#------------------------------------------------------------------------------
  617 +# AUTOVACUUM
  618 +#------------------------------------------------------------------------------
  619 +
  620 +#autovacuum = on # Enable autovacuum subprocess? 'on'
  621 + # requires track_counts to also be on.
  622 +#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
  623 + # (change requires restart)
  624 +#autovacuum_naptime = 1min # time between autovacuum runs
  625 +#autovacuum_vacuum_threshold = 50 # min number of row updates before
  626 + # vacuum
  627 +#autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts
  628 + # before vacuum; -1 disables insert
  629 + # vacuums
  630 +#autovacuum_analyze_threshold = 50 # min number of row updates before
  631 + # analyze
  632 +#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
  633 +#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table
  634 + # size before insert vacuum
  635 +#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
  636 +#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
  637 + # (change requires restart)
  638 +#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
  639 + # before forced vacuum
  640 + # (change requires restart)
  641 +#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for
  642 + # autovacuum, in milliseconds;
  643 + # -1 means use vacuum_cost_delay
  644 +#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
  645 + # autovacuum, -1 means use
  646 + # vacuum_cost_limit
  647 +
  648 +
  649 +#------------------------------------------------------------------------------
  650 +# CLIENT CONNECTION DEFAULTS
  651 +#------------------------------------------------------------------------------
  652 +
  653 +# - Statement Behavior -
  654 +
  655 +#client_min_messages = notice # values in order of decreasing detail:
  656 + # debug5
  657 + # debug4
  658 + # debug3
  659 + # debug2
  660 + # debug1
  661 + # log
  662 + # notice
  663 + # warning
  664 + # error
  665 +#search_path = '"$user", public' # schema names
  666 +#row_security = on
  667 +#default_table_access_method = 'heap'
  668 +#default_tablespace = '' # a tablespace name, '' uses the default
  669 +#default_toast_compression = 'pglz' # 'pglz' or 'lz4'
  670 +#temp_tablespaces = '' # a list of tablespace names, '' uses
  671 + # only default tablespace
  672 +#check_function_bodies = on
  673 +#default_transaction_isolation = 'read committed'
  674 +#default_transaction_read_only = off
  675 +#default_transaction_deferrable = off
  676 +#session_replication_role = 'origin'
  677 +#statement_timeout = 0 # in milliseconds, 0 is disabled
  678 +#lock_timeout = 0 # in milliseconds, 0 is disabled
  679 +#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
  680 +#idle_session_timeout = 0 # in milliseconds, 0 is disabled
  681 +#vacuum_freeze_table_age = 150000000
  682 +#vacuum_freeze_min_age = 50000000
  683 +#vacuum_failsafe_age = 1600000000
  684 +#vacuum_multixact_freeze_table_age = 150000000
  685 +#vacuum_multixact_freeze_min_age = 5000000
  686 +#vacuum_multixact_failsafe_age = 1600000000
  687 +#bytea_output = 'hex' # hex, escape
  688 +#xmlbinary = 'base64'
  689 +#xmloption = 'content'
  690 +#gin_pending_list_limit = 4MB
  691 +
  692 +# - Locale and Formatting -
  693 +
  694 +#datestyle = 'iso, mdy'
  695 +#intervalstyle = 'postgres'
  696 +#timezone = 'GMT'
  697 +#timezone_abbreviations = 'Default' # Select the set of available time zone
  698 + # abbreviations. Currently, there are
  699 + # Default
  700 + # Australia (historical usage)
  701 + # India
  702 + # You can create your own file in
  703 + # share/timezonesets/.
  704 +#extra_float_digits = 1 # min -15, max 3; any value >0 actually
  705 + # selects precise output mode
  706 +#client_encoding = sql_ascii # actually, defaults to database
  707 + # encoding
  708 +
  709 +# These settings are initialized by initdb, but they can be changed.
  710 +#lc_messages = 'C' # locale for system error message
  711 + # strings
  712 +#lc_monetary = 'C' # locale for monetary formatting
  713 +#lc_numeric = 'C' # locale for number formatting
  714 +#lc_time = 'C' # locale for time formatting
  715 +
  716 +# default configuration for text search
  717 +#default_text_search_config = 'pg_catalog.simple'
  718 +
  719 +# - Shared Library Preloading -
  720 +
  721 +#local_preload_libraries = ''
  722 +#session_preload_libraries = ''
  723 +#shared_preload_libraries = '' # (change requires restart)
  724 +#jit_provider = 'llvmjit' # JIT library to use
  725 +
  726 +# - Other Defaults -
  727 +
  728 +#dynamic_library_path = '$libdir'
  729 +#extension_destdir = '' # prepend path when loading extensions
  730 + # and shared objects (added by Debian)
  731 +#gin_fuzzy_search_limit = 0
  732 +
  733 +
  734 +#------------------------------------------------------------------------------
  735 +# LOCK MANAGEMENT
  736 +#------------------------------------------------------------------------------
  737 +
  738 +#deadlock_timeout = 1s
  739 +#max_locks_per_transaction = 64 # min 10
  740 + # (change requires restart)
  741 +#max_pred_locks_per_transaction = 64 # min 10
  742 + # (change requires restart)
  743 +#max_pred_locks_per_relation = -2 # negative values mean
  744 + # (max_pred_locks_per_transaction
  745 + # / -max_pred_locks_per_relation) - 1
  746 +#max_pred_locks_per_page = 2 # min 0
  747 +
  748 +
  749 +#------------------------------------------------------------------------------
  750 +# VERSION AND PLATFORM COMPATIBILITY
  751 +#------------------------------------------------------------------------------
  752 +
  753 +# - Previous PostgreSQL Versions -
  754 +
  755 +#array_nulls = on
  756 +#backslash_quote = safe_encoding # on, off, or safe_encoding
  757 +#escape_string_warning = on
  758 +#lo_compat_privileges = off
  759 +#quote_all_identifiers = off
  760 +#standard_conforming_strings = on
  761 +#synchronize_seqscans = on
  762 +
  763 +# - Other Platforms and Clients -
  764 +
  765 +#transform_null_equals = off
  766 +
  767 +
  768 +#------------------------------------------------------------------------------
  769 +# ERROR HANDLING
  770 +#------------------------------------------------------------------------------
  771 +
  772 +#exit_on_error = off # terminate session on any error?
  773 +#restart_after_crash = on # reinitialize after backend crash?
  774 +#data_sync_retry = off # retry or panic on failure to fsync
  775 + # data?
  776 + # (change requires restart)
  777 +#recovery_init_sync_method = fsync # fsync, syncfs (Linux 5.8+)
  778 +
  779 +
  780 +#------------------------------------------------------------------------------
  781 +# CONFIG FILE INCLUDES
  782 +#------------------------------------------------------------------------------
  783 +
  784 +# These options allow settings to be loaded from files other than the
  785 +# default postgresql.conf. Note that these are directives, not variable
  786 +# assignments, so they can usefully be given more than once.
  787 +
  788 +#include_dir = '...' # include files ending in '.conf' from
  789 + # a directory, e.g., 'conf.d'
  790 +#include_if_exists = '...' # include file only if it exists
  791 +#include = '...' # include file
  792 +
  793 +
  794 +#------------------------------------------------------------------------------
  795 +# CUSTOMIZED OPTIONS
  796 +#------------------------------------------------------------------------------
  797 +
  798 +# Add settings for extensions here
... ...
postgres/pg_hba.conf 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections only
  2 +local all all trust
  3 +# IPv4 local connections:
  4 +host all all 127.0.0.1/32 trust
  5 +# IPv6 local connections:
  6 +host all all ::1/128 trust
  7 +host all all 0.0.0.0/0 trust
  8 +# Allow replication connections from localhost, by a user with the
  9 +# replication privilege.
  10 +local replication all trust
  11 +host replication all 127.0.0.1/32 trust
  12 +host replication all ::1/128 trust
  13 +host replication replicator 0.0.0.0/0 trust
  14 +
  15 +host all all all md5
... ...
postgres/setup-master.sh 0 → 100755
... ... @@ -0,0 +1,16 @@
  1 +#!/bin/bash
  2 +set -e
  3 +
  4 +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
  5 + CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'my_replicator_password';
  6 +
  7 + CREATE TABLE test_replication (id INT PRIMARY KEY, name VARCHAR(30));
  8 + INSERT INTO test_replication (id, name) VALUES (1, 'test');
  9 + INSERT INTO test_replication (id, name) VALUES (2, 'test');
  10 + INSERT INTO test_replication (id, name) VALUES (3, 'test');
  11 + INSERT INTO test_replication (id, name) VALUES (4, 'test');
  12 +
  13 + GRANT ALL ON test_replication TO replicator;
  14 +
  15 + CREATE PUBLICATION pub FOR ALL TABLES;
  16 +EOSQL
... ...
postgres/setup-slave.sh 0 → 100755
... ... @@ -0,0 +1,11 @@
  1 +#!/bin/bash
  2 +set -e
  3 +
  4 +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
  5 +
  6 + CREATE TABLE test_replication (id INT PRIMARY KEY, name VARCHAR(30));
  7 +
  8 + CREATE SUBSCRIPTION my_subscription
  9 + CONNECTION 'host=postgres-master-1 port=5432 dbname=data_service password=my_replicator_password user=replicator' PUBLICATION pub;
  10 +
  11 +EOSQL
... ...
postgres/slave.conf 0 → 100644
... ... @@ -0,0 +1,798 @@
  1 +# -----------------------------
  2 +# PostgreSQL configuration file
  3 +# -----------------------------
  4 +#
  5 +# This file consists of lines of the form:
  6 +#
  7 +# name = value
  8 +#
  9 +# (The "=" is optional.) Whitespace may be used. Comments are introduced with
  10 +# "#" anywhere on a line. The complete list of parameter names and allowed
  11 +# values can be found in the PostgreSQL documentation.
  12 +#
  13 +# The commented-out settings shown in this file represent the default values.
  14 +# Re-commenting a setting is NOT sufficient to revert it to the default value;
  15 +# you need to reload the server.
  16 +#
  17 +# This file is read on server startup and when the server receives a SIGHUP
  18 +# signal. If you edit the file on a running system, you have to SIGHUP the
  19 +# server for the changes to take effect, run "pg_ctl reload", or execute
  20 +# "SELECT pg_reload_conf()". Some parameters, which are marked below,
  21 +# require a server shutdown and restart to take effect.
  22 +#
  23 +# Any parameter can also be given as a command-line option to the server, e.g.,
  24 +# "postgres -c log_connections=on". Some parameters can be changed at run time
  25 +# with the "SET" SQL command.
  26 +#
  27 +# Memory units: B = bytes Time units: us = microseconds
  28 +# kB = kilobytes ms = milliseconds
  29 +# MB = megabytes s = seconds
  30 +# GB = gigabytes min = minutes
  31 +# TB = terabytes h = hours
  32 +# d = days
  33 +
  34 +
  35 +#------------------------------------------------------------------------------
  36 +# FILE LOCATIONS
  37 +#------------------------------------------------------------------------------
  38 +
  39 +# The default values of these variables are driven from the -D command-line
  40 +# option or PGDATA environment variable, represented here as ConfigDir.
  41 +
  42 +#data_directory = 'ConfigDir' # use data in another directory
  43 + # (change requires restart)
  44 +#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
  45 + # (change requires restart)
  46 +#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
  47 + # (change requires restart)
  48 +
  49 +# If external_pid_file is not explicitly set, no extra PID file is written.
  50 +#external_pid_file = '' # write an extra PID file
  51 + # (change requires restart)
  52 +
  53 +
  54 +#------------------------------------------------------------------------------
  55 +# CONNECTIONS AND AUTHENTICATION
  56 +#------------------------------------------------------------------------------
  57 +
  58 +# - Connection Settings -
  59 +
  60 +listen_addresses = '*'
  61 + # comma-separated list of addresses;
  62 + # defaults to 'localhost'; use '*' for all
  63 + # (change requires restart)
  64 +#port = 5432 # (change requires restart)
  65 +#max_connections = 100 # (change requires restart)
  66 +#superuser_reserved_connections = 3 # (change requires restart)
  67 +#unix_socket_directories = '/tmp' # comma-separated list of directories
  68 + # (change requires restart)
  69 +#unix_socket_group = '' # (change requires restart)
  70 +#unix_socket_permissions = 0777 # begin with 0 to use octal notation
  71 + # (change requires restart)
  72 +#bonjour = off # advertise server via Bonjour
  73 + # (change requires restart)
  74 +#bonjour_name = '' # defaults to the computer name
  75 + # (change requires restart)
  76 +
  77 +# - TCP settings -
  78 +# see "man tcp" for details
  79 +
  80 +#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
  81 + # 0 selects the system default
  82 +#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
  83 + # 0 selects the system default
  84 +#tcp_keepalives_count = 0 # TCP_KEEPCNT;
  85 + # 0 selects the system default
  86 +#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds;
  87 + # 0 selects the system default
  88 +
  89 +#client_connection_check_interval = 0 # time between checks for client
  90 + # disconnection while running queries;
  91 + # 0 for never
  92 +
  93 +# - Authentication -
  94 +
  95 +#authentication_timeout = 1min # 1s-600s
  96 +#password_encryption = scram-sha-256 # scram-sha-256 or md5
  97 +#db_user_namespace = off
  98 +
  99 +# GSSAPI using Kerberos
  100 +#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
  101 +#krb_caseins_users = off
  102 +
  103 +# - SSL -
  104 +
  105 +#ssl = off
  106 +#ssl_ca_file = ''
  107 +#ssl_cert_file = 'server.crt'
  108 +#ssl_crl_file = ''
  109 +#ssl_crl_dir = ''
  110 +#ssl_key_file = 'server.key'
  111 +#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
  112 +#ssl_prefer_server_ciphers = on
  113 +#ssl_ecdh_curve = 'prime256v1'
  114 +#ssl_min_protocol_version = 'TLSv1.2'
  115 +#ssl_max_protocol_version = ''
  116 +#ssl_dh_params_file = ''
  117 +#ssl_passphrase_command = ''
  118 +#ssl_passphrase_command_supports_reload = off
  119 +
  120 +
  121 +#------------------------------------------------------------------------------
  122 +# RESOURCE USAGE (except WAL)
  123 +#------------------------------------------------------------------------------
  124 +
  125 +# - Memory -
  126 +
  127 +#shared_buffers = 32MB # min 128kB
  128 + # (change requires restart)
  129 +#huge_pages = try # on, off, or try
  130 + # (change requires restart)
  131 +#huge_page_size = 0 # zero for system default
  132 + # (change requires restart)
  133 +#temp_buffers = 8MB # min 800kB
  134 +#max_prepared_transactions = 0 # zero disables the feature
  135 + # (change requires restart)
  136 +# Caution: it is not advisable to set max_prepared_transactions nonzero unless
  137 +# you actively intend to use prepared transactions.
  138 +#work_mem = 4MB # min 64kB
  139 +#hash_mem_multiplier = 1.0 # 1-1000.0 multiplier on hash table work_mem
  140 +#maintenance_work_mem = 64MB # min 1MB
  141 +#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
  142 +#logical_decoding_work_mem = 64MB # min 64kB
  143 +#max_stack_depth = 2MB # min 100kB
  144 +#shared_memory_type = mmap # the default is the first option
  145 + # supported by the operating system:
  146 + # mmap
  147 + # sysv
  148 + # windows
  149 + # (change requires restart)
  150 +#dynamic_shared_memory_type = posix # the default is the first option
  151 + # supported by the operating system:
  152 + # posix
  153 + # sysv
  154 + # windows
  155 + # mmap
  156 + # (change requires restart)
  157 +#min_dynamic_shared_memory = 0MB # (change requires restart)
  158 +
  159 +# - Disk -
  160 +
  161 +#temp_file_limit = -1 # limits per-process temp file space
  162 + # in kilobytes, or -1 for no limit
  163 +
  164 +# - Kernel Resources -
  165 +
  166 +#max_files_per_process = 1000 # min 64
  167 + # (change requires restart)
  168 +
  169 +# - Cost-Based Vacuum Delay -
  170 +
  171 +#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables)
  172 +#vacuum_cost_page_hit = 1 # 0-10000 credits
  173 +#vacuum_cost_page_miss = 2 # 0-10000 credits
  174 +#vacuum_cost_page_dirty = 20 # 0-10000 credits
  175 +#vacuum_cost_limit = 200 # 1-10000 credits
  176 +
  177 +# - Background Writer -
  178 +
  179 +#bgwriter_delay = 200ms # 10-10000ms between rounds
  180 +#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables
  181 +#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
  182 +#bgwriter_flush_after = 0 # measured in pages, 0 disables
  183 +
  184 +# - Asynchronous Behavior -
  185 +
  186 +#backend_flush_after = 0 # measured in pages, 0 disables
  187 +#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching
  188 +#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching
  189 +#max_worker_processes = 8 # (change requires restart)
  190 +#max_parallel_workers_per_gather = 2 # taken from max_parallel_workers
  191 +#max_parallel_maintenance_workers = 2 # taken from max_parallel_workers
  192 +#max_parallel_workers = 8 # maximum number of max_worker_processes that
  193 + # can be used in parallel operations
  194 +#parallel_leader_participation = on
  195 +#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate
  196 + # (change requires restart)
  197 +
  198 +
  199 +#------------------------------------------------------------------------------
  200 +# WRITE-AHEAD LOG
  201 +#------------------------------------------------------------------------------
  202 +
  203 +# - Settings -
  204 +
  205 +wal_level = logical # minimal, replica, or logical
  206 + # (change requires restart)
  207 +#fsync = on # flush data to disk for crash safety
  208 + # (turning this off can cause
  209 + # unrecoverable data corruption)
  210 +#synchronous_commit = on # synchronization level;
  211 + # off, local, remote_write, remote_apply, or on
  212 +#wal_sync_method = fsync # the default is the first option
  213 + # supported by the operating system:
  214 + # open_datasync
  215 + # fdatasync (default on Linux and FreeBSD)
  216 + # fsync
  217 + # fsync_writethrough
  218 + # open_sync
  219 +#full_page_writes = on # recover from partial page writes
  220 +#wal_log_hints = off # also do full page writes of non-critical updates
  221 + # (change requires restart)
  222 +#wal_compression = off # enable compression of full-page writes
  223 +#wal_init_zero = on # zero-fill new WAL files
  224 +#wal_recycle = on # recycle WAL files
  225 +#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
  226 + # (change requires restart)
  227 +#wal_writer_delay = 200ms # 1-10000 milliseconds
  228 +#wal_writer_flush_after = 1MB # measured in pages, 0 disables
  229 +#wal_skip_threshold = 2MB
  230 +
  231 +#commit_delay = 0 # range 0-100000, in microseconds
  232 +#commit_siblings = 5 # range 1-1000
  233 +
  234 +# - Checkpoints -
  235 +
  236 +#checkpoint_timeout = 5min # range 30s-1d
  237 +#checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
  238 +#checkpoint_flush_after = 0 # measured in pages, 0 disables
  239 +#checkpoint_warning = 30s # 0 disables
  240 +#max_wal_size = 1GB
  241 +#min_wal_size = 80MB
  242 +
  243 +# - Archiving -
  244 +
  245 +#archive_mode = off # enables archiving; off, on, or always
  246 + # (change requires restart)
  247 +#archive_command = '' # command to use to archive a logfile segment
  248 + # placeholders: %p = path of file to archive
  249 + # %f = file name only
  250 + # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
  251 +#archive_timeout = 0 # force a logfile segment switch after this
  252 + # number of seconds; 0 disables
  253 +
  254 +# - Archive Recovery -
  255 +
  256 +# These are only used in recovery mode.
  257 +
  258 +restore_command = 'cp /var/lib/postgresql/data/pg_wal/%f "%p"' # command to use to restore an archived logfile segment
  259 + # placeholders: %p = path of file to restore
  260 + # %f = file name only
  261 + # e.g. 'cp /mnt/server/archivedir/%f %p'
  262 +#archive_cleanup_command = '' # command to execute at every restartpoint
  263 +#recovery_end_command = '' # command to execute at completion of recovery
  264 +
  265 +# - Recovery Target -
  266 +
  267 +# Set these only when performing a targeted recovery.
  268 +
  269 +#recovery_target = '' # 'immediate' to end recovery as soon as a
  270 + # consistent state is reached
  271 + # (change requires restart)
  272 +#recovery_target_name = '' # the named restore point to which recovery will proceed
  273 + # (change requires restart)
  274 +#recovery_target_time = '' # the time stamp up to which recovery will proceed
  275 + # (change requires restart)
  276 +#recovery_target_xid = '' # the transaction ID up to which recovery will proceed
  277 + # (change requires restart)
  278 +#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed
  279 + # (change requires restart)
  280 +#recovery_target_inclusive = on # Specifies whether to stop:
  281 + # just after the specified recovery target (on)
  282 + # just before the recovery target (off)
  283 + # (change requires restart)
  284 +#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID
  285 + # (change requires restart)
  286 +#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
  287 + # (change requires restart)
  288 +
  289 +
  290 +#------------------------------------------------------------------------------
  291 +# REPLICATION
  292 +#------------------------------------------------------------------------------
  293 +
  294 +# - Sending Servers -
  295 +
  296 +# Set these on the primary and on any standby that will send replication data.
  297 +
  298 +max_wal_senders = 2 # max number of walsender processes
  299 + # (change requires restart)
  300 +#max_replication_slots = 10 # max number of replication slots
  301 + # (change requires restart)
  302 +#wal_keep_size = 0 # in megabytes; 0 disables
  303 +#max_slot_wal_keep_size = -1 # in megabytes; -1 disables
  304 +#wal_sender_timeout = 60s # in milliseconds; 0 disables
  305 +#track_commit_timestamp = off # collect timestamp of transaction commit
  306 + # (change requires restart)
  307 +
  308 +# - Primary Server -
  309 +
  310 +# These settings are ignored on a standby server.
  311 +
  312 +#synchronous_standby_names = '' # standby servers that provide sync rep
  313 + # method to choose sync standbys, number of sync standbys,
  314 + # and comma-separated list of application_name
  315 + # from standby(s); '*' = all
  316 +#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
  317 +
  318 +# - Standby Servers -
  319 +
  320 +# These settings are ignored on a primary server.
  321 +
  322 +# primary_conninfo = 'host=customer-plans-service-customer-plans-service-db-master-1 port=5432 user=replicator password=my_replicator_password' # connection string to sending server
  323 +#primary_slot_name = '' # replication slot on sending server
  324 +#promote_trigger_file = '' # file name whose presence ends recovery
  325 +hot_standby = on # "off" disallows queries during recovery
  326 + # (change requires restart)
  327 +#max_standby_archive_delay = 30s # max delay before canceling queries
  328 + # when reading WAL from archive;
  329 + # -1 allows indefinite delay
  330 +#max_standby_streaming_delay = 30s # max delay before canceling queries
  331 + # when reading streaming WAL;
  332 + # -1 allows indefinite delay
  333 +#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name
  334 + # is not set
  335 +#wal_receiver_status_interval = 10s # send replies at least this often
  336 + # 0 disables
  337 +#hot_standby_feedback = off # send info from standby to prevent
  338 + # query conflicts
  339 +#wal_receiver_timeout = 60s # time that receiver waits for
  340 + # communication from primary
  341 + # in milliseconds; 0 disables
  342 +#wal_retrieve_retry_interval = 5s # time to wait before retrying to
  343 + # retrieve WAL after a failed attempt
  344 +#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery
  345 +
  346 +# - Subscribers -
  347 +
  348 +# These settings are ignored on a publisher.
  349 +
  350 +max_logical_replication_workers = 4 # taken from max_worker_processes
  351 + # (change requires restart)
  352 +max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers
  353 +
  354 +
  355 +#------------------------------------------------------------------------------
  356 +# QUERY TUNING
  357 +#------------------------------------------------------------------------------
  358 +
  359 +# - Planner Method Configuration -
  360 +
  361 +#enable_async_append = on
  362 +#enable_bitmapscan = on
  363 +#enable_gathermerge = on
  364 +#enable_hashagg = on
  365 +#enable_hashjoin = on
  366 +#enable_incremental_sort = on
  367 +#enable_indexscan = on
  368 +#enable_indexonlyscan = on
  369 +#enable_material = on
  370 +#enable_memoize = on
  371 +#enable_mergejoin = on
  372 +#enable_nestloop = on
  373 +#enable_parallel_append = on
  374 +#enable_parallel_hash = on
  375 +#enable_partition_pruning = on
  376 +#enable_partitionwise_join = off
  377 +#enable_partitionwise_aggregate = off
  378 +#enable_seqscan = on
  379 +#enable_sort = on
  380 +#enable_tidscan = on
  381 +
  382 +# - Planner Cost Constants -
  383 +
  384 +#seq_page_cost = 1.0 # measured on an arbitrary scale
  385 +#random_page_cost = 4.0 # same scale as above
  386 +#cpu_tuple_cost = 0.01 # same scale as above
  387 +#cpu_index_tuple_cost = 0.005 # same scale as above
  388 +#cpu_operator_cost = 0.0025 # same scale as above
  389 +#parallel_setup_cost = 1000.0 # same scale as above
  390 +#parallel_tuple_cost = 0.1 # same scale as above
  391 +#min_parallel_table_scan_size = 8MB
  392 +#min_parallel_index_scan_size = 512kB
  393 +#effective_cache_size = 4GB
  394 +
  395 +#jit_above_cost = 100000 # perform JIT compilation if available
  396 + # and query more expensive than this;
  397 + # -1 disables
  398 +#jit_inline_above_cost = 500000 # inline small functions if query is
  399 + # more expensive than this; -1 disables
  400 +#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if
  401 + # query is more expensive than this;
  402 + # -1 disables
  403 +
  404 +# - Genetic Query Optimizer -
  405 +
  406 +#geqo = on
  407 +#geqo_threshold = 12
  408 +#geqo_effort = 5 # range 1-10
  409 +#geqo_pool_size = 0 # selects default based on effort
  410 +#geqo_generations = 0 # selects default based on effort
  411 +#geqo_selection_bias = 2.0 # range 1.5-2.0
  412 +#geqo_seed = 0.0 # range 0.0-1.0
  413 +
  414 +# - Other Planner Options -
  415 +
  416 +#default_statistics_target = 100 # range 1-10000
  417 +#constraint_exclusion = partition # on, off, or partition
  418 +#cursor_tuple_fraction = 0.1 # range 0.0-1.0
  419 +#from_collapse_limit = 8
  420 +#jit = on # allow JIT compilation
  421 +#join_collapse_limit = 8 # 1 disables collapsing of explicit
  422 + # JOIN clauses
  423 +#plan_cache_mode = auto # auto, force_generic_plan or
  424 + # force_custom_plan
  425 +
  426 +
  427 +#------------------------------------------------------------------------------
  428 +# REPORTING AND LOGGING
  429 +#------------------------------------------------------------------------------
  430 +
  431 +# - Where to Log -
  432 +
  433 +#log_destination = 'stderr' # Valid values are combinations of
  434 + # stderr, csvlog, syslog, and eventlog,
  435 + # depending on platform. csvlog
  436 + # requires logging_collector to be on.
  437 +
  438 +# This is used when logging to stderr:
  439 +#logging_collector = off # Enable capturing of stderr and csvlog
  440 + # into log files. Required to be on for
  441 + # csvlogs.
  442 + # (change requires restart)
  443 +
  444 +# These are only used if logging_collector is on:
  445 +#log_directory = 'log' # directory where log files are written,
  446 + # can be absolute or relative to PGDATA
  447 +#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
  448 + # can include strftime() escapes
  449 +#log_file_mode = 0600 # creation mode for log files,
  450 + # begin with 0 to use octal notation
  451 +#log_rotation_age = 1d # Automatic rotation of logfiles will
  452 + # happen after that time. 0 disables.
  453 +#log_rotation_size = 10MB # Automatic rotation of logfiles will
  454 + # happen after that much log output.
  455 + # 0 disables.
  456 +#log_truncate_on_rotation = off # If on, an existing log file with the
  457 + # same name as the new log file will be
  458 + # truncated rather than appended to.
  459 + # But such truncation only occurs on
  460 + # time-driven rotation, not on restarts
  461 + # or size-driven rotation. Default is
  462 + # off, meaning append to existing files
  463 + # in all cases.
  464 +
  465 +# These are relevant when logging to syslog:
  466 +#syslog_facility = 'LOCAL0'
  467 +#syslog_ident = 'postgres'
  468 +#syslog_sequence_numbers = on
  469 +#syslog_split_messages = on
  470 +
  471 +# This is only relevant when logging to eventlog (Windows):
  472 +# (change requires restart)
  473 +#event_source = 'PostgreSQL'
  474 +
  475 +# - When to Log -
  476 +
  477 +#log_min_messages = warning # values in order of decreasing detail:
  478 + # debug5
  479 + # debug4
  480 + # debug3
  481 + # debug2
  482 + # debug1
  483 + # info
  484 + # notice
  485 + # warning
  486 + # error
  487 + # log
  488 + # fatal
  489 + # panic
  490 +
  491 +#log_min_error_statement = error # values in order of decreasing detail:
  492 + # debug5
  493 + # debug4
  494 + # debug3
  495 + # debug2
  496 + # debug1
  497 + # info
  498 + # notice
  499 + # warning
  500 + # error
  501 + # log
  502 + # fatal
  503 + # panic (effectively off)
  504 +
  505 +#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
  506 + # and their durations, > 0 logs only
  507 + # statements running at least this number
  508 + # of milliseconds
  509 +
  510 +#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements
  511 + # and their durations, > 0 logs only a sample of
  512 + # statements running at least this number
  513 + # of milliseconds;
  514 + # sample fraction is determined by log_statement_sample_rate
  515 +
  516 +#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding
  517 + # log_min_duration_sample to be logged;
  518 + # 1.0 logs all such statements, 0.0 never logs
  519 +
  520 +
  521 +#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements
  522 + # are logged regardless of their duration; 1.0 logs all
  523 + # statements from all transactions, 0.0 never logs
  524 +
  525 +# - What to Log -
  526 +
  527 +#debug_print_parse = off
  528 +#debug_print_rewritten = off
  529 +#debug_print_plan = off
  530 +#debug_pretty_print = on
  531 +#log_autovacuum_min_duration = -1 # log autovacuum activity;
  532 + # -1 disables, 0 logs all actions and
  533 + # their durations, > 0 logs only
  534 + # actions running at least this number
  535 + # of milliseconds.
  536 +#log_checkpoints = off
  537 +#log_connections = off
  538 +#log_disconnections = off
  539 +#log_duration = off
  540 +#log_error_verbosity = default # terse, default, or verbose messages
  541 +#log_hostname = off
  542 +#log_line_prefix = '%m [%p] ' # special values:
  543 + # %a = application name
  544 + # %u = user name
  545 + # %d = database name
  546 + # %r = remote host and port
  547 + # %h = remote host
  548 + # %b = backend type
  549 + # %p = process ID
  550 + # %P = process ID of parallel group leader
  551 + # %t = timestamp without milliseconds
  552 + # %m = timestamp with milliseconds
  553 + # %n = timestamp with milliseconds (as a Unix epoch)
  554 + # %Q = query ID (0 if none or not computed)
  555 + # %i = command tag
  556 + # %e = SQL state
  557 + # %c = session ID
  558 + # %l = session line number
  559 + # %s = session start timestamp
  560 + # %v = virtual transaction ID
  561 + # %x = transaction ID (0 if none)
  562 + # %q = stop here in non-session
  563 + # processes
  564 + # %% = '%'
  565 + # e.g. '<%u%%%d> '
  566 +#log_lock_waits = off # log lock waits >= deadlock_timeout
  567 +#log_recovery_conflict_waits = off # log standby recovery conflict waits
  568 + # >= deadlock_timeout
  569 +#log_parameter_max_length = -1 # when logging statements, limit logged
  570 + # bind-parameter values to N bytes;
  571 + # -1 means print in full, 0 disables
  572 +#log_parameter_max_length_on_error = 0 # when logging an error, limit logged
  573 + # bind-parameter values to N bytes;
  574 + # -1 means print in full, 0 disables
  575 +#log_statement = 'none' # none, ddl, mod, all
  576 +#log_replication_commands = off
  577 +#log_temp_files = -1 # log temporary files equal or larger
  578 + # than the specified size in kilobytes;
  579 + # -1 disables, 0 logs all temp files
  580 +#log_timezone = 'GMT'
  581 +
  582 +
  583 +#------------------------------------------------------------------------------
  584 +# PROCESS TITLE
  585 +#------------------------------------------------------------------------------
  586 +
  587 +#cluster_name = '' # added to process titles if nonempty
  588 + # (change requires restart)
  589 +#update_process_title = on
  590 +
  591 +
  592 +#------------------------------------------------------------------------------
  593 +# STATISTICS
  594 +#------------------------------------------------------------------------------
  595 +
  596 +# - Query and Index Statistics Collector -
  597 +
  598 +#track_activities = on
  599 +#track_activity_query_size = 1024 # (change requires restart)
  600 +#track_counts = on
  601 +#track_io_timing = off
  602 +#track_wal_io_timing = off
  603 +#track_functions = none # none, pl, all
  604 +#stats_temp_directory = 'pg_stat_tmp'
  605 +
  606 +
  607 +# - Monitoring -
  608 +
  609 +#compute_query_id = auto
  610 +#log_statement_stats = off
  611 +#log_parser_stats = off
  612 +#log_planner_stats = off
  613 +#log_executor_stats = off
  614 +
  615 +
  616 +#------------------------------------------------------------------------------
  617 +# AUTOVACUUM
  618 +#------------------------------------------------------------------------------
  619 +
  620 +#autovacuum = on # Enable autovacuum subprocess? 'on'
  621 + # requires track_counts to also be on.
  622 +#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
  623 + # (change requires restart)
  624 +#autovacuum_naptime = 1min # time between autovacuum runs
  625 +#autovacuum_vacuum_threshold = 50 # min number of row updates before
  626 + # vacuum
  627 +#autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts
  628 + # before vacuum; -1 disables insert
  629 + # vacuums
  630 +#autovacuum_analyze_threshold = 50 # min number of row updates before
  631 + # analyze
  632 +#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
  633 +#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table
  634 + # size before insert vacuum
  635 +#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
  636 +#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
  637 + # (change requires restart)
  638 +#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
  639 + # before forced vacuum
  640 + # (change requires restart)
  641 +#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for
  642 + # autovacuum, in milliseconds;
  643 + # -1 means use vacuum_cost_delay
  644 +#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
  645 + # autovacuum, -1 means use
  646 + # vacuum_cost_limit
  647 +
  648 +
  649 +#------------------------------------------------------------------------------
  650 +# CLIENT CONNECTION DEFAULTS
  651 +#------------------------------------------------------------------------------
  652 +
  653 +# - Statement Behavior -
  654 +
  655 +#client_min_messages = notice # values in order of decreasing detail:
  656 + # debug5
  657 + # debug4
  658 + # debug3
  659 + # debug2
  660 + # debug1
  661 + # log
  662 + # notice
  663 + # warning
  664 + # error
  665 +#search_path = '"$user", public' # schema names
  666 +#row_security = on
  667 +#default_table_access_method = 'heap'
  668 +#default_tablespace = '' # a tablespace name, '' uses the default
  669 +#default_toast_compression = 'pglz' # 'pglz' or 'lz4'
  670 +#temp_tablespaces = '' # a list of tablespace names, '' uses
  671 + # only default tablespace
  672 +#check_function_bodies = on
  673 +#default_transaction_isolation = 'read committed'
  674 +#default_transaction_read_only = off
  675 +#default_transaction_deferrable = off
  676 +#session_replication_role = 'origin'
  677 +#statement_timeout = 0 # in milliseconds, 0 is disabled
  678 +#lock_timeout = 0 # in milliseconds, 0 is disabled
  679 +#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
  680 +#idle_session_timeout = 0 # in milliseconds, 0 is disabled
  681 +#vacuum_freeze_table_age = 150000000
  682 +#vacuum_freeze_min_age = 50000000
  683 +#vacuum_failsafe_age = 1600000000
  684 +#vacuum_multixact_freeze_table_age = 150000000
  685 +#vacuum_multixact_freeze_min_age = 5000000
  686 +#vacuum_multixact_failsafe_age = 1600000000
  687 +#bytea_output = 'hex' # hex, escape
  688 +#xmlbinary = 'base64'
  689 +#xmloption = 'content'
  690 +#gin_pending_list_limit = 4MB
  691 +
  692 +# - Locale and Formatting -
  693 +
  694 +#datestyle = 'iso, mdy'
  695 +#intervalstyle = 'postgres'
  696 +#timezone = 'GMT'
  697 +#timezone_abbreviations = 'Default' # Select the set of available time zone
  698 + # abbreviations. Currently, there are
  699 + # Default
  700 + # Australia (historical usage)
  701 + # India
  702 + # You can create your own file in
  703 + # share/timezonesets/.
  704 +#extra_float_digits = 1 # min -15, max 3; any value >0 actually
  705 + # selects precise output mode
  706 +#client_encoding = sql_ascii # actually, defaults to database
  707 + # encoding
  708 +
  709 +# These settings are initialized by initdb, but they can be changed.
  710 +#lc_messages = 'C' # locale for system error message
  711 + # strings
  712 +#lc_monetary = 'C' # locale for monetary formatting
  713 +#lc_numeric = 'C' # locale for number formatting
  714 +#lc_time = 'C' # locale for time formatting
  715 +
  716 +# default configuration for text search
  717 +#default_text_search_config = 'pg_catalog.simple'
  718 +
  719 +# - Shared Library Preloading -
  720 +
  721 +#local_preload_libraries = ''
  722 +#session_preload_libraries = ''
  723 +#shared_preload_libraries = '' # (change requires restart)
  724 +#jit_provider = 'llvmjit' # JIT library to use
  725 +
  726 +# - Other Defaults -
  727 +
  728 +#dynamic_library_path = '$libdir'
  729 +#extension_destdir = '' # prepend path when loading extensions
  730 + # and shared objects (added by Debian)
  731 +#gin_fuzzy_search_limit = 0
  732 +
  733 +
  734 +#------------------------------------------------------------------------------
  735 +# LOCK MANAGEMENT
  736 +#------------------------------------------------------------------------------
  737 +
  738 +#deadlock_timeout = 1s
  739 +#max_locks_per_transaction = 64 # min 10
  740 + # (change requires restart)
  741 +#max_pred_locks_per_transaction = 64 # min 10
  742 + # (change requires restart)
  743 +#max_pred_locks_per_relation = -2 # negative values mean
  744 + # (max_pred_locks_per_transaction
  745 + # / -max_pred_locks_per_relation) - 1
  746 +#max_pred_locks_per_page = 2 # min 0
  747 +
  748 +
  749 +#------------------------------------------------------------------------------
  750 +# VERSION AND PLATFORM COMPATIBILITY
  751 +#------------------------------------------------------------------------------
  752 +
  753 +# - Previous PostgreSQL Versions -
  754 +
  755 +#array_nulls = on
  756 +#backslash_quote = safe_encoding # on, off, or safe_encoding
  757 +#escape_string_warning = on
  758 +#lo_compat_privileges = off
  759 +#quote_all_identifiers = off
  760 +#standard_conforming_strings = on
  761 +#synchronize_seqscans = on
  762 +
  763 +# - Other Platforms and Clients -
  764 +
  765 +#transform_null_equals = off
  766 +
  767 +
  768 +#------------------------------------------------------------------------------
  769 +# ERROR HANDLING
  770 +#------------------------------------------------------------------------------
  771 +
  772 +#exit_on_error = off # terminate session on any error?
  773 +#restart_after_crash = on # reinitialize after backend crash?
  774 +#data_sync_retry = off # retry or panic on failure to fsync
  775 + # data?
  776 + # (change requires restart)
  777 +#recovery_init_sync_method = fsync # fsync, syncfs (Linux 5.8+)
  778 +
  779 +
  780 +#------------------------------------------------------------------------------
  781 +# CONFIG FILE INCLUDES
  782 +#------------------------------------------------------------------------------
  783 +
  784 +# These options allow settings to be loaded from files other than the
  785 +# default postgresql.conf. Note that these are directives, not variable
  786 +# assignments, so they can usefully be given more than once.
  787 +
  788 +#include_dir = '...' # include files ending in '.conf' from
  789 + # a directory, e.g., 'conf.d'
  790 +#include_if_exists = '...' # include file only if it exists
  791 +#include = '...' # include file
  792 +
  793 +
  794 +#------------------------------------------------------------------------------
  795 +# CUSTOMIZED OPTIONS
  796 +#------------------------------------------------------------------------------
  797 +
  798 +# Add settings for extensions here
... ...