1. General information
Master Node
IP: 192.168.56.111
Hostname: postgres-master
Version: postgres (PostgreSQL) 16.4
$PGDATA=/var/lib/pgsql/16/data
postgres=# \db
List of tablespaces
Name | Owner | Location
------------+----------+------------------------------------
dvd_data | tucdt | /var/lib/pgsql/dvdrental_tbs/data
dvd_index | tucdt | /var/lib/pgsql/dvdrental_tbs/index
pg_default | postgres |
pg_global | postgres |
(4 rows)
Slave Node
IP: 192.168.56.222
Version: postgres (PostgreSQL) 16.4
$PGDATA=/var/lib/pgsql/16/data // empty
2. Preparation on Master/Slave
- Disable Selinux : SELINUX=disabled
- Stop Firewall
- Config /etc/hosts
- 192.168.56.111 postgres-master.taolaoxibup.com postgres-master
- 192.168.56.222 postgres-slave.taolaoxibup.com postgres-slave
- Setup SSH KEY-PAIR
- ssh-keygen -t rsa
- ssh-copy-id -i ~/.ssh/id_rsa.pub postgres@192.168.56.[111/222]
3. Master - Configuration
3.1 Create user for replication
postgres=# CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'P@ssw0rd';