This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| postgresql:replication [2015-10-22] – dcai | postgresql:replication [2020-04-19] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== PostgreSQL replication 9.3+ ====== | ||
| + | |||
| + | === On master node === | ||
| + | Install postgresql-9.3-pgpool2 | ||
| + | <file bash create_role.bash> | ||
| + | sudo -u postgres psql -c " | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | create extension pgpool_regclass; | ||
| + | CREATE EXTENSION pgpool_recovery; | ||
| + | \df | ||
| + | </ | ||
| + | |||
| + | <file - postgresql.conf> | ||
| + | listen_address = " | ||
| + | wal_level = hot_standby | ||
| + | max_wal_senders = 3 | ||
| + | checkpoint_segments = 8 | ||
| + | wal_keep_segments = 8 | ||
| + | </ | ||
| + | |||
| + | |||
| + | <file - pg_hba.conf> | ||
| + | hostssl replication | ||
| + | # line below is for pgpool2 | ||
| + | host all all 192.168.3.1/ | ||
| + | </ | ||
| + | === On slave node === | ||
| + | |||
| + | |||
| + | < | ||
| + | wal_level = hot_standby | ||
| + | max_wal_senders = 3 | ||
| + | checkpoint_segments = 8 | ||
| + | wal_keep_segments = 8 | ||
| + | hot_standby = on | ||
| + | </ | ||
| + | |||
| + | |||
| + | <file bash> | ||
| + | sudo service postgresql stop | ||
| + | sudo -u postgres rm -rf / | ||
| + | sudo -u postgres pg_basebackup -h 192.168.3.11 -D / | ||
| + | ## Writing recovery.conf file | ||
| + | sudo -u postgres bash -c "cat > / | ||
| + | standby_mode = ' | ||
| + | primary_conninfo = ' | ||
| + | trigger_file = '/ | ||
| + | _EOF1_ | ||
| + | " | ||
| + | sudo service postgresql start | ||
| + | </ | ||
| + | |||
| + | |||
| + | === pgpool II === | ||
| + | install pgpool2 package | ||