kopia lustrzana https://github.com/kartoza/docker-postgis
Add support for WAL level and archiving configuration (#200)
* Add wal, archive and recover configuration through environment variables. * Update readme to reflect new environment variables.pull/206/head
rodzic
38fcd9730e
commit
760fdf7758
63
README.md
63
README.md
|
@ -91,45 +91,66 @@ docker run --name "postgis" -p 25432:5432 -d -t kartoza/postgis
|
|||
|
||||
## Environment variables
|
||||
|
||||
You can also use the following environment variables to pass a
|
||||
#### Basic configuration
|
||||
|
||||
You can use the following environment variables to pass a
|
||||
user name, password and/or default database name(or multiple databases comma separated).
|
||||
|
||||
* -e POSTGRES_USER=<PGUSER>
|
||||
* -e POSTGRES_PASS=<PGPASSWORD>
|
||||
* -e POSTGRES_DBNAME=<PGDBNAME>
|
||||
* -e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology
|
||||
* `-e POSTGRES_USER=<PGUSER>`
|
||||
* `-e POSTGRES_PASS=<PGPASSWORD>`
|
||||
* `-e POSTGRES_DBNAME=<PGDBNAME>`
|
||||
* `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology`
|
||||
|
||||
You can pass as many extensions as you need.
|
||||
* -e SSL_CERT_FILE=/your/own/ssl_cert_file.pem
|
||||
* -e SSL_KEY_FILE=/your/own/ssl_key_file.key
|
||||
* -e SSL_CA_FILE=/your/own/ssl_ca_file.pem
|
||||
* -e DEFAULT_ENCODING="UTF8"
|
||||
* -e DEFAULT_COLLATION="en_US.UTF-8"
|
||||
* -e DEFAULT_CTYPE="en_US.UTF-8"
|
||||
* `-e SSL_CERT_FILE=/your/own/ssl_cert_file.pem`
|
||||
* `-e SSL_KEY_FILE=/your/own/ssl_key_file.key`
|
||||
* `-e SSL_CA_FILE=/your/own/ssl_ca_file.pem`
|
||||
* `-e DEFAULT_ENCODING="UTF8"`
|
||||
* `-e DEFAULT_COLLATION="en_US.UTF-8"`
|
||||
* `-e DEFAULT_CTYPE="en_US.UTF-8"`
|
||||
|
||||
Specifies whether extensions will also be installed in template1 database.
|
||||
* -e POSTGRES_TEMPLATE_EXTENSIONS=true
|
||||
#### Specifies whether extensions will also be installed in template1 database.
|
||||
* `-e POSTGRES_TEMPLATE_EXTENSIONS=true`
|
||||
|
||||
#### Configures archive mode
|
||||
|
||||
This image uses the initial PostgreSQL values which disables the archiving option by default.
|
||||
When `ARCHIVE_MODE` is changed to `on`, the archiving command will copy WAL files to `/opt/archivedir`
|
||||
|
||||
[More info: 19.5. Write Ahead Log](https://www.postgresql.org/docs/12/runtime-config-wal.html)
|
||||
|
||||
* `-e ARCHIVE_MODE off`
|
||||
* `-e ARCHIVE_COMMAND "test ! -f /opt/archivedir/%f && cp %p /opt/archivedir/%f"`
|
||||
[More info](https://www.postgresql.org/docs/12/continuous-archiving.html#BACKUP-ARCHIVING-WAL)
|
||||
* `-e ARCHIVE_CLEANUP_COMMAND 'cp /opt/archivedir/%f "%p"'`
|
||||
* `-e RESTORE_COMMAND 'pg_archivecleanup /opt/archivedir %r'`
|
||||
|
||||
#### Configure WAL level
|
||||
* `-e WAL_LEVEL=replica`
|
||||
[More info](https://www.postgresql.org/docs/12/runtime-config-wal.html)
|
||||
|
||||
Maximum size to let the WAL grow to between automatic WAL checkpoints.
|
||||
* -e WAL_SIZE=4GB
|
||||
|
||||
* -e MIN_WAL_SIZE=2048MB
|
||||
* -e WAL_SEGSIZE=1024
|
||||
* -e MAINTAINANCE_WORK_MEM=128MB
|
||||
* `-e WAL_SIZE=4GB`
|
||||
* `-e MIN_WAL_SIZE=2048MB`
|
||||
* `-e WAL_SEGSIZE=1024`
|
||||
* `-e MAINTAINANCE_WORK_MEM=128MB`
|
||||
|
||||
#### Configure networking
|
||||
You can open up the PG port by using the following environment variable. By default
|
||||
the container will allow connections only from the docker private subnet.
|
||||
|
||||
* -e ALLOW_IP_RANGE=<0.0.0.0/0> By default
|
||||
* `-e ALLOW_IP_RANGE=<0.0.0.0/0> By default`
|
||||
|
||||
Postgres conf is setup to listen to all connections and if a user needs to restrict which IP address
|
||||
PostgreSQL listens to you can define it with the following environment variable. The default is set to listen to
|
||||
all connections.
|
||||
* -e IP_LIST=<*>
|
||||
* `-e IP_LIST=<*>`
|
||||
|
||||
#### Additional configuration
|
||||
|
||||
You can also define any other configuration to add to `postgres.conf`, separated by '\n' e.g.:
|
||||
|
||||
* -e EXTRA_CONF="log_destination = 'stderr'\nlogging_collector = on"
|
||||
* `-e EXTRA_CONF="log_destination = 'stderr'\nlogging_collector = on"`
|
||||
|
||||
|
||||
## Docker secrets
|
||||
|
|
26
env-data.sh
26
env-data.sh
|
@ -88,6 +88,31 @@ if [ -z "${MAINTAINANCE_WORKERS}" ]; then
|
|||
MAINTAINANCE_WORKERS=2
|
||||
fi
|
||||
|
||||
if [ -z "${ARCHIVE_MODE}" ]; then
|
||||
# https://www.postgresql.org/docs/12/runtime-config-wal.html
|
||||
ARCHIVE_MODE=off
|
||||
fi
|
||||
|
||||
if [ -z "${ARCHIVE_COMMAND}" ]; then
|
||||
# https://www.postgresql.org/docs/12/continuous-archiving.html#BACKUP-ARCHIVING-WAL
|
||||
ARCHIVE_COMMAND="test ! -f ${WAL_ARCHIVE}/%f && cp %p ${WAL_ARCHIVE}/%f"
|
||||
fi
|
||||
|
||||
if [ -z "${RESTORE_COMMAND}" ]; then
|
||||
# https://www.postgresql.org/docs/12/runtime-config-wal.html
|
||||
RESTORE_COMMAND="cp ${WAL_ARCHIVE}/%f \"%p\""
|
||||
fi
|
||||
|
||||
if [ -z "${ARCHIVE_CLEANUP_COMMAND}" ]; then
|
||||
# https://www.postgresql.org/docs/12/runtime-config-wal.html
|
||||
ARCHIVE_CLEANUP_COMMAND="pg_archivecleanup ${WAL_ARCHIVE} %r"
|
||||
fi
|
||||
|
||||
if [ -z "${WAL_LEVEL}" ]; then
|
||||
# https://www.postgresql.org/docs/12/runtime-config-wal.html
|
||||
WAL_LEVEL=replica
|
||||
fi
|
||||
|
||||
if [ -z "${WAL_SIZE}" ]; then
|
||||
WAL_SIZE=4GB
|
||||
fi
|
||||
|
@ -100,7 +125,6 @@ if [ -z "${WAL_SEGSIZE}" ]; then
|
|||
WAL_SEGSIZE=1024
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${CHECK_POINT_TIMEOUT}" ]; then
|
||||
CHECK_POINT_TIMEOUT=30min
|
||||
fi
|
||||
|
|
|
@ -17,12 +17,16 @@ cat $CONF.template > $CONF
|
|||
|
||||
# This script will setup necessary configuration to optimise for PostGIS and to enable replications
|
||||
cat >> $CONF <<EOF
|
||||
wal_level = hot_standby
|
||||
archive_mode = ${ARCHIVE_MODE}
|
||||
archive_command = '${ARCHIVE_COMMAND}'
|
||||
restore_command = '${RESTORE_COMMAND}'
|
||||
archive_cleanup_command = '${ARCHIVE_CLEANUP_COMMAND}'
|
||||
wal_level = ${WAL_LEVEL}
|
||||
max_wal_senders = ${PG_MAX_WAL_SENDERS}
|
||||
wal_keep_segments = ${PG_WAL_KEEP_SEGMENTS}
|
||||
superuser_reserved_connections= 10
|
||||
min_wal_size =${MIN_WAL_SIZE}
|
||||
max_wal_size= ${WAL_SIZE}
|
||||
min_wal_size = ${MIN_WAL_SIZE}
|
||||
max_wal_size = ${WAL_SIZE}
|
||||
wal_keep_segments= 64
|
||||
hot_standby = on
|
||||
listen_addresses = '${IP_LIST}'
|
||||
|
|
Ładowanie…
Reference in New Issue