Nuxeo Server

MongoDB

Updated: March 18, 2024

Document-Based Storage is an architectural abstraction in the Nuxeo Platform that allows the storage of documents in a document-oriented store, for instance NoSQL databases.

An implementation is available for MongoDB.

Nuxeo supports the following MongoDB version:

MongoDB 3.2

Installation

When using MongoDB 3.0 or higher we recommend that you configure the WiredTiger storage engine for better performance of write operations. Please follow this documentation to activate this storage engine.

Nuxeo stores its data in a MongoDB database under the default collection. The name of the collection is the Nuxeo repository name. If you have more than one repository configured, other collections with the names of these repositories will be used for storage.

By default MongoDB doesn't require authentication, but you can enable the client access control and create a user with the dbOwner role.

User Creation with Nuxeo 8.1 and MongoDB 3.x

If you are using a version 3.x of MongoDB on Nuxeo 8.1, you have to change the authentication schema before creating the users in the database. In these MongoDB versions, the default authentication mechanism is SCRAM-SHA-1 which is not supported by Nuxeo 8.1 where the MongoDB driver only supports MONGO-CR.

Note that if you are upgrading from a MongoDB 2.8 databases, you will be fine as the MONGO-CR credentials were previously created.

For new MongoDB instance use the following commands:

mongo
use admin
db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 })

For existing MongoDB instance with users, you need to remove the user first (make sure you don't need them before) then change the authentication schema using the following commands:

mongo
use admin
db.system.users.remove({})
db.system.version.remove({})
db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 })

Then restart the server and recreate users.

Nuxeo Configuration

To activate MongoDB document storage, add the mongodb template to your existing list of templates (nuxeo.templates) in nuxeo.conf.

If you also want to activate audit and directories storage, you need to install the MongoDB extension addon. This addon includes mongodb-audit and mongodb-directory templates in order to store respectively audit or directories data in MongoDB. For example:

 nuxeo.templates=default,mongodb,mongodb-audit,mongodb-directory

If you are not using the MongoDB extension addon, you must keep the template corresponding to your SQL database in nuxeo.templates. For instance you could have:

nuxeo.templates=postgresql,mongodb

or

nuxeo.templates=default,mongodb

The following properties are available in nuxeo.conf:

  • nuxeo.mongodb.server: The MongoDB server, either a hostname or a hostname with port or a full mongodb:// URI if you have an authentication, the pattern is: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] (defaults to localhost:27017)
  • nuxeo.mongodb.dbname: The MongoDB database. (defaults to nuxeo)

Using the full mongodb:// URI syntax you can configure the connection options, like the pool size, the write concern or the read preference, for instance:

nuxeo.mongodb.server=mongodb://example1.com,example2.com,example3.com/?maxPoolSize=200

See the MongoDB Connection String URI Format for the list of options.

GridFS

It is possible to use MongoDB's GridFS mechanism to store binary files inside MongoDB instead of the default filesystem mechanism of Nuxeo. This is activated by adding gridfsbinaries to the templates, for instance:

nuxeo.templates=postgresql,mongodb,gridfsbinaries

When doing this, binaries will be stored in the default.fs GridFS bucket, which means that in native MongoDB the collections default.fs.files and default.fs.chunks will be used. See the GridFS Reference for more details about MongoDB's GridFS implementation.


Related pages in current documentation