Configuration
Module:
Categories:
FerretDB Cluster
Before deploying a Mongo (FerretDB) cluster, you need to define it in the inventory using the relevant parameters.
The following example uses the default single-node pg-meta cluster’s meta database as FerretDB’s underlying storage:
all: children: #----------------------------------# # ferretdb for mongodb on postgresql #----------------------------------# # ./mongo.yml -l ferret ferret: hosts: 10.10.10.10: { mongo_seq: 1 } vars: mongo_cluster: ferret mongo_pgurl: 'postgres://mongod:[email protected]:5432/meta' Here, mongo_cluster and mongo_seq are essential identity parameters. For FerretDB, mongo_pgurl is also required to specify the underlying PG location.
Note that the mongo_pgurl parameter requires a PostgreSQL superuser. In this example, a dedicated mongod superuser is defined for FerretDB.
Note that FerretDB’s authentication is entirely based on PostgreSQL. You can create other regular users using either FerretDB or PostgreSQL.
PostgreSQL Cluster
FerretDB 2.0+ requires an extension: DocumentDB, which depends on several other extensions. Here’s a template for creating a PostgreSQL cluster for FerretDB:
all: children: #----------------------------------# # pgsql (singleton on current node) #----------------------------------# # postgres cluster: pg-meta pg-meta: hosts: { 10.10.10.10: { pg_seq: 1, pg_role: primary } } vars: pg_cluster: pg-meta pg_users: - { name: mongod ,password: DBUser.Mongo ,pgbouncer: true ,roles: [dbrole_admin ] ,superuser: true ,comment: ferretdb super user } - { 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 for meta database } pg_databases: - {name: meta, owner: mongod ,baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [pigsty] ,extensions: [ documentdb, postgis, vector, pg_cron, rum ]} pg_hba_rules: - { user: dbuser_view , db: all ,addr: infra ,auth: pwd ,title: 'allow grafana dashboard access cmdb from infra nodes' } - { user: mongod , db: all ,addr: world ,auth: pwd ,title: 'mongodb password access from everywhere' } pg_extensions: - documentdb, citus, postgis, pgvector, pg_cron, rum pg_parameters: cron.database_name: meta pg_libs: 'pg_documentdb, pg_documentdb_core, pg_cron, pg_stat_statements, auto_explain' # add timescaledb to shared_preload_libraries High Availability
You can use Services to connect to a highly available PostgreSQL cluster and deploy multiple FerretDB instance replicas with L2 VIP binding for FerretDB layer high availability.
ferret: hosts: 10.10.10.45: { mongo_seq: 1 } 10.10.10.46: { mongo_seq: 2 } 10.10.10.47: { mongo_seq: 3 } vars: mongo_cluster: ferret mongo_pgurl: 'postgres://mongod:[email protected]:5436/test' vip_enabled: true vip_vrid: 128 vip_address: 10.10.10.99 vip_interface: eth1 Parameters
There are 9 parameters in the MONGO module.
| Parameter | Type | Level | Comment |
|---|---|---|---|
mongo_seq | int | I | mongo instance identifier, REQUIRED |
mongo_cluster | string | C | mongo cluster name, MONGO by default |
mongo_pgurl | pgurl | C/I | underlying postgres URL for ferretdb |
mongo_ssl_enabled | bool | C | mongo/ferretdb ssl enabled, false by default |
mongo_listen | ip | C | mongo listen address, empty for all addr |
mongo_port | port | C | mongo service port, 27017 by default |
mongo_ssl_port | port | C | mongo tls listen port, 27018 by default |
mongo_exporter_port | port | C | mongo exporter port, 9216 by default |
mongo_extra_vars | string | C | extra environment variables for MONGO server |
# mongo_cluster: #CLUSTER # mongo cluster name, required identity parameter # mongo_seq: 0 #INSTANCE # mongo instance seq number, required identity parameter # mongo_pgurl: 'postgres:///' # mongo/ferretdb underlying postgresql url, required mongo_ssl_enabled: false # mongo/ferretdb ssl enabled, false by default mongo_listen: '' # mongo/ferretdb listen address, '' for all addr mongo_port: 27017 # mongo/ferretdb listen port, 27017 by default mongo_ssl_port: 27018 # mongo/ferretdb tls listen port, 27018 by default mongo_exporter_port: 9216 # mongo/ferretdb exporter port, 9216 by default mongo_extra_vars: '' # extra environment variables for mongo/ferretdb Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.