简体   繁体   中英

How to enable free monitoring in mongodb if access control is enabled?

I want to enable free monitoring on my MongoDB standalone instance running on AWS. I had performed before enabling access control. After enabling, when I tried

db.enableFreeMonitoring()

it returns following error.

uncaught exception: Error: command failed: { "ok": 0, "errmsg": "not authorized on admin to execute command { setFreeMonitoring: 1.0, action: "enable", lsid: { id: UUID("0483e6c8-4d96-4eae-9967-608838f07f42") }, $db: "admin" }", "code": 13, "codeName": "Unauthorized" }:

As per the documentation, I have granted the admin clusterMonitor role. Still same error. Is there any other way?

I enabled monitoring by giving the user the role root

use admin;
db.grantRolesToUser('admin', [{ role: 'root', db: 'admin' }]);

You may want to think this through before assigning the user with 'root' privileges. I believe dbOwner and adminUser roles could also accomplish the same task, although I have not tried them. Here's the link to the documentation Role-Aased Access Control

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM