Introduction
Pigsty is an open-source PostgreSQL distribution that packages high-availability clustering, monitoring dashboards, and hundreds of extensions into a single Ansible-driven deployment. It aims to give every PostgreSQL user a production-grade setup without manually stitching together separate tools for replication, backups, and observability.
What Pigsty Does
- Deploys PostgreSQL clusters with automatic failover via Patroni and etcd
- Provides pre-built Grafana dashboards for database, system, and query monitoring
- Bundles 340+ PostgreSQL extensions including PostGIS, TimescaleDB, and pgvector
- Manages infrastructure provisioning with Ansible playbooks and a declarative inventory
- Includes local YUM/APT repos for air-gapped and offline installations
Architecture Overview
Pigsty uses Ansible to orchestrate multi-node PostgreSQL clusters. Each database node runs Patroni for leader election, pgBouncer for connection pooling, and a local monitoring agent. A dedicated infra node hosts Grafana, Prometheus, Alertmanager, and a local package repository. Configuration is defined in a single YAML inventory file, and playbooks handle the full lifecycle from bootstrap to scaling.
Self-Hosting & Configuration
- Requires a Linux host (RHEL, Debian, or Ubuntu) with root or sudo access
- Run the bootstrap script to install Ansible and prepare the local repo
- Edit pigsty.yml to define cluster topology, replication mode, and resource limits
- Deploy additional nodes by adding entries to the inventory and re-running the playbook
- Supports Vagrant and Terraform templates for local and cloud sandbox environments
Key Features
- One-command deployment of production-ready PostgreSQL with HA
- Over 30 pre-built Grafana dashboards covering queries, locks, replication lag, and system metrics
- Built-in DKIM/PITR backup via pgBackRest with S3 and local storage targets
- Extension marketplace with pre-compiled packages for major PostgreSQL versions
- Multi-cluster management from a single admin node
Comparison with Similar Tools
- CloudNativePG — Kubernetes-native operator; Pigsty targets bare-metal and VM deployments
- Crunchy PGO — Kubernetes PostgreSQL operator; Pigsty uses Ansible for non-K8s environments
- Patroni (standalone) — HA only; Pigsty bundles monitoring, extensions, and provisioning
- pgAdmin — GUI for a single server; Pigsty manages fleets with dashboards and automation
- Percona Distribution for PostgreSQL — similar concept but Pigsty includes richer monitoring out of the box
FAQ
Q: Can Pigsty run on a single node for development? A: Yes. A single-node sandbox mode installs everything on one machine, which is useful for testing and development.
Q: Does Pigsty support major PostgreSQL version upgrades? A: It provides packages for multiple PostgreSQL versions and supports in-place minor upgrades. Major version upgrades can be done with pg_upgrade following the documented procedure.
Q: Is internet access required during installation? A: Not if you pre-download the offline package. Pigsty can bootstrap entirely from local repos, making it suitable for air-gapped environments.
Q: How does Pigsty handle backups? A: It integrates pgBackRest for full, incremental, and differential backups with point-in-time recovery, stored locally or on S3-compatible storage.