MongoDB Configuration
tiCrypt backend services use MongoDB as their database. Five of the ten services store data: ticrypt-auth, ticrypt-file-manager, ticrypt-vm, ticrypt-batch, and ticrypt-notifications. Each connects to its own database within the MongoDB instance. The other five keep no database.
MongoDB installation and replica set initialization are handled by the Ansible playbook. See the Installation Guide for setup instructions.
Connection Configuration
Each service's mongodb section defines how it connects to MongoDB. See the shared mongodb section in Service Configuration for the full parameter reference.
Configure the connection with individual parameters:
mongodb {
database = "ticrypt-auth"
hostname = "localhost"
port = 27017
user = "ticrypt"
password = "your-password"
}
Or with a single URI:
mongodb {
uri = "mongodb://ticrypt:your-password@localhost:27017/ticrypt-auth"
}
Do not specify both the uri and individual connection parameters (hostname, port, user, password). Use one method or the other.
Indexes
From backend 3.16.5, ticrypt-auth, ticrypt-file-manager and ticrypt-vm create the indexes they need when they start, in the background, so running the scripts/index_*.js scripts is no longer needed. Indexes that already exist are left alone. On a large database, the first start after upgrading can take a while to build indexes that were never created.
One of these indexes, email_ci_unique, makes login IDs unique ignoring case. It cannot be created while two users have login IDs that differ only by case. The service still starts, and its log reads Could not create index email_ci_unique on users. To fix it:
-
Find the pairs with the
aggregatequery inscripts/index_auth.js:db.users.aggregate([{$group: {_id: {$toLower: "$email"}, n: {$sum: 1}, ids: {$push: "$_id"}}},{$match: {n: {$gt: 1}}}]) -
Rename the login ID of one user in each pair.
-
Restart
ticrypt-auth. The index is created at that start.
Replication Requirements
tiCrypt versions prior to 3.2.0 require a MongoDB replica set for transaction support. The replica set name is configurable and is set in /etc/mongod.conf:
replication:
replSetName: ticrypt
A single-node replica set is sufficient for testing. Use a minimum 3-node replica set for production deployments.