mirror of
https://github.com/wassname/docker-postgresql.git
synced 2026-06-27 22:22:10 +08:00
PSQL_MODE config parameter renamed to REPLICATION_MODE
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
**latest**
|
||||
- complete rewrite
|
||||
- `PSQL_TRUST_LOCALNET` config parameter renamed to `PG_TRUST_LOCALNET`
|
||||
- `PSQL_MODE` config parameter renamed to `REPLICATION_MODE`
|
||||
|
||||
**9.4-2**
|
||||
- added replication options
|
||||
|
||||
@@ -168,15 +168,15 @@ host all all samenet trust
|
||||
|
||||
# Creating a Snapshot or Slave Database
|
||||
|
||||
You may use the `PSQL_MODE` variable along with `REPLICATION_HOST`, `REPLICATION_PORT`, `REPLICATION_USER` and `REPLICATION_PASS` to create a snapshot of an existing database and enable stream replication.
|
||||
You may use the `REPLICATION_MODE` variable along with `REPLICATION_HOST`, `REPLICATION_PORT`, `REPLICATION_USER` and `REPLICATION_PASS` to create a snapshot of an existing database and enable stream replication.
|
||||
|
||||
Your master database must support replication or super-user access for the credentials you specify. The `PSQL_MODE` variable should be set to `master`, for replication on your master node and `slave` or `snapshot` respectively for streaming replication or a point-in-time snapshot of a running instance.
|
||||
Your master database must support replication or super-user access for the credentials you specify. The `REPLICATION_MODE` variable should be set to `master`, for replication on your master node and `slave` or `snapshot` respectively for streaming replication or a point-in-time snapshot of a running instance.
|
||||
|
||||
Create a master instance
|
||||
|
||||
```bash
|
||||
docker run --name='psql-master' -it --rm \
|
||||
-e 'PSQL_MODE=master' -e 'PG_TRUST_LOCALNET=true' \
|
||||
-e 'REPLICATION_MODE=master' -e 'PG_TRUST_LOCALNET=true' \
|
||||
-e 'REPLICATION_USER=replicator' -e 'REPLICATION_PASS=replicatorpass' \
|
||||
-e 'DB_NAME=dbname' -e 'DB_USER=dbuser' -e 'DB_PASS=dbpass' \
|
||||
sameersbn/postgresql:9.4-8
|
||||
@@ -187,7 +187,7 @@ Create a streaming replication instance
|
||||
```bash
|
||||
docker run --name='psql-slave' -it --rm \
|
||||
--link psql-master:psql-master \
|
||||
-e 'PSQL_MODE=slave' -e 'PG_TRUST_LOCALNET=true' \
|
||||
-e 'REPLICATION_MODE=slave' -e 'PG_TRUST_LOCALNET=true' \
|
||||
-e 'REPLICATION_HOST=psql-master' -e 'REPLICATION_PORT=5432' \
|
||||
-e 'REPLICATION_USER=replicator' -e 'REPLICATION_PASS=replicatorpass' \
|
||||
sameersbn/postgresql:9.4-8
|
||||
|
||||
+7
-6
@@ -1,12 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
PSQL_MODE=${PSQL_MODE:-}
|
||||
PSQL_SSLMODE=${PSQL_SSLMODE:-}
|
||||
|
||||
PG_TRUST_LOCALNET=${PG_TRUST_LOCALNET:-$PSQL_TRUST_LOCALNET} # backward compatibility
|
||||
PG_TRUST_LOCALNET=${PG_TRUST_LOCALNET:-false}
|
||||
|
||||
REPLICATION_MODE=${REPLICATION_MODE:-$PSQL_MODE} # backward compatibility
|
||||
REPLICATION_MODE=${REPLICATION_MODE:-}
|
||||
REPLICATION_USER=${REPLICATION_USER:-}
|
||||
REPLICATION_PASS=${REPLICATION_PASS:-}
|
||||
REPLICATION_HOST=${REPLICATION_HOST:-}
|
||||
@@ -105,7 +106,7 @@ set_hba_param() {
|
||||
}
|
||||
|
||||
configure_hot_standby() {
|
||||
case ${PSQL_MODE} in
|
||||
case ${REPLICATION_MODE} in
|
||||
slave|snapshot) ;;
|
||||
*)
|
||||
echo "Configuring hot standby..."
|
||||
@@ -120,7 +121,7 @@ configure_hot_standby() {
|
||||
|
||||
initialize_database() {
|
||||
if [[ ! -f ${PG_DATADIR}/PG_VERSION ]]; then
|
||||
case ${PSQL_MODE} in
|
||||
case ${REPLICATION_MODE} in
|
||||
slave|snapshot)
|
||||
# default params
|
||||
REPLICATION_PORT=${REPLICATION_PORT:-5432}
|
||||
@@ -155,7 +156,7 @@ initialize_database() {
|
||||
done
|
||||
echo
|
||||
|
||||
case ${PSQL_MODE} in
|
||||
case ${REPLICATION_MODE} in
|
||||
slave)
|
||||
echo "Replicating initial data from $REPLICATION_HOST..."
|
||||
exec_as_postgres PGPASSWORD=$REPLICATION_PASS ${PG_BINDIR}/pg_basebackup -D ${PG_DATADIR} \
|
||||
@@ -272,7 +273,7 @@ create_database() {
|
||||
}
|
||||
|
||||
create_replication_user() {
|
||||
case $PSQL_MODE in
|
||||
case $REPLICATION_MODE in
|
||||
slave|snapshot) ;; # replication user can only be created on the master
|
||||
*)
|
||||
if [[ -n ${REPLICATION_USER} ]]; then
|
||||
@@ -293,7 +294,7 @@ create_replication_user() {
|
||||
|
||||
configure_recovery() {
|
||||
if [[ ! -f ${PG_RECOVERY_CONF} ]]; then
|
||||
if [[ ${PSQL_MODE} == slave ]]; then
|
||||
if [[ ${REPLICATION_MODE} == slave ]]; then
|
||||
# initialize recovery.conf on the firstrun (slave only)
|
||||
echo "Configuring recovery..."
|
||||
exec_as_postgres touch ${PG_RECOVERY_CONF}
|
||||
|
||||
Reference in New Issue
Block a user