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