mongodb - 允许设置分析的 MongoDB 用户角色
问题描述
我正在尝试创建一个用户角色,该角色可以在 MongoDB 上设置分析级别以执行慢速查询检查。
角色:
db.createRole(
{
role: "slow_query_check",
privileges: [
{ resource: { db: "admin", collection: "system.profile"}, actions: [ "enableProfiler" ] },
],
roles: [
{ role: "read", db: "admin" }
]
},
{ w: "majority" , wtimeout: 5000 }
)
然后我正在应用这个角色:
db.grantRolesToUser(
"monitor",
[
{ role: "slow_query_check", db: "admin" },
]
)
但我仍然无法设置例如。db.setProfilingLevel(0) 因为我未经授权。
根据手册: https ://docs.mongodb.com/v4.2/reference/privilege-actions/
enableProfiler是我需要授予的操作,但这不起作用。
有什么帮助吗?
解决方案
推荐阅读
- sockets - 如何将小型 Web 服务器程序连接到 Internet 中另一台设备上运行的 Web 浏览器?
- algorithm - 预测 2 个均匀圆周运动对象之间的碰撞
- python - 如果数据框没有带有名称的列,则将最后一列转换为分类
- python - Python 将电子邮件一一发送给多个收件人
- c++ - 我和我的朋友正在从 UDP 的服务器接收数据包,我能够接收它们,但他不能
- javascript - Google 电子表格 API 在本地工作,但不在 Live Heroku 应用程序上
- c++ - 如何以线程安全的方式使用`std::unordered_map`?
- cluster-computing - 已还原计算机上的 Veritas 集群
- python - How to see posts using functions based view in django?
- r - Is there an R function that allows me to group a list together based off identical characters