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