pgraft Installation

Build and install pgraft PostgreSQL Raft extension from source.

Prerequisites

1

PostgreSQL 16-18

pgraft requires PostgreSQL version 16 or higher with development headers.

2

Go 1.21+

pgraft uses a Go-based Raft implementation that requires Go 1.21 or later.

3

Build Tools

GCC/Clang, Make, and pkg-config for building the extension.

Installation Steps

1. Clone the Repository

git clone https://github.com/pgElephant/pgraft.git
cd pgraft

2. Build the Extension

make
sudo make install

This builds both the PostgreSQL extension and the Go Raft library.

3. Configure PostgreSQL

# Add to postgresql.conf
shared_preload_libraries = 'pgraft'

# Restart PostgreSQL
sudo systemctl restart postgresql

4. Create the Extension

psql -d postgres
CREATE EXTENSION pgraft;

Verification

# Check if extension is loaded
SELECT * FROM pg_extension WHERE extname = 'pgraft';

# Check available functions
\df pgraft_*

Troubleshooting

Build Errors

Ensure all dependencies are installed and PostgreSQL development headers are available.

Extension Not Loading

Check PostgreSQL logs for errors and ensure shared_preload_libraries is configured correctly.