NoSQL MongoDB

📝 Note

The MongoDB backend is currently in beta.

This implementation uses MongoDB as the persistence backend and leverages the Quarkus MongoDB extension for connection management. Configuration can be done through environment variables or JVM -D flags at startup.

Basic Configurationđź”—

Using environment variables:

1POLARIS_PERSISTENCE_TYPE=nosql
2POLARIS_PERSISTENCE_NOSQL_BACKEND=MongoDb
3QUARKUS_MONGODB_DATABASE=polaris
4QUARKUS_MONGODB_CONNECTION_STRING=mongodb://<username>:<password>@<host>:<port>

Using properties file:

1polaris.persistence.type=nosql
2polaris.persistence.nosql.backend=MongoDb
3quarkus.mongodb.database=polaris
4quarkus.mongodb.connection-string=mongodb://<username>:<password>@<host>:<port>

MongoDB Atlas Configurationđź”—

For MongoDB Atlas deployments, use the mongodb+srv:// connection string format:

1polaris.persistence.type=nosql
2polaris.persistence.nosql.backend=MongoDb
3quarkus.mongodb.database=polaris
4quarkus.mongodb.connection-string=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/?retryWrites=true&w=majority

MongoDB Replica Set Configurationđź”—

For replica set deployments:

1polaris.persistence.type=nosql
2polaris.persistence.nosql.backend=MongoDb
3quarkus.mongodb.database=polaris
4quarkus.mongodb.connection-string=mongodb://<username>:<password>@<host1>:<port1>,<host2>:<port2>,<host3>:<port3>/?replicaSet=<rs-name>&authSource=admin

Advanced MongoDB Configurationđź”—

Additional MongoDB settings can be configured via Quarkus MongoDB properties:

1quarkus.mongodb.connect-timeout=10S
2quarkus.mongodb.read-timeout=30S
3quarkus.mongodb.server-selection-timeout=30S
4quarkus.mongodb.write-concern.safe=true
5quarkus.mongodb.read-preference=primaryPreferred

For TLS/SSL connections, add tls=true to the connection string:

1quarkus.mongodb.connection-string=mongodb://<username>:<password>@<host>:<port>/?tls=true

For more details on available MongoDB configuration options, please refer to the Quarkus MongoDB configuration reference.

Bootstrapping Polarisđź”—

Before using Polaris with the MongoDB backend, you must bootstrap the metastore to create the necessary collections and initial realm. This is done using the Admin Tool.

Using Docker:

1docker run --rm -it \
2  --env="polaris.persistence.type=nosql" \
3  --env="polaris.persistence.nosql.backend=MongoDb" \
4  --env="quarkus.mongodb.database=polaris" \
5  --env="quarkus.mongodb.connection-string=mongodb://<username>:<password>@<host>:<port>" \
6  apache/polaris-admin-tool:latest bootstrap -r <realm-name> -c <realm-name>,<client-id>,<client-secret>

Using the standalone JAR:

1java \
2  -Dpolaris.persistence.type=nosql \
3  -Dpolaris.persistence.nosql.backend=MongoDb \
4  -Dquarkus.mongodb.database=polaris \
5  -Dquarkus.mongodb.connection-string=mongodb://<username>:<password>@<host>:<port> \
6  -jar polaris-admin-tool.jar bootstrap -r <realm-name> -c <realm-name>,<client-id>,<client-secret>

For more details on the bootstrap command and other administrative operations, see the Admin Tool documentation.

Regular maintenanceđź”—

The Polaris NoSQL backend requires regular maintenance to remove stale data from the backend database. The frequency of this maintenance depends on the size of the database and the frequency of data updates. The recommended maintenance frequency is once per day. It is recommended to schedule maintenance during off-peak hours or to set reasonable scan rates to minimize the impact on operational availability. Maintenance can be triggered using the Admin Tool.