1

I want to migrate from one cluster to another. So I'm goint go make a backup with mongodump and mongorestore. Db is not so big, so I would like to disable writes on source db before the start to exclude accidental writes from apps.

What would be the best way to do this?

2

There are two similar options available, based on user permissions.

  1. For the user which your application uses to connect to the DB (let's call it applicationConnUser), change its permissions: for example if it currently has the readWrite role, revoke that and grant the read role instead.
  2. Set up a different user - leave applicationConUser unchanged and create a new account applicationConUserReadOnly to which you grant the read role - and reconfigure your application to connect with this account instead.

Note that your application may not react helpfully when its normal operations cannot write to the database; depending on how it is coded, it may crash out as soon as it gets a db error.

  • Thanks for the answer. Is it possible to change permissions remotely via cli? – WHITECOLOR Jun 14 '18 at 12:48
  • Yes, all the commands to do with granting and revoking roles can be executed through the command-line mongo shell. – Vince Bowdren Jun 14 '18 at 14:54

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.