This document provides a step-by-step guide for setting up a highly available (HA) PostgreSQL cluster using GritivaCore. The setup includes a primary node, two replicas, and a connection pooler (pgbouncer), all interconnected via gmesh.
Create the primary scope on VM-1 from the panel at gritiva.com: INFRA → Scopes → New scope, name pg-primary, VM-1, 4 vCPU / 16 GB, isolation medium, network mode mesh so the replicas can reach it. Wait for the status to go from creating to running.
On VM-2 and VM-3, repeat INFRA → Scopes → New scope to create pg-replica-1 and pg-replica-2, and join all three scopes to the same mesh network under MESH → Networks. Check that the peers came up:
Register PostgreSQL as a service in the panel: open the pgbouncer scope, go to PROJECTS → Services → Add service, name it postgres and point it at port 6432. The service reports initializing and then active once the agent sees it listening.
Grant another scope access from Sharing → Access shares → New share: pick pgbouncer:postgres from the catalog as the resource and my-app as the grantee. Confirm the grant:
Take scope backups from the panel (Scopes → pg-primary → Backups) or on a schedule under INFRA → Scopes → Backups → Schedules, and keep a daily pg_basebackup running inside the cluster as well:
BASH
# backups that exist for a scopecurl -s -H "X-API-Key: $GRITIVA_API_KEY" \ https://api.gritiva.com/api/v1/scopes/<scope-id>/backups# is offsite S3 copying configured?curl -s -H "X-API-Key: $GRITIVA_API_KEY" \ https://api.gritiva.com/api/v1/backups/s3/status
Creating one on demand is POST /api/v1/scopes/<scope-id>/backups, which is what the panel button calls. Note that offsite S3 copies are not enabled by default — the status endpoint returns {"enabled": false} until the S3_* environment variables are set on the backend — so until you configure them, every copy lives on the same host as the cluster. Ship your pg_basebackup output somewhere else yourself.
If you encounter issues, refer to common troubleshooting tips for PostgreSQL clusters. If a whole scope rather than Postgres looks wrong, check the agent on that VM with sudo /opt/gritiva/gritiva-agent scope-status and journalctl -u gritiva-agent.
This guide provides a comprehensive approach to setting up a PostgreSQL cluster with high availability. For further insights, refer to the official PostgreSQL documentation.