...
Code Block | ||||
---|---|---|---|---|
| ||||
# # To check if a database is master or slave: # psql -h <ip-address> -U postgres -c 'SELECT pg_is_in_recovery();' -qtA f = master; t = slave |
Installing new nodes
WARNING: This script deletes the database on the host where it is run. Do NOT run this script on the master node, as that will cause data loss!
When a new node is installed, it needs to be connected to the master manually. This can be done with the following script from our tools-repository:
Code Block | ||||
---|---|---|---|---|
| ||||
# postgres-joinMaster.sh <master_host> Stopping PostgreSQL Cleaning up old cluster directory Starting base backup as replicator pg_basebackup: initiating base backup, waiting for checkpoint to complete pg_basebackup: checkpoint completed 40842/40842 kB (100%), 1/1 tablespace NOTICE: WAL archiving is not enabled; you must ensure that all required WAL segments are copied through other means to complete the backup pg_basebackup: base backup completed Startging PostgreSQL |
...
When a node is joined to the cluster it generates a configfile at '/var/lib/postgresql/9.6/main/recovery.conf' which makes this database server connect to that host everytime it starts.
...