Multitenant RTDB: MongoDB

By default, each tenant has a separated database inside the same MongoDB instance/cluster.

For example, suppose we have the vertical Energy, and the tenants sandbox and production. MongoDB server is at realtimedb:27017. The resultant MongoDB URI connection strings of both tenants will be:

  • sandbox → mongodb://realtimedb:27017/onesaitplatform_rtdb_sandbox

  • production → mongodb://realtimedb:27017/onesaitplatform_rtdb_production

 

However, if needed, you can configure dedicated MongoDB instances for each Vertical or Tenant, here’s how.

Currently we only support this functionality over MongoDB, since version 2.0.2-fireball.

Master Configuration for RTDB

First of all, log in as platform_admin (Role PLATFORM_ADMIN), as you’ll need to configure a Master Configuration.

Then go to Multitenancy Administration > Multitenant Configurations.

Now click on the create button, and you’ll be dispatched to the create page.

Select RTDB as configuration type, and give it any description.

Now for the yaml, copy the next template as the base:

 

isolation-level: TENANT #isolation-level: VERTICAL databases: mongodb: map: default: mongodb://localhost:27017/ sandbox: mongodb://localhost:27017/ production: mongodb://localhost:27018/ atlas: mongodb+srv://onesait:onesait@cluster0.wgdjl.gcp.mongodb.net/?retryWrites=true&w=majority #mongodb: #default: localhost:27017 #onesaitplatform: localhost:27017 #data_portal: localhost:27018

The isolation-level can be either TENANT or VERTICAL. If TENANT mode is enabled, then MongoDB server mapping will be done at tenant level. On the other hand, if VERTICAL mode is enabled, then servers will be mapped by vertical.

In the map section of mongodb level, server to tenant/vertical mapping will be configured. The servers must be in the mongodb URI format.

 

Once done, save the configuration, and don’t forget to restart the following services for changes to take place: controlpanel, router, dashboardengine.

Â