Table of Contents | ||||
---|---|---|---|---|
|
Create primary database server
Info |
---|
This is the database server in our facility in e.g. Munich |
Code Block |
---|
initdb -D /var/lib/pgsql/daselement-datamunich |
Configure primary server
change postgres.conf to enable networking
create a replication user
allow remote access in pg_hba.conf
...
Code Block |
---|
vim /var/lib/pgsql/daselement-datamunich/postgres.conf # uncomment and change the line: listen_addresses = '*' # and change the port to 5433 to avoid conflicts with production port 5432 port = 5433 # start the database pg_ctl -D /var/lib/pgsql/daselement-data start |
...
Code Block |
---|
vim /var/lib/pgsql/daselement-data/pg_hba.conf # TYPE DATABASE USER CIDR-ADDRESS METHOD # IPv4 local connections host all repuser localhost trust # restart the database pg_ctl -D /var/lib/pgsql/daselement-datamunich restart |
The primary system is now ready. Let’s move on to the replica system!
Create replica database server
Info |
---|
Now we are at a database server in a different facility. E.g. Vancouver |
Code Block |
---|
# create the replica database
# this command pg_basebackup copies the files from the primary database
pg_basebackup -h db-munich -U repuser --checkpoint=fast -D /var/lib/pgsql/daselement-munich-replica/ -R --slot=daselement_munich -C --port 5433 |
In the replica directory you will find these two files
standby.signal
this file defines that the database that it is a replica
postgresql.auto.conf
contains information to connect to the primary server