Skip to main content
Servers Are Up
Virtual Datacenter
Pricing
Sign inCreate VDC
Servers Are Up
Virtual Datacenter
Pricing
Sign inCreate VDC

Loading…

Servers Are UpEncrypted Multi-Provider VDC

Connect your cloud and on-site servers in one encrypted Virtual Datacenter. Open a browser console, recover a backup or automate a deployment from your workspace.

Customer Portal & Services

Client DashboardMulti-Provider VDCMy ServersBYOC & HybridBrowser ConsoleBillingAPI Keys & MCPSupport
SLA with service creditsVirtual datacenterWorkspace pricingRegional placement

Create your virtual datacenter

Connect your first machine or check regional availability in your workspace. Review the monthly price before you order.

Sign up freeView Pricing

Products

  • Linux servers
  • Windows servers
  • Cloud & SaaS Services
  • Cloud Storage (Azure)
  • Virtual Datacenter
  • AI workloads
  • Containers
  • Self-hosted applications
  • Software Platforms
  • Network builder
  • Game Servers
  • Game sponsorship
  • Pricing

Resources

  • Free Network Tools
  • 2026 Pricing Benchmark
  • Live SVG Badges
  • Latency & Speed Test
  • Guides & Tutorials
  • Documentation
  • API Reference
  • MCP Server
  • CLI & SDKs
  • OpenAPI & llms.txt
  • Use Cases
  • Migration guide
  • Uptime & Reliability
  • Datacenter
  • System Status
  • Network
  • Provider Comparisons Hub
  • Compare Providers

Company

  • About Us
  • Enterprise
  • Security Architecture
  • Trust Center
  • Blog
  • FAQ
  • Compliance
  • Startup Program
  • Open-Source Sponsorship
  • Press & Media Kit
  • Referral Program
  • Help Center
  • Contact Us
© Servers Are Up
TermsPrivacySLARefund PolicyDPAAcceptable Use
Service information
Docs
  • Documentation Hub
  • Technical Knowledge Library
    Runbooks & 187 Blueprints
  • Choose a Product
    VMs, Containers & Cloud
  • First Linux Server
    SSH, Firewall & Apps
  • Windows Server 2025
    BYOL & Remote Desktop
  • Remote Access
  • Troubleshooting
  • FAQ
  • All Product Guides
    33 Step-by-Step Guides
  • Cloud & SaaS Catalog
    139 Cloud & SaaS Offerings
  • Azure Cloud Storage
    Hot/Cool/Archive & WORM
  • Resource Manager & RBAC
    Groups, Tags & Locks
  • ARM/TF & Cloud Blueprints
    42-Type IaC & State
  • OCI Container Registry
    SBOM, CVE & Signing
  • Multi-Model Cloud DB
    JSONB, SQL & pgvector
  • Cloud Identity & ZTNA
    OIDC, SCIM & PIM
  • Per-Environment Tenant Suite
    Isolated Auth, SIEM & MCP
  • Secrets & KMS
    Secrets & Envelope Keys
  • Cloud SIEM, SOAR & DLP
    Posture & Threat Response
  • Data Lineage & DSPM
    Classification, EASM & DKE
  • API Gateway & Cloud DNS
    Edge WAF & DNS Zones
  • Serverless, Workflows & IoT
    Functions, Queues & DAGs
  • SaaS, Governance & Vault
    Budgets & Off-Host GRS
  • Linux Systems & Kernel
    SSH, UFW, sysctl & OOM
  • Self-Hosted Apps & Stacks
    Caddy, Nextcloud & Auth
  • Build Web Apps with AI
  • Next.js and React
  • TypeScript and Node.js
  • npm and Tooling
  • Data and APIs
  • Deploy and Operate
  • Tutorials
  • Infrastructure
  • Automation & Regions
  • API Overview
  • API v1 Reference
    Endpoints & 26 Scopes
  • MCP Server
    202 AI Agent Tools
  • Swagger / OpenAPI 3.1
  • API Playground
  • Versioning & Sunset
  • API Token Security
    Authentication & Tokens
  • Instances API
    Compute Resources
  • Networking API
    Networks & Ports
  • Storage API Availability
    Volumes & Backups
  • Webhooks & Events
    Event Notifications
  • Rate Limits & Best Practices
    Throttling & Retries
  • sau CLI Reference
    202 Commands (v0.3)
  • Browser Web CLI
  • SDKs
  • Infrastructure as Code
    Terraform & Ansible
  • Code Examples
  • CLI & SDK Guides
  • Security Guides
  • Security at a Glance
  • Zero Trust Architecture
  • Live Trust Center
  • Compliance
