pgraft
Quick Start Guide
Get your first pgraft cluster up and running in minutes. pgraft is a production-ready PostgreSQL extension that embeds the Raft consensus protocol for automatic leader election, deterministic failover, and 100% split-brain protection.
Installation
Install pgraft on your system with these simple steps
Prerequisites
- PostgreSQL 16, 17, or 18
- Go 1.21 or higher
- GCC C compiler
- PostgreSQL development headers
System Requirements
- Minimum 2GB RAM per node
- 10GB free disk space
- Network connectivity between nodes
- Linux, macOS, or Windows
Installation Steps
1. Install Dependencies
2. Clone and Build
Note: The build process compiles both C and Go components, including the etcd-io/raft library integration.
3. Install Extension
Quick Start
Get your first cluster running in 5 minutes
Step 1: Configure PostgreSQL
Add these settings to your postgresql.conf
:
Note: Each node needs a unique node_id
and port
.
Step 2: Initialize pgraft
Connect to PostgreSQL and create the extension:
Step 3: Add Additional Nodes
Repeat steps 1-2 on other nodes, then add them to the cluster:
Step 4: Verify Cluster Status
Check that your cluster is healthy and working properly:
The cluster should show one leader node and the worker should be running. Wait 10 seconds after initialization for leader election to complete.