Deploying a standalone PostgreSQL server

Deploying a standalone PostgreSQL server is a basic example of provisioning and administration of a standalone PostgreSQL cluster running on a single RHEL-compatible box.

The demo exposes the database to the outside world on port 5432 with a configuration option to limit the access to a IP subnet. A local disk is used for storage with an option to use attached block storage location.

What you'll learn

  • Creating a PostgreSQL cluster from scratch
  • Asking for database user passwords interactivelly
  • Creating a custom firewalld service for the PostgreSQL service
  • Connecting to PostgreSQL with psql over SSL/TLS
  • Setting up automatic weekly system update
  • Setting up log rotation for the PostgreSQL log and max limit for system log
  • Doing cluster backups and restores
  • Creating admin tasks

Configuration options

SERVER The virtual machine IP address
SSH_KEY The path to the private SSH key
LISTEN_ADDRESS The IP address or mask for binding PostgreSQL connections
PGDIR The PostgreSQL directory on the block storage (optional)
ADMIN The administrator user name that will replace root
DB_USER The initial database user name
DB_NAME The initial database name
Buy book + code for $50
Rated 36x five stars
Gumroad (as of Aug 3, 2023)
I am using some scripts I downloaded from Josef Strzibny's book that are setting up Ruby on Rails deployment and automatically installing a PostgreSQL server. I am also using Dokku, but I like the idea of controlling what is happening on the server.
Lucian Ghinda, Senior Ruby Developer

Code to get you started

A static website

A static website with automatic Let's Encrypt certificates and system updates. A separate configuration and rootless deployment script.

Add server-side analytics and beat the pricing of hosted solutions.

A database-backed Ruby on Rails application
with Action Cable

A single server running a full-featured web application with UNIX sockets, PostgreSQL ident system authentication, Web Sockets, and Let's Encrypt certificates. A git-push deployment with helpful administration scripts for connecting to the server or handeling file and database backups.

Adjust for your application based on the knowledge from the book. Deploy within the same day!

A standalone PostgreSQL server

A self-sufficient PostgreSQL cluster demo with automatic system upgrades, log rotation, and TLS. Scripts for cluster-wide backups and restores.

Run a standalone database when you need more power or to host all your projects' databases in one place.

All demonstrations are scripted in Bash for RHEL 8 compatible systems such as Rocky Linux 8.

You don't need any knowledge of typical configuration management tools. Learn how everything works without abstractions and indirection.