0

I have the following setup:

— Many servers

— One shared network mounted data storage folder

On one of the servers, I need to run MongoDB to write data to it. I want to be able to access those written data from other servers while the one instance is still running. Is it possible to have a read-only-instance of MongoDB that allows this? In all others, I don't need to write anything, just read.

  • 2
    Why not replication then ? You would be able to access data on any of the servers this way. Doesn't look like you need a shared storage. – drookie Dec 19 '18 at 15:23
0

You cannot share a dbPath with multiple active mongod processes - each process requires exclusive access to the data files.

For data redundancy and readonly copies of data, MongoDB supports replica set deployments. A replica set elects a single primary member that accepts writes and can have multiple read-only secondary members. By default all reads and writes are directed to the current primary in a replica set, but your driver or application can use read preferences to read from secondary members. In the event the current primary is unavailable, replica sets also support failover based on your configuration.

However, shared storage is not ideal for a replica set as you will be writing many copies of the same data to the shared storage (which presumably also has some built-in write redundancy).

With or without replication, you should configure MongoDB's Role-Based Access Control (RBAC) so that your applications authenticate with appropriate privileges such as read-only access. The MongoDB Security Checklist has a list of security measures to consider. Even if access is limited to a trusted network, use of RBAC limits your exposure to accidental data modification and provides some audit trail in the MongoDB server logs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.