Need help?

Loading documentation...

Documentation/tutorials

Set Up Database Cluster

Run a resilient database cluster with backups and failover.

Advanced
18 min
Updated 2026-10-27
Browse runbooks

Connect your first machine

Manage one cloud or on-site machine free. Team covers up to 10 machines and Business covers up to 50.

Open your VDCView Pricing

Self-managed setup. A managed database product is planned and not yet available. This guide sets up PostgreSQL yourself across Linux servers you check out.

Run a PostgreSQL primary with streaming replicas, connection pooling and nightly backups.

Architecture

Server Role Size
db-primary Primary (read/write) 4 vCPU / 8 GB or more
db-replica-1 Replica (read-only) the same as the primary
db-replica-2 Replica (read-only) 2 vCPU / 4 GB or more

All three servers share your environment's private network, and its firewall lets them reach each other on every port. None of them needs a port forward: the application reaches them over the private network.

Step 1: Create Infrastructure

Create a Virtual Datacenter first. Enroll a machine in your cloud account or at your site, or choose a currently qualified external region in the VDC. Check the displayed provider, configuration and price before placing an order.

Create the three servers in the same environment. Each joins its private network at creation; its private address is on Servers > [your server] > Network, and the network's range (like 10.0.105.0/24) is on Network > Map. See Private Networking.

On each server, turn on public SSH, sign in with the command from its How to connect card, and run sudo -i for a root shell.

Step 2: Install PostgreSQL

On all three servers:

apt update
apt install -y postgresql-16

Ubuntu 24.04 creates the 16/main cluster and starts it.

Step 3: Configure Every Server

On all three servers, in place of PRIVATE_NETWORK write your private network's range:

cat > /etc/postgresql/16/main/conf.d/cluster.conf <<'EOF'
listen_addresses = '*'
wal_level = replica
max_wal_senders = 5
wal_keep_size = '1GB'
hot_standby = on
EOF

cat >> /etc/postgresql/16/main/pg_hba.conf <<'EOF'
host replication replicator PRIVATE_NETWORK scram-sha-256
host all         all        PRIVATE_NETWORK scram-sha-256
EOF

systemctl restart postgresql

Step 4: Create the Replication User

On db-primary only, with a strong password of your own:

sudo -u postgres psql -c "CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD 'STRONG_REPLICATION_PASSWORD';"

Step 5: Start the Replicas

On each replica, replace its data with a copy of the primary's. pg_basebackup asks for the replicator's password:

systemctl stop postgresql
rm -rf /var/lib/postgresql/16/main
sudo -u postgres pg_basebackup -h PRIMARY_PRIVATE_IP -U replicator \
  -D /var/lib/postgresql/16/main -Fp -Xs -P -R
systemctl start postgresql

The -R flag writes standby.signal and the connection to the primary, so the copy starts as a replica.

Step 6: Verify Replication

On the primary, both replicas are listed with state = streaming:

sudo -u postgres psql -c "SELECT client_addr, state, sync_state FROM pg_stat_replication;"

On a replica, recovery is on:

sudo -u postgres psql -c "SELECT pg_is_in_recovery();"

Step 7: Connection Pooling with PgBouncer

On the primary, create your application's user and database, and print the user's password secret for PgBouncer:

sudo -u postgres psql -c "CREATE ROLE appuser LOGIN PASSWORD 'STRONG_APP_PASSWORD';"
sudo -u postgres psql -c "CREATE DATABASE mydb OWNER appuser;"
sudo -u postgres psql -Atc "SELECT rolpassword FROM pg_authid WHERE rolname = 'appuser';"

