Search code examples
mongodbmongodb-mms

How to access to oplog MongoDB (MMS replica set)


I have a MongoDB replica set with MMS. I created a user with all privileges (all available on MMS) but I can't access to the local db and/or oplog colecction. TRACE:

mydatabse-r1:PRIMARY> use local
switched to db local
mydatabse-r1:PRIMARY> db.oplog.rs.find().pretty();
error: { "$err" : "not authorized for query on local.oplog.rs", "code" : 13 }

I need connect my Meteor app and another apps with Node.js to the oplog but I cannot access it.

Why? Because I'm working on a script with Node.js to create a queue based on the oplog. This is possible, I tested on MongoHQ and MongoLab successfully, but now I need run this in my MMS production replica set with MMS without create a custom MongoDB replica set.


Solution

  • Check this link

    Basically, from mongo 2.6 you need to create a user and grant access to the oplog (as well as accessing the DB using the right credentials)

    Something like:

    db.runCommand({ createRole: "oplogger", 
                   privileges: [{ resource: { db: 'local', collection: 'oplog.rs'},
                                   actions: ['find']}, ],
                   roles: [{role: 'read', db: 'local'}] })
    

    Full procedure here