Quick start
This procedure builds pgetcd and pg_etcd from source and starts one tenant on an isolated PostgreSQL 18 primary with mutual TLS. For the supported RPCs and operating limits, see Compatibility.
Prerequisites
Prepare the pgetcd source checkout, Go 1.27.3, a C compiler, and PostgreSQL 18.6 with its server headers and PGXS files (pg_config). You also need psql, curl, and permission to install extensions into the PostgreSQL instance.
Configure PostgreSQL TLS and authentication before starting:
- The PostgreSQL server certificate must match the host or IP address in
PGETCD_DSN, and the gateway must trust its root CA. pg_hba.confmust allow the rolepgetcd_demo_gatewayto authenticate over TLS.- Obtain the following mTLS certificates for the gateway and client (
SANis the certificate Subject Alternative Name):
| File | Requirement | Used by |
|---|---|---|
server.crt, server.key | Gateway server certificate and private key; SAN includes the endpoint IP or DNS name | Tenant JSON: tls.certificate, tls.private_key |
client-ca.crt | CA that issued the tenant client certificate | Tenant JSON: tls.client_ca |
tenant-client.crt, tenant-client.key | Client certificate and private key; URI SAN is spiffe://pgetcd/tenant/demo | curl and etcd clients |
server-ca.crt | CA that issued the gateway server certificate | curl --cacert and client CA flags |
Keep private keys and generated credentials outside version control.
Build the gateway and extension
Run these commands from the pgetcd checkout with PG_CONFIG pointing to your PostgreSQL 18 installation:
The gateway binary is written to .cache/docs-dev/pgetcd. The extension installs pg_etcd.so, pg_etcd.control, and pg_etcd--0.1.0.sql into the directories selected by PG_CONFIG.
Configure PostgreSQL
Add pg_etcd to shared_preload_libraries in postgresql.conf and register the tenant database:
Keep fsync and full_page_writes enabled. Restart PostgreSQL so the pg_etcd preload launcher starts.
Create the tenant database
Connect to PostgreSQL as an administrator, create the owner and gateway roles, install the extension, and grant access only to the four public SQL ABI functions:
Configure authentication for pgetcd_demo_gateway according to your instance policy (for example, client certificate authentication or \password pgetcd_demo_gateway in psql).
In the same session, read the database identity and readiness status:
Verify the result in three steps:
- Confirm that
COMMITcompleted without an error or a synchronous-replication cancellation warning. - Confirm that
response.ready,response.primary, andresponse.lease_readyare alltrue. - Record
header.cluster_idandheader.member_idas decimal strings for the tenant configuration file.
If response.ready is false, inspect response.not_ready_reasons. If the Lease worker is still rebuilding, wait briefly and repeat the transaction. For other causes, see Troubleshooting.
Start the gateway
Create .cache/docs-dev/tenant.json from the tenant configuration example. Replace the placeholder "1" values for cluster_id and member_id with the decimal strings returned by diag.status, set database to pgetcd_demo and role to pgetcd_demo_gateway, and fill in your certificate paths.
Start pgetcd with PGETCD_DSN set to a verify-full TLS connection string:
Append sslcert and sslkey to PGETCD_DSN if PostgreSQL requires SQL client certificates. Before opening its listeners, the gateway verifies the SQL ABI, persistent cluster and member identity, and Lease worker readiness.
In a second terminal, query the diagnostics readiness endpoint using the tenant client certificate:
A ready gateway returns {"health":true}. Continue with the etcdctl and Go clientv3 tutorials.
This procedure was run end to end during the v0.1.0-rc1 regression (commit 7e43446) and again for v0.1.0-rc2 (commit 81691bc) on Linux amd64 with PostgreSQL 18.6, using certificate authentication and a synchronous standby.
