MongoDB Enterprise HA

Page last updated:

Integrating the Service With Your App

After the creation of the service and the binding of the service to the application, the environment variable VCAP_SERVICES is created. Information about the credentials are stored in this variable as shown here:

{
  "mongodbent": [
   {
    "credentials": {
     "database": "rs_a2215d2a-5b5d-0909-8d74-532982b72693",
     "database_uri": "mongodb://3RlgLecirkFZxOxI:JYmPwXizSsyspGl0@a2215d2a-5b5d-4501-8d74-532982b72693-0.service.consul:33694,a2215d2a-5b5d-4501-8d74-532982b72693-1.service.consul:33694,a2215d2a-5b5d-4501-8d74-532982b72693-2.service.consul:33694/rs_a2215d2a-5b5d-4501-8d74-532982b72693?replicaSet=rs_a2215d2a-5b5d-4501-8d74-532982b72693",
     "host": "a2215d2a-5b5d-4501-8d74-532982b72693-0.service.consul,a2215d2a-5b5d-4501-8d74-532982b72693-1.service.consul,a2215d2a-5b5d-4501-8d74-532982b72693-2.service.consul",
     "ops_manager_password": "i7r240A3cTQkVMRdw7P4HCWirA2E2xzL!1aA",
     "ops_manager_url": "http://opsmanager.service.consul:8080",
     "ops_manager_user": "llYlttVLBe9T7lmL",
     "password": "JYmPwXizSsyspGl0",
     "port": "33694",
     "replica_set": "rs_a2215d2a-5b5d-4501-8d74-532982b72693",
     "uri": "mongodb://3RlgLecirkFZxOxI:JYmPwXizSsyspGl0@a2215d2a-5b5d-4501-8d74-532982b72693-0.service.consul:33694,a2215d2a-5b5d-4501-8d74-532982b72693-1.service.consul:33694,a2215d2a-5b5d-4501-8d74-532982b72693-2.service.consul:33694/rs_a2215d2a-5b5d-4501-8d74-532982b72693?replicaSet=rs_a2215d2a-5b5d-4501-8d74-532982b72693",
     "username": "3RlgLecirkFZxOxI"
    },
    "label": "mongodbent",
    "name": "mongoentluk",
    "plan": "small3rs",
    "provider": null,
    "syslog_drain_url": null,
    "tags": []
   }
  ]
}

Administrating Your MongoDB Enterprise Instances

To connect to a running MongoDB Enterprise instance with your local development tools, you can use the cf ssh feature of the cf CLI.

Sample Application

Cloud Foundry: Spring Music Example

Version Upgrade and Feature Compatibility

New versions of MongoDB Enterprise will be announced in the newsletter as soon as they are available.

The upgrade to the new version is done through the CF CLI by running the update service command. This command will always upgrade the binaries to the lastest available version. To ensure the compatibility with your application MongoDB provides a feature flag for breaking changes which is called “featureCompatibilityVersion”.

cf update-service <service-name> -c '{"featureCompatibilityVersion":"X.Y"}'

You can either upgrade the service to the new version without changing the feature compatibility or upgrade both.

Example:

Assume you have a MongoDB Enterprise with version 3.4.x called my-mongodb-enterprise

To upgrade to the MongoDB Enterprise 3.6.x binaries without enabling the new features (keep featureCompatibility at 3.4) you must run the following command:

cf update-service my-mongodb-enterprise -c '{"featureCompatibilityVersion":"3.4"}'

To upgrade both the MongoDB Enteprise binaries (if not already done) and the feature set to version 3.6, you must run the following command:

cf update-service my-mongodb-enterprise -c '{"featureCompatibilityVersion":"3.6"}'

MongoDB Ops Manager

As a MongoDB Enterprise customer, you receive access to the Ops Manager to see detailed performance metrics and health state.

To connect to the Ops Manager to get insights into your MongoDB, you can use the cf ssh feature of the cf CLI.

Specifications

Our MongoDB Enterprise offering consists of 3 dedicated VMs configured as a replicaset.

Ops Manager Host Mappings

There is a known bug regarding host mappings. When the deployment overview shows incorrect information, you need to delete the host mappings on http://opsmanager.service.consul:8080/v2/$GROUP_ID#deployment/hostMappingTab. Please replace $GROUP_ID with your actual group ID.

Overview hosts mappings Delete host mapping

Roles

On the MongoDB replicaset you will receive the role readWrite@rs_DBNAME.

On the MongoDB Ops Manager you will receive the role Monitoring Admin.

Best Practices for Developers

  • Write concern majority

Please read Replica Set Read and Write Semantics. We recommend a “Write Concern” of majority to avoid Rollbacks During Replica Set Failover.

  • Check Ops Manager metrics regularly

Please check your Ops Manager metrics and graphs regularly. The performance statistics are particularly important after app deployments.

  • Use an application driver maintained by the MongoDB team

It’s critical to find a driver that is well-maintained and stays up to date with the latest MongoDB features.

  • Index early and often

Without question, the most common database performance issue is improper indexing (or a complete lack thereof). Have a look at Indexes docs.

  • Consider a query timeout

MongoDB targets operations for termination if the associated cursor exceeds its allotted time limit. See cursor.maxTimeMS() for more details.

View the source for this page in GitHub