blob: e0fce11456f0c7432b43756d30026dd10700dfd1 [file] [log] [blame]
Adam Tenglerb5792ca2017-02-13 14:31:23 +01001{%- from "postgresql/map.jinja" import server, cluster with context -%}
Michael Kutý1769c112016-10-08 14:48:20 +02002# -----------------------------
3# PostgreSQL configuration file
4# -----------------------------
5#
6# This file consists of lines of the form:
7#
8# name = value
9#
10# (The "=" is optional.) Whitespace may be used. Comments are introduced with
11# "#" anywhere on a line. The complete list of parameter names and allowed
12# values can be found in the PostgreSQL documentation.
13#
14# The commented-out settings shown in this file represent the default values.
15# Re-commenting a setting is NOT sufficient to revert it to the default value;
16# you need to reload the server.
17#
18# This file is read on server startup and when the server receives a SIGHUP
19# signal. If you edit the file on a running system, you have to SIGHUP the
20# server for the changes to take effect, or use "pg_ctl reload". Some
21# parameters, which are marked below, require a server shutdown and restart to
22# take effect.
23#
24# Any parameter can also be given as a command-line option to the server, e.g.,
25# "postgres -c log_connections=on". Some parameters can be changed at run time
26# with the "SET" SQL command.
27#
28# Memory units: kB = kilobytes Time units: 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
Adam Tenglerb5792ca2017-02-13 14:31:23 +010042data_directory = '{{ server.dir.data }}' # use data in another directory
Michael Kutý1769c112016-10-08 14:48:20 +020043 # (change requires restart)
44hba_file = '/etc/postgresql/9.6/main/pg_hba.conf' # host-based authentication file
45 # (change requires restart)
46ident_file = '/etc/postgresql/9.6/main/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.
50external_pid_file = '/var/run/postgresql/9.6-main.pid' # write an extra PID file
51 # (change requires restart)
52
53
54#------------------------------------------------------------------------------
55# CONNECTIONS AND AUTHENTICATION
56#------------------------------------------------------------------------------
57
58# - Connection Settings -
59{%- if server.bind.address == '0.0.0.0' %}
60listen_addresses = '*'
61{%- else %}
Adam Tenglerb5792ca2017-02-13 14:31:23 +010062listen_addresses = 'localhost{% if server.bind.address != "127.0.0.1" %}, {{ server.bind.address }}'{% endif %}
Michael Kutý1769c112016-10-08 14:48:20 +020063{%- endif %}
64port = {{ server.bind.get('port', '5432') }}
65
66#listen_addresses = 'localhost' # what IP address(es) to listen on;
67 # comma-separated list of addresses;
68 # defaults to 'localhost'; use '*' for all
69 # (change requires restart)
70#port = 5433 # (change requires restart)
71max_connections = 100 # (change requires restart)
72#superuser_reserved_connections = 3 # (change requires restart)
73unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
74 # (change requires restart)
75#unix_socket_group = '' # (change requires restart)
76#unix_socket_permissions = 0777 # begin with 0 to use octal notation
77 # (change requires restart)
78#bonjour = off # advertise server via Bonjour
79 # (change requires restart)
80#bonjour_name = '' # defaults to the computer name
81 # (change requires restart)
82
83# - Security and Authentication -
84
85#authentication_timeout = 1min # 1s-600s
86ssl = true # (change requires restart)
87#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
88 # (change requires restart)
89#ssl_prefer_server_ciphers = on # (change requires restart)
90#ssl_ecdh_curve = 'prime256v1' # (change requires restart)
91ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart)
92ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart)
93#ssl_ca_file = '' # (change requires restart)
94#ssl_crl_file = '' # (change requires restart)
95#password_encryption = on
96#db_user_namespace = off
97#row_security = on
98
99# GSSAPI using Kerberos
100#krb_server_keyfile = ''
101#krb_caseins_users = off
102
103# - TCP Keepalives -
104# see "man 7 tcp" for details
105
106#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
107 # 0 selects the system default
108#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
109 # 0 selects the system default
110#tcp_keepalives_count = 0 # TCP_KEEPCNT;
111 # 0 selects the system default
112
113
114#------------------------------------------------------------------------------
115# RESOURCE USAGE (except WAL)
116#------------------------------------------------------------------------------
117
118# - Memory -
119
120shared_buffers = 128MB # min 128kB
121 # (change requires restart)
122#huge_pages = try # on, off, or try
123 # (change requires restart)
124#temp_buffers = 8MB # min 800kB
125#max_prepared_transactions = 0 # zero disables the feature
126 # (change requires restart)
127# Caution: it is not advisable to set max_prepared_transactions nonzero unless
128# you actively intend to use prepared transactions.
129#work_mem = 4MB # min 64kB
130#maintenance_work_mem = 64MB # min 1MB
131#replacement_sort_tuples = 150000 # limits use of replacement selection sort
132#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
133#max_stack_depth = 2MB # min 100kB
134dynamic_shared_memory_type = posix # the default is the first option
135 # supported by the operating system:
136 # posix
137 # sysv
138 # windows
139 # mmap
140 # use none to disable dynamic shared memory
141
142# - Disk -
143
144#temp_file_limit = -1 # limits per-process temp file space
145 # in kB, or -1 for no limit
146
147# - Kernel Resource Usage -
148
149#max_files_per_process = 1000 # min 25
150 # (change requires restart)
151#shared_preload_libraries = '' # (change requires restart)
152
153# - Cost-Based Vacuum Delay -
154
155#vacuum_cost_delay = 0 # 0-100 milliseconds
156#vacuum_cost_page_hit = 1 # 0-10000 credits
157#vacuum_cost_page_miss = 10 # 0-10000 credits
158#vacuum_cost_page_dirty = 20 # 0-10000 credits
159#vacuum_cost_limit = 200 # 1-10000 credits
160
161# - Background Writer -
162
163#bgwriter_delay = 200ms # 10-10000ms between rounds
164#bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round
165#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
166#bgwriter_flush_after = 0 # 0 disables,
167 # default is 512kB on linux, 0 otherwise
168
169# - Asynchronous Behavior -
170
171#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching
172#max_worker_processes = 8 # (change requires restart)
173#max_parallel_workers_per_gather = 0 # taken from max_worker_processes
174#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate
175 # (change requires restart)
176#backend_flush_after = 0 # 0 disables, default is 0
177
178
179#------------------------------------------------------------------------------
180# WRITE AHEAD LOG
181#------------------------------------------------------------------------------
182
183# - Settings -
184
185#wal_level = minimal # minimal, replica, or logical
186 # (change requires restart)
187#fsync = on # flush data to disk for crash safety
188 # (turning this off can cause
189 # unrecoverable data corruption)
190#synchronous_commit = on # synchronization level;
191 # off, local, remote_write, remote_apply, or on
192#wal_sync_method = fsync # the default is the first option
193 # supported by the operating system:
194 # open_datasync
195 # fdatasync (default on Linux)
196 # fsync
197 # fsync_writethrough
198 # open_sync
199#full_page_writes = on # recover from partial page writes
200#wal_compression = off # enable compression of full-page writes
201#wal_log_hints = off # also do full page writes of non-critical updates
202 # (change requires restart)
203#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
204 # (change requires restart)
205#wal_writer_delay = 200ms # 1-10000 milliseconds
206#wal_writer_flush_after = 1MB # 0 disables
207
208#commit_delay = 0 # range 0-100000, in microseconds
209#commit_siblings = 5 # range 1-1000
210
211# - Checkpoints -
212
213#checkpoint_timeout = 5min # range 30s-1d
214#max_wal_size = 1GB
215#min_wal_size = 80MB
216#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0
217#checkpoint_flush_after = 0 # 0 disables,
218 # default is 256kB on linux, 0 otherwise
219#checkpoint_warning = 30s # 0 disables
220
221# - Archiving -
222
223#archive_mode = off # enables archiving; off, on, or always
224 # (change requires restart)
225#archive_command = '' # command to use to archive a logfile segment
226 # placeholders: %p = path of file to archive
227 # %f = file name only
228 # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
229#archive_timeout = 0 # force a logfile segment switch after this
230 # number of seconds; 0 disables
231
232
233#------------------------------------------------------------------------------
234# REPLICATION
235#------------------------------------------------------------------------------
236
237# - Sending Server(s) -
238
Adam Tenglerb5792ca2017-02-13 14:31:23 +0100239{%- if cluster.enabled and cluster.get("mode") == "hot_standby" and cluster.role != "master" %}
240hot_standby = on
241{%- endif %}
242
243{%- if cluster.enabled and cluster.get("mode") == "hot_standby" and cluster.role == "master" %}
244
245wal_level = hot_standby
246archive_mode = {{ cluster.archive }}
247
248max_wal_senders = {{ cluster.members|length + 1 }}
249max_replication_slots = {{ cluster.members|length + 1 }}
250
251{%- if cluster.synchronous %}
252synchronous_standby_names = '*'
253{%- endif %}
254{%- endif %}
255
Michael Kutý1769c112016-10-08 14:48:20 +0200256# Set these on the master and on any standby that will send replication data.
257
258#max_wal_senders = 0 # max number of walsender processes
259 # (change requires restart)
260#wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables
261#wal_sender_timeout = 60s # in milliseconds; 0 disables
262
263#max_replication_slots = 0 # max number of replication slots
264 # (change requires restart)
265#track_commit_timestamp = off # collect timestamp of transaction commit
266 # (change requires restart)
267
268# - Master Server -
269
270# These settings are ignored on a standby server.
271
272#synchronous_standby_names = '' # standby servers that provide sync rep
273 # number of sync standbys and comma-separated list of application_name
274 # from standby(s); '*' = all
275#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
276
277# - Standby Servers -
278
279# These settings are ignored on a master server.
280
281#hot_standby = off # "on" allows queries during recovery
282 # (change requires restart)
283#max_standby_archive_delay = 30s # max delay before canceling queries
284 # when reading WAL from archive;
285 # -1 allows indefinite delay
286#max_standby_streaming_delay = 30s # max delay before canceling queries
287 # when reading streaming WAL;
288 # -1 allows indefinite delay
289#wal_receiver_status_interval = 10s # send replies at least this often
290 # 0 disables
291#hot_standby_feedback = off # send info from standby to prevent
292 # query conflicts
293#wal_receiver_timeout = 60s # time that receiver waits for
294 # communication from master
295 # in milliseconds; 0 disables
296#wal_retrieve_retry_interval = 5s # time to wait before retrying to
297 # retrieve WAL after a failed attempt
298
299
300#------------------------------------------------------------------------------
301# QUERY TUNING
302#------------------------------------------------------------------------------
303
304# - Planner Method Configuration -
305
306#enable_bitmapscan = on
307#enable_hashagg = on
308#enable_hashjoin = on
309#enable_indexscan = on
310#enable_indexonlyscan = on
311#enable_material = on
312#enable_mergejoin = on
313#enable_nestloop = on
314#enable_seqscan = on
315#enable_sort = on
316#enable_tidscan = on
317
318# - Planner Cost Constants -
319
320#seq_page_cost = 1.0 # measured on an arbitrary scale
321#random_page_cost = 4.0 # same scale as above
322#cpu_tuple_cost = 0.01 # same scale as above
323#cpu_index_tuple_cost = 0.005 # same scale as above
324#cpu_operator_cost = 0.0025 # same scale as above
325#parallel_tuple_cost = 0.1 # same scale as above
326#parallel_setup_cost = 1000.0 # same scale as above
327#min_parallel_relation_size = 8MB
328#effective_cache_size = 4GB
329
330# - Genetic Query Optimizer -
331
332#geqo = on
333#geqo_threshold = 12
334#geqo_effort = 5 # range 1-10
335#geqo_pool_size = 0 # selects default based on effort
336#geqo_generations = 0 # selects default based on effort
337#geqo_selection_bias = 2.0 # range 1.5-2.0
338#geqo_seed = 0.0 # range 0.0-1.0
339
340# - Other Planner Options -
341
342#default_statistics_target = 100 # range 1-10000
343#constraint_exclusion = partition # on, off, or partition
344#cursor_tuple_fraction = 0.1 # range 0.0-1.0
345#from_collapse_limit = 8
346#join_collapse_limit = 8 # 1 disables collapsing of explicit
347 # JOIN clauses
348#force_parallel_mode = off
349
350
351#------------------------------------------------------------------------------
352# ERROR REPORTING AND LOGGING
353#------------------------------------------------------------------------------
354
355# - Where to Log -
356
357#log_destination = 'stderr' # Valid values are combinations of
358 # stderr, csvlog, syslog, and eventlog,
359 # depending on platform. csvlog
360 # requires logging_collector to be on.
361
362# This is used when logging to stderr:
363#logging_collector = off # Enable capturing of stderr and csvlog
364 # into log files. Required to be on for
365 # csvlogs.
366 # (change requires restart)
367
368# These are only used if logging_collector is on:
369#log_directory = 'pg_log' # directory where log files are written,
370 # can be absolute or relative to PGDATA
371#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
372 # can include strftime() escapes
373#log_file_mode = 0600 # creation mode for log files,
374 # begin with 0 to use octal notation
375#log_truncate_on_rotation = off # If on, an existing log file with the
376 # same name as the new log file will be
377 # truncated rather than appended to.
378 # But such truncation only occurs on
379 # time-driven rotation, not on restarts
380 # or size-driven rotation. Default is
381 # off, meaning append to existing files
382 # in all cases.
383#log_rotation_age = 1d # Automatic rotation of logfiles will
384 # happen after that time. 0 disables.
385#log_rotation_size = 10MB # Automatic rotation of logfiles will
386 # happen after that much log output.
387 # 0 disables.
388
389# These are relevant when logging to syslog:
390#syslog_facility = 'LOCAL0'
391#syslog_ident = 'postgres'
392#syslog_sequence_numbers = on
393#syslog_split_messages = on
394
395# This is only relevant when logging to eventlog (win32):
396#event_source = 'PostgreSQL'
397
398# - When to Log -
399
400#client_min_messages = notice # values in order of decreasing detail:
401 # debug5
402 # debug4
403 # debug3
404 # debug2
405 # debug1
406 # log
407 # notice
408 # warning
409 # error
410
411#log_min_messages = warning # values in order of decreasing detail:
412 # debug5
413 # debug4
414 # debug3
415 # debug2
416 # debug1
417 # info
418 # notice
419 # warning
420 # error
421 # log
422 # fatal
423 # panic
424
425#log_min_error_statement = error # values in order of decreasing detail:
426 # debug5
427 # debug4
428 # debug3
429 # debug2
430 # debug1
431 # info
432 # notice
433 # warning
434 # error
435 # log
436 # fatal
437 # panic (effectively off)
438
439#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
440 # and their durations, > 0 logs only
441 # statements running at least this number
442 # of milliseconds
443
444
445# - What to Log -
446
447#debug_print_parse = off
448#debug_print_rewritten = off
449#debug_print_plan = off
450#debug_pretty_print = on
451#log_checkpoints = off
452#log_connections = off
453#log_disconnections = off
454#log_duration = off
455#log_error_verbosity = default # terse, default, or verbose messages
456#log_hostname = off
457log_line_prefix = '%t [%p-%l] %q%u@%d ' # special values:
458 # %a = application name
459 # %u = user name
460 # %d = database name
461 # %r = remote host and port
462 # %h = remote host
463 # %p = process ID
464 # %t = timestamp without milliseconds
465 # %m = timestamp with milliseconds
466 # %n = timestamp with milliseconds (as a Unix epoch)
467 # %i = command tag
468 # %e = SQL state
469 # %c = session ID
470 # %l = session line number
471 # %s = session start timestamp
472 # %v = virtual transaction ID
473 # %x = transaction ID (0 if none)
474 # %q = stop here in non-session
475 # processes
476 # %% = '%'
477 # e.g. '<%u%%%d> '
478#log_lock_waits = off # log lock waits >= deadlock_timeout
479#log_statement = 'none' # none, ddl, mod, all
480#log_replication_commands = off
481#log_temp_files = -1 # log temporary files equal or larger
482 # than the specified size in kilobytes;
483 # -1 disables, 0 logs all temp files
484log_timezone = 'localtime'
485
486
487# - Process Title -
488
489#cluster_name = '' # added to process titles if nonempty
490 # (change requires restart)
491#update_process_title = on
492
493
494#------------------------------------------------------------------------------
495# RUNTIME STATISTICS
496#------------------------------------------------------------------------------
497
498# - Query/Index Statistics Collector -
499
500#track_activities = on
501#track_counts = on
502#track_io_timing = off
503#track_functions = none # none, pl, all
504#track_activity_query_size = 1024 # (change requires restart)
505stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp'
506
507
508# - Statistics Monitoring -
509
510#log_parser_stats = off
511#log_planner_stats = off
512#log_executor_stats = off
513#log_statement_stats = off
514
515
516#------------------------------------------------------------------------------
517# AUTOVACUUM PARAMETERS
518#------------------------------------------------------------------------------
519
520#autovacuum = on # Enable autovacuum subprocess? 'on'
521 # requires track_counts to also be on.
522#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and
523 # their durations, > 0 logs only
524 # actions running at least this number
525 # of milliseconds.
526#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
527 # (change requires restart)
528#autovacuum_naptime = 1min # time between autovacuum runs
529#autovacuum_vacuum_threshold = 50 # min number of row updates before
530 # vacuum
531#autovacuum_analyze_threshold = 50 # min number of row updates before
532 # analyze
533#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
534#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
535#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
536 # (change requires restart)
537#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
538 # before forced vacuum
539 # (change requires restart)
540#autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for
541 # autovacuum, in milliseconds;
542 # -1 means use vacuum_cost_delay
543#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
544 # autovacuum, -1 means use
545 # vacuum_cost_limit
546
547
548#------------------------------------------------------------------------------
549# CLIENT CONNECTION DEFAULTS
550#------------------------------------------------------------------------------
551
552# - Statement Behavior -
553
554#search_path = '"$user", public' # schema names
555#default_tablespace = '' # a tablespace name, '' uses the default
556#temp_tablespaces = '' # a list of tablespace names, '' uses
557 # only default tablespace
558#check_function_bodies = on
559#default_transaction_isolation = 'read committed'
560#default_transaction_read_only = off
561#default_transaction_deferrable = off
562#session_replication_role = 'origin'
563#statement_timeout = 0 # in milliseconds, 0 is disabled
564#lock_timeout = 0 # in milliseconds, 0 is disabled
565#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
566#vacuum_freeze_min_age = 50000000
567#vacuum_freeze_table_age = 150000000
568#vacuum_multixact_freeze_min_age = 5000000
569#vacuum_multixact_freeze_table_age = 150000000
570#bytea_output = 'hex' # hex, escape
571#xmlbinary = 'base64'
572#xmloption = 'content'
573#gin_fuzzy_search_limit = 0
574#gin_pending_list_limit = 4MB
575
576# - Locale and Formatting -
577
578datestyle = 'iso, mdy'
579#intervalstyle = 'postgres'
580timezone = 'localtime'
581#timezone_abbreviations = 'Default' # Select the set of available time zone
582 # abbreviations. Currently, there are
583 # Default
584 # Australia (historical usage)
585 # India
586 # You can create your own file in
587 # share/timezonesets/.
588#extra_float_digits = 0 # min -15, max 3
589#client_encoding = sql_ascii # actually, defaults to database
590 # encoding
591
592# These settings are initialized by initdb, but they can be changed.
593lc_messages = 'en_US.UTF-8' # locale for system error message
594 # strings
595lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
596lc_numeric = 'en_US.UTF-8' # locale for number formatting
597lc_time = 'en_US.UTF-8' # locale for time formatting
598
599# default configuration for text search
600default_text_search_config = 'pg_catalog.english'
601
602# - Other Defaults -
603
604#dynamic_library_path = '$libdir'
605#local_preload_libraries = ''
606#session_preload_libraries = ''
607
608
609#------------------------------------------------------------------------------
610# LOCK MANAGEMENT
611#------------------------------------------------------------------------------
612
613#deadlock_timeout = 1s
614#max_locks_per_transaction = 64 # min 10
615 # (change requires restart)
616#max_pred_locks_per_transaction = 64 # min 10
617 # (change requires restart)
618
619
620#------------------------------------------------------------------------------
621# VERSION/PLATFORM COMPATIBILITY
622#------------------------------------------------------------------------------
623
624# - Previous PostgreSQL Versions -
625
626#array_nulls = on
627#backslash_quote = safe_encoding # on, off, or safe_encoding
628#default_with_oids = off
629#escape_string_warning = on
630#lo_compat_privileges = off
631#operator_precedence_warning = off
632#quote_all_identifiers = off
633#sql_inheritance = on
634#standard_conforming_strings = on
635#synchronize_seqscans = on
636
637# - Other Platforms and Clients -
638
639#transform_null_equals = off
640
641
642#------------------------------------------------------------------------------
643# ERROR HANDLING
644#------------------------------------------------------------------------------
645
646#exit_on_error = off # terminate session on any error?
647#restart_after_crash = on # reinitialize after backend crash?
648
649
650#------------------------------------------------------------------------------
651# CONFIG FILE INCLUDES
652#------------------------------------------------------------------------------
653
654# These options allow settings to be loaded from files other than the
655# default postgresql.conf.
656
657#include_dir = 'conf.d' # include files ending in '.conf' from
658 # directory 'conf.d'
659#include_if_exists = 'exists.conf' # include file only if it exists
660#include = 'special.conf' # include file
661
662
663#------------------------------------------------------------------------------
664# CUSTOMIZED OPTIONS
665#------------------------------------------------------------------------------
666
667# Add settings for extensions here