Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Postgres databases are currently being used as:

  • Data storage for puppetdb

Architecture

The current postgres architecture is a simple Master->Slave setup without automatic failover.

Verification

There are some commands which can be useful to verify psql's operation:

Code Block
titleVerification commands
linenumberstrue
# # 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

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
titleVerification commands
linenumberstrue
# 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

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!

Failover