PIGSTY - Self-Host Postgres like a Pro for Multi-Cloudron Distributed DB
-
PIGSTY - Self-Host Postgres like a Pro
Enterprise-Grade Open-Source PostgreSQL Distribution with HA, PITR, IaC, Monitor, and 460 PG extensions.
"PostgreSQL In Great STYle": Postgres, Infras, Graphics, Service, Toolbox, it's all Yours.
Website | ORG | PGEXT | AI INFRA | Public Demo | Blog | Discuss | Support | δΈζ
Pigsty scales from laptop to datacenter. Enterprise-grade. Developer-friendly. Get Started with the latest v4.2.2:
curl -fsSL https://repo.pigsty.io/get | bash -s v4.2.2Features
- Extensible: 464+ PG Extensions & 12 PG Kernels available, Packed for 14 Linux Platforms, Battery-Included.
- Reliable: Self-healing HA clusters with pre-configured PITR and built-in ACL, CA & SSL secure best practice.
- Observable: SOTA monitoring for PG / Infra / Node based on the Victoria & Grafana stack: Demo & Gallery.
- Scalable: Auto-routed & pooled customizable database Services Access with haproxy, pgbouncer, and VIP.
- Maintainable: One-Cmd Deploy, Admin SOP, Auto-Tune, Local Repo, IaC and Vagrant / Terraform support.
- Composable: Bonus Modules such as Redis, MinIO, Etcd, Docker, DuckDB, FerretDB, Supabase, & More.
- Controllable: Self-sufficient Infra Closure, Cloud Neutral FOSS. Run on bare Linux without Docker & K8S.
- Affordable: Self-Hosting like a Pro, without the cost of RDS. Empowering Cloud-Exit for Ultra Cost Saving!
You can even use many exotic PG Kernel Forks as in-place replacement and wrap it as a full RDS service:
Kernel Key Feature Description PostgreSQL Battery-Included Original PGDG PostgreSQL with 460+ extensions Supabase Backend as Service BaaS over PostgreSQL, Firebase alternative Citus Horizontal Scaling Distributive PostgreSQL via native extension Babelfish SQL Server Simulation Microsoft SQL Server wire-compatibility IvorySQL Oracle Simulation Oracle Grammar and PL/SQL compatible OpenHalo MySQL Simulation MySQL wire-protocol compatibility FerretDB MongoDB Simulation MongoDB wire-protocol compatibility Percona Transparent Data Encryption Percona Distribution with pg_tde OrioleDB OLTP Optimization Engine No bloat, No XID Wraparound, S3 Storage PolarDB Aurora flavor RAC RAC, China domestic compliance AgensGraph Graph-Native Database Transactional graph database based on PostgreSQL pgEdge Multi-Master Distributive Geo-Distributive multi-writer Postgres Cloudberry MPP Data Warehouse Greenplum 7 Apache OSS Fork And gather the synergistic superpowers of all 460+ PostgreSQL Extensions all together:
Get Started
Prepare a fresh
x86_64/aarch64node runs any compatible Linux OS Distros, then Install Pigsty with:curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty;Then configure and run the
deploy.ymlplaybook with an admin user (nopassssh&sudo
./configure -g # generate config and random passwords ./deploy.yml # deploy everything on current nodeFinally, you will get a pigsty singleton node ready, with WebUI on port
80/443and Postgres on port5432.For dev/testing purposes, you can also run Pigsty inside Docker containers:
cd docker; make launch
Single-Node Setup | Production Deploy | Offline Install | Minimal Install | Docker Install | Run Supabase
<details><summary>Install with the pig cli</summary><br>
Then you can launch pigsty with
pig stysub command:curl -fsSL https://repo.pigsty.io/pig | bash # install pig pig sty init # install latest pigsty src to ~/pigsty pig sty conf # auto-generate pigsty.yml config file pig sty deploy # run the deploy.yml playbook</details>
<details><summary>Install with get script</summary><br>
[root@pg-meta ~]# curl -fsSL https://repo.pigsty.io/get | bash -s v4.2.2 [v4.2.2] =========================================== $ curl -fsSL https://repo.pigsty.io/get | bash [Docs] https://pigsty.io/docs [Demo] https://demo.pigsty.io [Repo] https://github.com/pgsty/pigsty [Download] =========================================== [ OK ] version = v4.2.2 (from arg) curl -fSL https://repo.pigsty.io/src/pigsty-v4.2.2.tgz -o /tmp/pigsty-v4.2.2.tgz ######################################################################## 100.0% [ OK ] md5sums = 53cb5980f9XXXXX1fbb832d7ee2fc93a /tmp/pigsty-v4.2.2.tgz [Install] =========================================== [WARN] os user = root , it's recommended to use a non-root sudo-able admin [ OK ] install = /root/pigsty, from /tmp/pigsty-v4.2.2.tgz [Bootstrap] =========================================== [WARN] ansible = not found, bootstrap bootstrap pigsty v4.2.2 begin [ OK ] region = china [ OK ] kernel = Linux [ OK ] machine = x86_64 [ OK ] package = rpm,dnf [ OK ] vendor = rocky (Rocky Linux) [ OK ] version = 10 (10.0) [ OK ] sudo = root ok [WARN] ssh = root@127.0.0.1 fixed [WARN] old repos = moved to /etc/yum.repos.d/backup [ OK ] repo file = add el10.x86_64 china upstream [WARN] rpm cache = updating, may take a while Pigsty PGSQL 10 - x86_64 364 kB/s | 251 kB 00:00 EL 10 BaseOS 10 - x86_64 32 MB/s | 6.4 MB 00:00 EL 10 AppStream 10 - x86_64 11 MB/s | 2.1 MB 00:00 EL 10 CRB 10 - x86_64 1.8 MB/s | 492 kB 00:00 EL 10 EPEL 10.0 - x86_64 27 MB/s | 4.8 MB 00:00 Metadata cache created. [ OK ] repo cache = created [ OK ] install el10 utils Last metadata expiration check: 0:00:02 ago on Wed 07 Jan 2026 05:58:22 PM CST. ..... Installed: ansible-2.16.14-1.el10.noarch ansible-collection-ansible-posix-2.0.0-1.el10_0.noarch ansible-collection-community-crypto-2.15.0-1PIGSTY.el10.noarch ansible-collection-community-general-10.2.0-1.el10_0.noarch ansible-core-1:2.16.14-1.el10.noarch git-core-2.47.3-1.el10.x86_64 python3-cffi-1.16.0-7.el10.x86_64 python3-cryptography-43.0.0-4.el10.x86_64 python3-jmespath-1.0.1-8.el10.noarch python3-ply-3.11-25.el10.noarch python3-pycparser-2.20-16.el10.noarch python3-resolvelib-1.0.1-6.el10.noarch Complete! [ OK ] ansible = ansible [core 2.16.14] [ OK ] boostrap pigsty complete proceed with ./configureHINT: To install a specific version, pass the version string as the first parameter:
curl -fsSL https://repo.pigsty.io/get | bash -s v4.2.2</details>
<details><summary>Clone src with git</summary><br>
You can also download the pigsty source with
git, remember to check out a specific version tag, themainbranch is for development.git clone https://github.com/pgsty/pigsty; cd pigsty; git checkout v4.2.2</details>
Architecture
Pigsty uses a modular design: you can use one or all, with best-of-breed products integrated as a platform.
Self-healing PostgreSQL HA cluster powered by Patroni, Pgbouncer, PgBackrest & HAProxy
Nginx, Local Repo, DNSMasq, and the entire Victoria & Grafana observability stack.
Init node name, repo, pkg, NTP, ssh, admin, tune, expose services, collect logs & metrics.
Etcd cluster is used as a reliable distributed configuration store by PostgreSQL HA agents.
You can compose them freely in a declarative manner.
INFRA&NODEwill suffice for host monitoring.
ETCDandPGSQLare used for HA PG clusters; installing them on multiple nodes automatically forms HA clusters.The default
deploy.ymlplaybook will deployINFRA,NODE,ETCD&PGSQLon the current node.
This gives you an out-of-the-box PostgreSQL singleton instance (admin_ip:5432) with everything ready.The node can be used as an admin controller to deploy & monitor more nodes & clusters. For example, you can install these 6 OPTIONAL extra modules for advanced use cases:
S3-compatible object storage service; used as an optional central backup server for
PGSQL.Deploy Redis servers in standalone master-replica, sentinel, and native cluster mode.
Native support for FerretDB β adding MongoDB wire protocol compatibility to Postgres!
Launch optional docker daemons to run other stateless parts besides Pigsty RDS.
JuiceFS can mount S3/MinIO, and even PostgreSQL as a filesystem shared by multi users.
Vibe coding environment with VS Code Server, JupyterLab, Node.js, and Claude Code.
Of course, you can deploy different kinds of HA PostgreSQL clusters on multiple nodes, as much as you want.
It will create a cluster with everything properly configured: High Availability powered by patroni & etcd; Point-In-Time-Recovery powered by pgBackRest & optional MinIO / S3;
auto-routed, pooled Services & Access pooled by pgBouncer and exposed by haproxy; and out-of-the-box Monitoring & alerting powered by theINFRAmodule.The cluster keeps serving as long as ANY instance survives, with excellent Fault-Tolerance performance:
RPO = 0 on sync mode, RPO < 1MB on async mode; RTO ~ 2s on switchover, RTO < 30s on failover.
You can deploy different kinds of PostgreSQL instance such as
primary,replica,offline,delayed,sync standby, etc.,
and customize with scene-optimize config templates and all 460+ extensions out-of-the-box.You can define Users, Databases, Service, HBAs and other entities with code and provision them in one pass.
You can also self-host postgres-centric software like
SUPABASE,Odoo&Dify, Electric, GitLab, ... with Pigsty:<details><summary>Example: Self-hosting Supabase</summary><br>
You can launch a self-hosting supabase with MinIO and PostgreSQL with just several commands:
./configure -c supabase # use supabase config ./deploy.yml # install pigsty ./docker.yml # install docker compose ./app.yml # launch supabase stateless part with dockerThe
conf/supabase.ymljust describes everything you need:pg-meta: hosts: { 10.10.10.10: { pg_seq: 1, pg_role: primary } } vars: pg_cluster: pg-meta pg_users: # supabase roles: anon, authenticated, dashboard_user - { name: anon ,login: false } - { name: authenticated ,login: false } - { name: dashboard_user ,login: false ,replication: true ,createdb: true ,createrole: true } - { name: service_role ,login: false ,bypassrls: true } # supabase users: please use the same password - { name: supabase_admin ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: true ,roles: [ dbrole_admin ] ,superuser: true ,replication: true ,createdb: true ,createrole: true ,bypassrls: true } - { name: authenticator ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false ,roles: [ dbrole_admin, authenticated ,anon ,service_role ] } - { name: supabase_auth_admin ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false ,roles: [ dbrole_admin ] ,createrole: true } - { name: supabase_storage_admin ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false ,roles: [ dbrole_admin, authenticated ,anon ,service_role ] ,createrole: true } - { name: supabase_functions_admin ,password: 'DBUser.Supa' ,pgbouncer: true ,inherit: false ,roles: [ dbrole_admin ] ,createrole: true } - { name: supabase_replication_admin ,password: 'DBUser.Supa' ,replication: true ,roles: [ dbrole_admin ]} - { name: supabase_read_only_user ,password: 'DBUser.Supa' ,bypassrls: true ,roles: [ dbrole_readonly, pg_read_all_data ] } pg_databases: - name: postgres baseline: supabase.sql owner: supabase_admin comment: supabase postgres database schemas: [ extensions ,auth ,realtime ,storage ,graphql_public ,supabase_functions ,_analytics ,_realtime ] extensions: - { name: pgcrypto ,schema: extensions } # cryptographic functions - { name: pg_net ,schema: extensions } # async HTTP - { name: pgjwt ,schema: extensions } # json web token API for postgres - { name: uuid-ossp ,schema: extensions } # generate universally unique identifiers (UUIDs) - { name: pgsodium } # pgsodium is a modern cryptography library for Postgres. - { name: supabase_vault } # Supabase Vault Extension - { name: pg_graphql } # pg_graphql: GraphQL support - { name: pg_jsonschema } # pg_jsonschema: Validate json schema - { name: wrappers } # wrappers: FDW collections - { name: http } # http: allows web page retrieval inside the database. - { name: pg_cron } # pg_cron: Job scheduler for PostgreSQL - { name: timescaledb } # timescaledb: Enables scalable inserts and complex queries for time-series data - { name: pg_tle } # pg_tle: Trusted Language Extensions for PostgreSQL - { name: vector } # pgvector: the vector similarity search - { name: pgmq } # pgmq: A lightweight message queue like AWS SQS and RSMQ # supabase required extensions pg_libs: 'timescaledb, plpgsql, plpgsql_check, pg_cron, pg_net, pg_stat_statements, auto_explain, pg_tle, plan_filter' pg_parameters: cron.database_name: postgres pgsodium.enable_event_trigger: off pg_hba_rules: # supabase hba rules, require access from docker network - { user: all ,db: postgres ,addr: intra ,auth: pwd ,title: 'allow supabase access from intranet' } - { user: all ,db: postgres ,addr: 172.17.0.0/16 ,auth: pwd ,title: 'allow access from local docker network' } pg_crontab: [ '00 01 * * * /pg/bin/pg-backup full' ] # make a full backup every 1am
</details>
There are other pro, beta, or pilot modules, and there will be more coming in the future:
License
Pigsty is licensed under Apache-2.0. Check NOTICE and License Documentation for details.
About
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register Login



