enh
This commit is contained in:
parent
b1f671e716
commit
cfd87a4b7c
3 changed files with 74 additions and 0 deletions
22
master_side/init-replication.sh
Executable file
22
master_side/init-replication.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Creating replication role..."
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
||||||
|
DO \$\$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM pg_roles WHERE rolname = 'replicator'
|
||||||
|
) THEN
|
||||||
|
CREATE ROLE replicator
|
||||||
|
WITH REPLICATION
|
||||||
|
LOGIN
|
||||||
|
PASSWORD 'replicator_password';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
\$\$;
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
echo "Replication role ready."
|
||||||
|
|
||||||
17
master_side/pg_hba.conf
Normal file
17
master_side/pg_hba.conf
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# TYPE DATABASE USER ADDRESS METHOD
|
||||||
|
|
||||||
|
# Local connections
|
||||||
|
local all all trust
|
||||||
|
|
||||||
|
# IPv4 local connections
|
||||||
|
host all all 127.0.0.1/32 trust
|
||||||
|
|
||||||
|
# IPv6 local connections
|
||||||
|
host all all ::1/128 trust
|
||||||
|
|
||||||
|
# Allow replication user from primary
|
||||||
|
host replication replicator 0.0.0.0/0 md5
|
||||||
|
|
||||||
|
host mytestdb postgres 0.0.0.0/0 md5
|
||||||
|
|
||||||
|
|
||||||
35
master_side/postgresql.conf
Normal file
35
master_side/postgresql.conf
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# -----------------------------
|
||||||
|
# BASIC
|
||||||
|
# -----------------------------
|
||||||
|
listen_addresses = '*'
|
||||||
|
port = 5432
|
||||||
|
max_connections = 100
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# REPLICATION
|
||||||
|
# -----------------------------
|
||||||
|
wal_level = replica
|
||||||
|
hot_standby = on
|
||||||
|
max_wal_senders = 10
|
||||||
|
max_replication_slots = 10
|
||||||
|
wal_keep_size = 256MB
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# REPLICA READ SAFETY
|
||||||
|
# -----------------------------
|
||||||
|
hot_standby_feedback = on
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# LOGGING (optional but useful)
|
||||||
|
# -----------------------------
|
||||||
|
logging_collector = on
|
||||||
|
log_destination = 'stderr'
|
||||||
|
log_directory = 'log'
|
||||||
|
log_filename = 'postgresql-%Y-%m-%d.log'
|
||||||
|
log_statement = 'none'
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# FILE LOCATIONS (IMPORTANT)
|
||||||
|
# -----------------------------
|
||||||
|
hba_file = '/etc/postgresql/pg_hba.conf'
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue