MongoDB Settings in the Boxfile

Last Updated October 2014

The Boxfile is a yaml config file that allows you to custom-configure your app's environment. Settings typically set in mongod, mongos, or your MongoDB config file are handled here. The following configuration options available in the Boxfile allow you to tailor-fit the build of your MongoDB service specific to your needs. After reading this, you should understand how to:

  • How to customize your MongoDB build
  • Bask in the awesomeness of MongoDB and Pagoda Box

Overview of MongoDB Boxfile Settings YAML

  database1:
    type: mongodb
    version: 3.0
    stability: production
    topology: single
    mongodb_diaglog: 0
    mongodb_objcheck: true
    mongodb_log_verbosity: 'v'
    mongodb_directoryperdb: true
    mongodb_logappend: true
    mongodb_nojournal: false
    mongodb_noscripting: false
/Boxfile

MongoDB Configuration Options

MongoDB Type & Version

When configuring a MongoDB service in your Boxfile, you must define the type of the service as mongodb. You can also specify the version of MongoDB to load into your database service. The following version(s) are available:

  • 2.6

  • 3.0

The specific patch level is determined by the "stability" config.

MongoDB Version Defined on Create

Due to version compatibility constraints, MongoDB versions cannot be changed after the service is created. To use a different version, you'll have to create a new MongoDB service and manually migrate data.

mongodb type & version YAML

  # default setting
  database1:
    type: mongodb
    version: 3.0
/Boxfile
Topology

Topology defines the service's architecture and in what ways it can scale. MongoDB supports the following topologies:

  • Single

  • Redundant

More information can be found in the Service Topologies doc.

topology YAML

  #default setting
  database1:
    type: mongodb
    topology: single
/Boxfile
Diaglog

View the MongoDB documentation for details and configuration options.

mongodb_diaglog YAML

  #default setting
  database1:
    mongodb_diaglog: 0
/Boxfile
ObjCheck

View the MongoDB documentation for details and configuration options.

mongodb_objcheck YAML

  #default setting
  database1:
    mongodb_objcheck: true
/Boxfile
Log Verbosity

View the MongoDB documentation for details and configuration options.

mongodb_log_verbosity YAML

  database1:
    mongodb_log_verbosity: 'v'
/Boxfile
DirectoryPerDB

View the MongoDB documentation for details and configuration options.

mongodb_directoryperdb YAML

  #default setting
  database1:
    mongodb_directoryperdb: true
/Boxfile
LogAppend

View the MongoDB documentation for details and configuration options.

mongodb_logappend YAML

  #default setting
  database1:
    mongodb_logappend: true
/Boxfile
NoJournal

View the MongoDB documentation for details and configuration options.

mongodb_nojournal YAML

  #default setting
  database1:
    mongodb_nojournal: false
/Boxfile
NoScripting

View the MongoDB documentation for details and configuration options.

mongodb_noscripting YAML

  #default setting
  database1:
    mongodb_noscripting: false
/Boxfile

Boxfile Modifications Only Take Affect After a New Build

Whenever changes are made to a MongoDB service's configuration in the Boxfile, those changes will not apply until the service is rebuilt. By default, MongoDB services are not rebuilt on deploy. However, there are three options for rebuilding your service:

Enable Rebuild on Deploy

In your app dashboard, under Dev Config > Code Deployment, you can enable the option to have data services rebuild on deploy whenever changes to the service's Boxfile config are detected.

Rebuilding data services on deploy will increase deploy times, but only when changes to the service's config are detected.

Scale

Any time you scale a MongoDB Service, a new instance or instances are provisioned, data is migrated, requests are routed to the new instance(s) and old instances decommissioned. The new instances are built using the modified settings in your Boxfile.

Repair

In your dashboard, click on your MongoDB service to expand it's options. Each data service has a "Repair" option.

"Repairing" your service will provision a new instance (or instances) based on the settings in your Boxfile, migrate data to the new instances, then reroute requests away from the old instance to the new.

MongoDB Will be Unavailable During a Rebuild

Data migrations are required during a rebuild. MongoDB does not support live migrations, so your MongoDB service will be temporarily unavailable as data is migrated from the old instance to the new.

If you have any questions, suggestions, or corrections, let us know.