Version v3.7.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot.
For up-to-date documentation, see the latest version.
We add two new groups here: etcd and pg-meta, which defines an 1-node ETCD cluster and a 1-node PGSQL cluster.
Recreate everything with ./install.yml, or using these cmd to do incremental steps:
~/pigsty
./etcd.yml -l etcd # install etcd module on group etcd./pgsql.yml -l pg-meta # install pgsql module on group pg-meta
The PGSQL module depends on ETCD for HA consensus, so make sure to install ETCD module first.
Database & Users
Now we want to customize our postgres database cluster, with users, database, and backups:
We define some additional details at the pg-meta cluster level:
pg_users: define a new user dbuser_meta with password DBUser.Meta
pg_databases: define a new database meta with pigsty CMDB schema and vector extension
node_crontab: define crontab that takes a full backup at 1 am every day
Instead of recreating everything with ./install.yml, we make changes incrementally:
~/pigsty
bin/pgsql-user pg-meta dbuser_meta # create user dbuser_meta on pg-metabin/pgsql-db pg-meta meta # create database meta on pg-meta./node.yml -l pg-meta -t node_crontab # add backup task to crontab on pg-meta
PG VER & Extensions
You can install different major versions of PostgreSQL, and 437+ corresponding extensions.
Let’s install PostgreSQL 16 (instead of default 18) with timescaledb, postgis, and pgvector extensions.
~/pigsty/pigsty.yml
all:children:infra:{hosts:{10.10.10.10:{infra_seq:1}}}etcd:{hosts:{10.10.10.10:{etcd_seq:1 } }, vars:{etcd_cluster:etcd } }pg-meta:hosts:{10.10.10.10:{pg_seq:1, pg_role:primary } }vars:pg_cluster:pg-metapg_users:- name:dbuser_metapassword:DBUser.Metapgbouncer:trueroles:[dbrole_admin]comment:pigsty admin userpg_databases:- name:metabaseline:cmdb.sqlcomment:pigsty meta databaseschemas:[pigsty]extensions:[vector, postgis, timescaledb ] # <--- CREATE EXTENSIONSpg_libs:'timescaledb, pg_stat_statements, auto_explain'# <--- LOAD EXTENSIONSnode_crontab:- '00 01 * * * postgres /pg/bin/pg-backup full'vars:admin_ip:10.10.10.10region:default # use local mirror for faster download speed # <--- default|china|europerepo_extra_packages:[timescaledb, postgis, pgvector, pgsql ]# <--- DOWNLOAD EXTENSIONSpg_extensions:[timescaledb, postgis, pgvector ] # <--- INSTALL EXTENSIONSpg_version:16# PG 17 is the default latest major version # <--- USE PG 16 VERSION
repo_extra_packages: download timescaledb and postgis extensions.
Let’s redownload missing packages (PG 16 kernel & extensions), remove the old cluster, and recreate it:
make repo # redownload packages./pgsql-rm.yml -l pg-meta # remove the old pg-meta cluster (because it is PG18)./pgsql.yml -l pg-meta # recreate the pg-meta cluster with PG16 & extensions
Pigsty’s working assumption is there’s only ONE postgres instance on each node.
There’s no support to run multiple postgres instances on a single node.
Redis Up
Pigsty has optional Redis support, which is used as a cache in front of PostgreSQL.