Skip to content

Commit 0d31498

Browse files
committed
clean up, fig based streaming replication examples.
1 parent 22ed93b commit 0d31498

11 files changed

+811
-36
lines changed

pgpool2/Dockerfile docker/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ ENV PG_REPL_USER docker
3737
ENV PG_REPL_PASS docker
3838
ENV PCP_USER docker
3939
ENV PCP_PASS docker
40-
ADD ./pgmgt.conf.php /var/www/conf/
41-
ADD ./pool_hba.conf /usr/local/etc/
42-
ADD setup.sh /var/www/
40+
ADD ./pgpool/pgmgt.conf.php /var/www/conf/
41+
ADD ./pgpool/pool_hba.conf /usr/local/etc/
42+
ADD ./pgpool/setup.sh /var/www/
4343
RUN sh ./setup.sh
4444

4545
# pgpool

pgpool2/init_sql.sh docker/init_sql.sh

+19-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ gosu postgres postgres --single template1 <<- EOSQL
66
CREATE EXTENSION pgpool_adm
77
EOSQL
88

9-
gosu postgres postgres --single -jE <<-EOSQL
10-
CREATE USER "$REPLICATION_USER" REPLICATION LOGIN ENCRYPTED PASSWORD $REPLICATION_PASSWORD;
11-
EOSQL
9+
cat > "$PGDATA"/pg_hba.conf <<EOS
10+
# TYPE DATABASE USER ADDRESS METHOD
11+
# "local" is for Unix domain socket connections only
12+
local all all trust
13+
# IPv4 local connections:
14+
host all all 127.0.0.1/32 trust
15+
# IPv6 local connections:
16+
host all all ::1/128 trust
17+
18+
# Allow anyone to connect remotely so long as they have a valid username and
19+
# password.
20+
host all all 0.0.0.0/0 md5
21+
EOS
1222

1323
# postgresql.conf
1424
{ echo; echo "wal_level = hot_standby"; } >> "$PGDATA"/postgresql.conf
@@ -19,15 +29,14 @@ EOSQL
1929
{ echo; echo "local replication postgres trust"; } >> "$PGDATA"/pg_hba.conf
2030
{ echo; echo "host replication \"$REPLICATION_USER\" 0.0.0.0/0 md5"; } >> "$PGDATA"/pg_hba.conf
2131

32+
gosu postgres postgres --single -jE <<-EOSQL
33+
CREATE USER "$REPLICATION_USER" REPLICATION LOGIN ENCRYPTED PASSWORD '$REPLICATION_PASSWORD';
34+
SELECT * FROM pg_create_physical_replication_slot('$REPLICATION_SLOT');
35+
EOSQL
36+
2237

2338

2439
# # Specifies a trigger file whose presence should cause streaming replication to
2540
# # end (i.e., failover).
2641
# trigger_file = '/tmp/pg_failover'
27-
#
28-
# # Specifies a command to load archive segments from the WAL archive. If
29-
# # wal_keep_segments is a high enough number to retain the WAL segments
30-
# # required for the standby server, this may not be necessary. But
31-
# # a large workload can cause segments to be recycled before the standby
32-
# # is fully synchronized, requiring you to start again from a new base backup.
33-
# #restore_command = 'cp /path_to/archive/%%f "%%p"'
42+
#

docker/pgpool/pcp.conf

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PCP Client Authentication Configuration File
2+
# ============================================
3+
#
4+
# This file contains user ID and his password for pgpool
5+
# communication manager authentication.
6+
#
7+
# Note that users defined here do not need to be PostgreSQL
8+
# users. These users are authorized ONLY for pgpool
9+
# communication manager.
10+
#
11+
# File Format
12+
# ===========
13+
#
14+
# List one UserID and password on a single line. They must
15+
# be concatenated together using ':' (colon) between them.
16+
# No spaces or tabs are allowed anywhere in the line.
17+
#
18+
# Example:
19+
# postgres:e8a48653851e28c69d0506508fb27fc5
20+
#
21+
# Be aware that there will be no spaces or tabs at the
22+
# beginning of the line! although the above example looks
23+
# like so.
24+
#
25+
# Lines beginning with '#' (pound) are comments and will
26+
# be ignored. Again, no spaces or tabs allowed before '#'.
27+
28+
# USERID:MD5PASSWD
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22
define('_PGPOOL2_LANG', 'en');
3+
define('_PGPOOL2_VERSION', '3.4');
34
define('_PGPOOL2_CONFIG_FILE', '/usr/local/etc/pgpool.conf');
45
define('_PGPOOL2_PASSWORD_FILE', '/usr/local/etc/pcp.conf');
56
define('_PGPOOL2_COMMAND', '/usr/local/bin/pgpool');
67
define('_PGPOOL2_CMD_OPTION_C', '0');
78
define('_PGPOOL2_CMD_OPTION_LARGE_D', '0');
89
define('_PGPOOL2_CMD_OPTION_D', '0');
9-
define('_PGPOOL2_CMD_OPTION_M', 'f');
10-
define('_PGPOOL2_CMD_OPTION_N', '1');
10+
define('_PGPOOL2_CMD_OPTION_M', 's');
11+
define('_PGPOOL2_CMD_OPTION_N', '0');
12+
define('_PGPOOL2_CMD_OPTION_LARGE_C', '0');
1113
define('_PGPOOL2_LOG_FILE', '/tmp/pgpool.log');
1214
define('_PGPOOL2_PCP_DIR', '/usr/local/bin');
1315
define('_PGPOOL2_PCP_HOSTNAME', 'localhost');
14-
define('_PGPOOL2_PCP_TIMEOUT', '10');
15-
define('_PGPOOL2_STATUS_REFRESH_TIME', '10');
16+
define('_PGPOOL2_STATUS_REFRESH_TIME', '0');
1617
?>

0 commit comments

Comments
 (0)