Postgres Deployment

docker run -d --rm --name $ctnr -p 5432:5432 \
    -v $(pwd):/home \
    -e POSTGRES_DB=${DB_NAME:-dbp} \
    -e POSTGRES_PASSWORD=${DB_PASSWORD:-postgres} \
    -e POSTGRES_USER=${DB_USER:-postgres} \
    'postgres:12.6-alpine'

Warm Standby

# Limit addresses per 'postgresql.conf'
psql -U 'uzr1' -d 'db1' -c 'show listen_addresses'

Server Config

Data directory (default is config dir)

Show Location:

psql -h $host -U $user -c 'SHOW config_file;'
SHOW config_file;

Reload @ running server:

Authentication | pg_hba.conf

Password reset; align with bcrypt method @ services (Golang)

UPDATE users SET pass_hash = crypt('$DB_OPS_PASS', gen_salt('bf', 10))
WHERE (handle = 'app') OR (handle = 'AdminTest') OR (handle = 'UserTest');

@ Docker

13.1, 13, latest
13.1-alpine, 13-alpine, alpine
12.5, 12
12.5-alpine, 12-alpine
11.10, 11
11.10-alpine, 11-alpine
10.15, 10
10.15-alpine, 10-alpine
9.6.20, 9.6, 9
9.6.20-alpine, 9.6-alpine, 9-alpine
9.5.24, 9.5
9.5.24-alpine, 9.5-alpine

@ AWS RDS :: Managed RDBMS Engine per AMI Instance

# Versions list
aws rds describe-db-engine-versions \
    --engine 'postgres' \
    | jq -r '.DBEngineVersions[].EngineVersion'

Storage :: Persistence

@ AWS :: EC2/EBS

  1. Attach EBS volume (disk) to EC2 instance
    • /dev/xvdh
  2. Make partition (optional)
    • /dev/xvdh1
  3. Make filesystem on the partition/disk
  4. Mount filesystem inside EC2 instance
    • /opt/ebs_data
  5. Start Docker container with volume
    • /opt/ebs_data:/var/lib/postgresql/data