# Optimal Flexible Architecture

Inspired by Oracle standards, dbi services has developed an equivalent **Optimal Flexible Architecture (OFA)** for MongoDB. Its purpose is to provide a logical, efficient, and maintainable directory structure.

All MongoDB instances follow the same installation and management conventions, enabling easier automation.

#### Mount Points and Paths

The recommended mount points for an OFA-compliant MongoDB system are listed below:

| Mount Point | Purpose                                                                           |
| ----------- | --------------------------------------------------------------------------------- |
| `/u01`      | Administration files, database binaries, DMK installation and configuration files |
| `/u02`      | Data files                                                                        |
| `/u03`      | Journal files                                                                     |
| `/u04`      | Log files                                                                         |
| `/u90`      | Backups and dumps                                                                 |

Important paths on your system :

| Path                                     | Purpose                                                                         |
| ---------------------------------------- | ------------------------------------------------------------------------------- |
| `/u01/app/mongodb/product/x.y.z`         | MongoDB binaries. X.Y.Z is the main MongoDB version (8.0.16, for instance)      |
| `/u01/app/mongodb/local/dmk`             | DMK installation path                                                           |
| `/u01/app/mongodb/etc`                   | Location of the `mongodb.lst` file, listing the MongoDB instances on the server |
| `/u01/app/mongodb/artifacts`             | Stage path to keep tar.gz binaries files                                        |
| `/u01/app/mongodb/admin/<instance_name>` | Configuration files for MongoDB instances                                       |
| `/u02/mongodb/data/<instance_name>`      | MongoDB data files                                                              |
| `/u03/mongodb/journal/<instance_name>`   | MongoDB journal files                                                           |
| `/u04/mongodb/log/<instance_name>`       | MongoDB log files                                                               |
| `/u90/mongodb/backup/<instance_name>`    | MongoDB backups and dumps                                                       |

#### Variables associated with OFA

These variables are located in the `$DMK_HOME/etc/dmk.conf.default` file.

For any of these variable, you can override the default value by using `set_local_dmk_config.py`, for instance:

```bash
mongodb@vm00:/home/mongodb/ [mdb01] set_local_dmk_config.py INSTANCE MONGO_JOURNAL "\${MONGO_DATA_ROOT}/\${MONGO_INSTANCE}/journal"
```

| Variable              | Path                    | Purpose                                                                                                                                                                                              |
| --------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$MONGO_BASE`         | `/u01/app/mongodb`      | Binary files, instance configuration files.                                                                                                                                                          |
| `$MONGO_DATA_ROOT`    | `/u02/mongodb/data/`    | MongoDB data files.                                                                                                                                                                                  |
| `$MONGO_JOURNAL_ROOT` | `/u03/mongodb/journal/` | MongoDB journal files. If you don't want to separate MongoDB journal and data files, set `MONGO_JOURNAL_ROOT` to the same value as `MONGO_DATA_ROOT` with `set_local_dmk_config.py`                  |
| `$MONGO_LOG_ROOT`     | `/u04/mongodb/log/`     | MongoDB instances log files. Default changed in release 2.3.0 from `/u02/mongodblog` to `/u04/mongodb/log`, to separate data and log files. Use `set_local_dmk_config.py` to override this variable. |
| `$MONGO_BACKUP_ROOT`  | `/u90/mongodb/backup`   | MongoDB backups location.                                                                                                                                                                            |

These directory conventions help standardize deployment and maintenance across environments.
