PRIMARY> db.createUser({'user': 'oplogger', pwd: 'PASSWORD', "roles" : [{"role" : "read", "db" : "local"}]})
and then running meteor (on a different machine) like so:
MONGO_OPLOG_URL=mongodb://oplogger:PASSWORD@MONGOHOST/local?authSource=admin MONGO_URL="mongodb://readUser:PASSWORD@MONGOHOST/DBNAME" meteor run
But meteor fails to start with an error "MongoError: not authorized for query on local.system.replset"
I'm at a bit of a loss to know how to debug this. If I log on to MONGOHOST, I can use those credentials to login to the admin database, but not the local one.
Any help or pointers would be most gratefully received
Rachel
mongo -u oplogger --password PASSWORD local --authenticationDatabase admin --host MONGOHOST
Which gets me into the local database, where I can see the oplog.rs
PRIMARY>db.oplog.rs.find()
works fine
But looking more closely at the error message, what meteor is complaining about is not having access to system.replset
PRIMARY>db.system.replset.find()
gives me error: { "$err" : "not authorized for query on local.system.replset", "code" : 13 }
So I wonder whether something has changed been 2.4 and 2.6 to make the addition of extra permissions necessary?
Rachel
db.runCommand({ createRole: "oplogger", privileges: [ { resource: { db: 'local', collection: 'system.replset'}, actions: ['read']}, ], roles: [{role: 'read', db: 'local'}] })
db.runCommand({ grantRolesToUser: 'oplogger', roles: ['oplogger']})
Hope that helps someone in the same boat...
Rachel
# For MongoDB 2.4
rs0:PRIMARY> db.addUser({ user:'oplogger', pwd:'pwd', roles:[], otherDBRoles:{ local: ['read'] } }) # can read everything that is written to the local database.
# For MongoDB 2.6
rs0:PRIMARY> db.createUser({ user:'oplogger', pwd:'pwd', roles:[] })
rs0:PRIMARY> db.runCommand({ createRole: "oplogger", privileges: [ { resource: { db: 'local', collection: 'system.replset'}, actions: ['find']}, ], roles: [{role: 'read', db: 'local'}] })
rs0:PRIMARY> db.runCommand({ grantRolesToUser: 'oplogger', roles: ['oplogger']})
rs0:PRIMARY> show users # you should see the new oplogger user appearAs for roles, the only roles available are the ones that are provisioned on the database for you. We don't support the creation or addition of roles on Compose MongoDB instances.