mongo
DocumentDB + FerretDB(Mongo Wire 协议兼容)配置模板,基于 PostgreSQL 提供 Mongo 风格服务。
mongo 配置模板用于部署 FerretDB 与 DocumentDB 兼容栈,在 PostgreSQL 之上提供 Mongo Wire 协议兼容能力。
配置概览
- 配置名称:
mongo - 节点数量: 单节点(默认)
- 配置说明:基于 PostgreSQL 18 + FerretDB + DocumentDB 的 Mongo 兼容模板。
- 适用系统:
el8,el9,el10,d12,d13,u22,u24 - 适用架构:
x86_64,aarch64 - 相关配置:
meta、pgsql
启用方式:
./configure -c mongo
./deploy.yml
./mongo.yml -l ferret
配置内容
源文件地址:pigsty/conf/mongo.yml
---
#==============================================================#
# File : mongo.yml
# Desc : DocumentDB & FerretDB (MongoDB Compatible) template
# Ctime : 2025-02-23
# Mtime : 2026-01-17
# Docs : https://pigsty.io/docs/ferret
# License : Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#
# This is the config template for FerretDB & DocumentDB
# That is a Mongo Wire-Compatible Layer upon PostgreSQL
# This config template works with PostgreSQL 16, 17, 18
# tutorial: https://pigsty.io/docs/ferret
#
# Usage:
# curl https://repo.pigsty.io/get | bash
# ./configure -c mongo
# ./deploy.yml
# ./mongo.yml -l ferret
all:
children:
infra: { hosts: { 10.10.10.10: { infra_seq: 1 }} ,vars: { repo_enabled: false }}
etcd: { hosts: { 10.10.10.10: { etcd_seq: 1 }} ,vars: { etcd_cluster: etcd }}
#minio: { hosts: { 10.10.10.10: { minio_seq: 1 }} ,vars: { minio_cluster: minio }}
#----------------------------------#
# FerretDB Database Cluster
#----------------------------------#
# ./mongo.yml -l ferret
ferret:
hosts:
10.10.10.10: { mongo_seq: 1 }
vars:
mongo_cluster: ferret
mongo_pgurl: 'postgres://dbuser_dba:DBUser.DBA@10.10.10.10:5432/postgres'
# mongosh 'mongodb://dbuser_dba:DBUser.DBA@10.10.10.10:27017'
#----------------------------------#
# PGSQL Database Cluster
#----------------------------------#
pg-meta:
hosts:
10.10.10.10: { pg_seq: 1, pg_role: primary }
vars:
pg_cluster: pg-meta
pg_users:
- { name: dbuser_meta ,password: DBUser.Meta ,pgbouncer: true ,roles: [dbrole_admin ] ,comment: pigsty admin user }
- { name: dbuser_view ,password: DBUser.Viewer ,pgbouncer: true ,roles: [dbrole_readonly] ,comment: read-only viewer }
pg_databases:
- { name: postgres, extensions: [ documentdb, postgis, vector, pg_cron, rum ]} # run on the postgres database
pg_hba_rules:
- { user: dbuser_view , db: all ,addr: infra ,auth: pwd ,title: 'allow grafana dashboard access cmdb from infra nodes' }
# WARNING: demo/dev only. Avoid world access for dbsu in production.
- { user: postgres , db: all ,addr: world ,auth: pwd ,title: 'dbsu password access everywhere' }
- { user: all ,db: all ,addr: localhost ,order: 1 ,auth: trust ,title: 'documentdb localhost trust access' }
- { user: all ,db: all ,addr: local ,order: 1 ,auth: trust ,title: 'documentdb local trust access' }
- { user: all ,db: all ,addr: intra ,auth: pwd ,title: 'everyone intranet access with password' ,order: 800 }
pg_parameters: { cron.database_name: postgres }
pg_extensions: [ documentdb, postgis, pgvector, pg_cron, rum ]
pg_libs: 'pg_documentdb, pg_documentdb_core, pg_documentdb_extended_rum, pg_cron, pg_stat_statements, auto_explain'
pg_crontab: # https://pigsty.io/docs/pgsql/admin/crontab
- '00 01 * * * /pg/bin/pg-backup full'
vars: # global variables
#----------------------------------------------#
# INFRA : https://pigsty.io/docs/infra/param
#----------------------------------------------#
version: v4.1.0 # pigsty version string
admin_ip: 10.10.10.10 # admin node ip address
region: default # upstream mirror region: default,china,europe
infra_portal: # infra services exposed via portal
home : { domain: i.pigsty } # default domain name
#----------------------------------------------#
# NODE : https://pigsty.io/docs/node/param
#----------------------------------------------#
nodename_overwrite: false # do not overwrite node hostname
node_repo_modules: node,infra,pgsql # add these repos directly to the nodes (consider add 'mongo' too)
node_tune: oltp # node tuning specs: oltp,olap,tiny,crit
#----------------------------------------------#
# PGSQL : https://pigsty.io/docs/pgsql/param
#----------------------------------------------#
pg_version: 18 # default postgres version (16,17,18)
pg_conf: oltp.yml # pgsql tuning specs: {oltp,olap,tiny,crit}.yml
#----------------------------------------------#
# PASSWORD : https://pigsty.io/docs/setup/security/
#----------------------------------------------#
grafana_admin_password: pigsty
grafana_view_password: DBUser.Viewer
pg_admin_password: DBUser.DBA
pg_monitor_password: DBUser.Monitor
pg_replication_password: DBUser.Replicator
patroni_password: Patroni.API
haproxy_admin_password: pigsty
minio_secret_key: S3User.MinIO
etcd_root_password: Etcd.Root
...
配置解读
mongo 模板包含两个核心分组:
pg-meta:PostgreSQL 主库,承载documentdb、pg_cron、rum等扩展。ferret:Mongo 协议兼容服务层,使用mongo_pgurl连接 PostgreSQL。
关键特征:
- 默认使用 PostgreSQL 18(可改为 16/17/18)。
- 在
postgres数据库直接启用documentdb相关能力,便于快速验证。 - 默认 HBA 规则包含本地 trust 与内网密码访问,便于开发测试。
version已对齐v4.1.0,并与主仓库配置保持一致。
注意事项:
- 模板中包含面向开发环境的宽松访问规则(如 world 访问示例),生产环境请按需收紧。
- 若需多节点与高可用,应在此模板基础上扩展拓扑与安全策略。