On your application server, in place of APPUSER_SCRAM_SECRET paste the line the last command printed (it starts with SCRAM-SHA-256):

apt update
apt install -y pgbouncer postgresql-client

cat > /etc/pgbouncer/pgbouncer.ini <<'EOF'
[databases]
mydb = host=PRIMARY_PRIVATE_IP port=5432 dbname=mydb
mydb_ro = host=REPLICA1_PRIVATE_IP port=5432 dbname=mydb

[pgbouncer]
listen_addr = 127.0.0.1
listen_port = 6432
auth_type = scram-sha-256
auth_file = /etc/pgbouncer/userlist.txt
pool_mode = transaction
max_client_conn = 200
default_pool_size = 25
EOF

echo '"appuser" "APPUSER_SCRAM_SECRET"' > /etc/pgbouncer/userlist.txt
chown postgres:postgres /etc/pgbouncer/userlist.txt
chmod 640 /etc/pgbouncer/userlist.txt
systemctl restart pgbouncer

# Through PgBouncer to the primary; it asks for appuser's password
psql "host=127.0.0.1 port=6432 dbname=mydb user=appuser" -c "SELECT 1;"

Your application connects to 127.0.0.1:6432: database mydb for writes, mydb_ro for reads from a replica.

Step 8: Automated Backups

On the primary, a nightly dump runs as the postgres user and keeps seven days:

install -d -o postgres -g postgres -m 700 /var/backups/postgresql

cat > /usr/local/bin/backup-db.sh <<'EOF'
#!/bin/bash
set -euo pipefail
FILE="/var/backups/postgresql/db-backup-$(date +%Y%m%d-%H%M%S).sql.gz"
pg_dumpall | gzip > "$FILE"
find /var/backups/postgresql -name 'db-backup-*.sql.gz' -mtime +7 -delete
echo "Backup complete: $FILE"
EOF
chmod 755 /usr/local/bin/backup-db.sh

echo '0 2 * * * postgres /usr/local/bin/backup-db.sh >> /var/backups/postgresql/backup.log 2>&1' > /etc/cron.d/db-backup

# Run it once now
sudo -u postgres /usr/local/bin/backup-db.sh

A dump on the same server does not survive the server. Copy the dumps to storage you control, such as an S3-compatible bucket.

Failover

If the primary fails, promote a replica. On the replica to promote:

pg_ctlcluster 16 main promote
sudo -u postgres psql -Atc "SELECT pg_is_in_recovery();"  # f: it takes writes now

Then point your application (or PgBouncer's mydb line) at the new primary, and rebuild the other servers as its replicas with Step 5.

Next Steps

  • Snapshots & Backups
  • Monitoring
  • Private Networking

Related Articles

Snapshots & Backups

Read more

Monitoring

Read more

Private Networking

Read more

Frequently Asked Questions

What does the Set Up Database Cluster documentation guide cover?
Run a resilient database cluster with backups and failover. It is rated advanced difficulty (18 min) and applies to Servers Are Up infrastructure and workflows.
Can I manage or automate these steps through the Servers Are Up dashboard, REST API v1, or MCP server?
Yes. Every Servers Are Up server includes browser-based SSH, WebRDP, and VNC console access in the dashboard, plus programmatic control via the REST API v1 (/api/v1) and hosted Model Context Protocol server (/api/mcp/v1) using a scoped Personal Access Token.

Need hands-on help with Set Up Database Cluster?

Open the workspace to check your machine’s connection and available controls. For automation, consult the REST API or MCP guide. Include the resource and region when you contact support.

Was this article helpful?

On this page

ArchitectureStep 1: Create InfrastructureStep 2: Install PostgreSQLStep 3: Configure Every ServerStep 4: Create the Replication UserStep 5: Start the ReplicasStep 6: Verify ReplicationStep 7: Connection Pooling with PgBouncerStep 8: Automated BackupsFailoverNext Steps