Try it with Pigsty
This example uses the Pigsty mongo template and FerretDB from the earlier PG18 study. The configuration was conf/mongo.yml in Pigsty v4.5.0 and conf/fork/mongo.yml in its development sources at the time. Single-node Mimus 19.0.1 results
Single-node deployment
The default mongo template deploys PostgreSQL 18, the documentdb extension stack and a local FerretDB container on a single node (10.10.10.10):
Configure and deploy the PostgreSQL cluster, then install Docker and launch the
ferretdbapplication container on thepg-metanode:Connect from
mongoshor any MongoDB driver to the local loopback listener on port27017using the backend PostgreSQL user created by the template:
What the template configures
On the PostgreSQL side (pg_version: 18), the mongo template declares a mongod backend superuser, sets cron.database_name to postgres, preloads the DocumentDB and pg_cron libraries, and installs the required extensions in the postgres database:
On the gateway side, Pigsty deploys FerretDB (ghcr.io/ferretdb/ferretdb:2.7.0) as a stateless Docker application under apps.ferretdb.conf. The container connects to Pigsty’s local primary-routing service on port 5436 via host.docker.internal:
Three-node high-availability topology
Because FerretDB holds no state, high availability uses the standard PostgreSQL Patroni + etcd cluster layout (pg-mongo in the template):
- Each of the three PostgreSQL nodes (
10.10.10.11–10.10.10.13) runs a local FerretDB container bound to{{ inventory_hostname }}:27018and connected to its local port5436primary-routing service. - HAProxy runs TCP health checks (
option tcp-checkon port27018) across the three gateway containers and exposes a single floating endpoint at10.10.10.4:27017(mongo.pigsty). - Patroni and etcd handle PostgreSQL primary failover, while pgBackRest writes backups to a shared Silo or external S3 repository so backup history survives primary switchovers.
After uncommenting the pg-mongo cluster and the two additional etcd members in the template, deploy with:
Backup scope for DocumentDB 1.2
On PostgreSQL 19 with DocumentDB 1.2 and pg_cron 1.6.8, exclude the cron schema at dump time only if the destination may recreate the default jobs and you can discard user jobs, schedule or active-state changes, original job IDs, and execution history.
This omits the entire cron schema, including jobs registered by other extensions. To keep your options open, omit -N cron at dump time and retain the full custom-format archive. Use pg_restore --exit-on-error -N cron -d doclab doclab.dump only on a fresh destination that may start with default jobs. Other restores can still use the original scheduling data. If scheduling state must survive, keep it in the backup and use a tested restore procedure. Excluding only cron.job leaves history pointing to old job IDs.
A PostgreSQL logical archive of stock DocumentDB 1.2 can contain the physical document tables but omit the catalog that maps collection names to those tables. A successful pg_restore can therefore leave a collection returning zero documents. To preserve the full document database, use a tested same-version physical backup. On a separate restored instance, read known documents by collection name and check their indexes. Include documentdb_data whenever the backup is intended to preserve documents.
Operational notes
- Loopback binding by default: in single-node mode,
FERRETDB_BIND_ADDRdefaults to127.0.0.1. ChangeFERRETDB_BIND_ADDRonly when remote MongoDB clients need direct network access. - PostgreSQL is the security boundary:
FERRETDB_AUTH: trueauthenticates clients against PostgreSQL roles, but FerretDB does not implement MongoDB role-based authorization. Tightenpg_hba.confand change default passwords before production use. - Client TLS: the template does not enable client-side MongoDB TLS by default; configure certificates and the
FERRETDB_LISTEN_TLS*variables before exposing port27017on an untrusted network. - Upgrade smoke tests: FerretDB releases specify a preferred DocumentDB version while package repositories may ship a newer compatible
documentdbbuild. Run an authenticated CRUD smoke test after upgrading either component.
