MongoDB

Connecting to MongoDB

Aptible MongoDB Databases require authentication and SSL to connect.

📘

Tip

MongoDB databases use a valid certificate for their host, so you're encouraged to verify the certificate when connecting.

Connecting to the admin database

There are two MongoDB databases you might want to connect to:

  • The admin database.
  • The db database created by Aptible automatically.

The username (aptible) and password for both databases are the same. However, the users in MongoDB are different (i.e. there is a aptible user in the admin database, and a separate aptible user in the db database, which simply happens to have the same password).

This means that if you'd like to connect to the admin database, you need to make sure to select that one as your authentication database when connecting: connecting to db and running use admin will not work.

Clustering

Replica set clustering is available for MongoDB. Replicas can be created using the aptible db:replicate command.

Failover

MongoDB replica sets will automatically fail over between members. In order to do so effectively, MongoDB recommends replica sets have a minimum of three members. This can be done by creating two Aptible replicas of the same primary Database.

The connection URI you provide your Apps with must contain the hostnames and ports of all members in the replica set. MongoDB clients will attempt each host until it's able to reach the replica set. With a single host, if that host is unavailable, the App will not be able to reach the replica set. The hostname and port of each member can be found in the Database's Credentials and the combined connection URI will look something like this for a three member replica set:

mongodb://username:[email protected]:27017,host2.aptible.in:27018,host3.aptible.in:27019/db

Data Integrity and Durability

On Aptible, MongoDB is configured with default settings for journaling. For MongoDB 3.x instances, this means journaling is enabled. If you use the appropriate write concern (j=1) when writing to MongoDB, you are guaranteed that committed transactions were written to disk.

Configuration

Configuration of MongoDB command line options is not supported on Aptible.

MongoDB Databases on Aptible autotune their Wired Tiger cache size based on the size of their container based upon Mongo's recommendation. See the image's public git repo for details.

Connection Security

Aptible MongoDB Databases support connections via the following protocols:

  • For Mongo versions 2.6, 3.4, and 3.6: TLSv1.0, TLSv1.1, TLSv1.2
  • For Mongo version 4.0: TLSv1.1, TLSv1.2