標籤:
https://docs.mongodb.org/v3.0/reference/built-in-roles/#dbAdmin
資料庫使用者角色有:readreadWrite
資料庫管理員角色有:dbAdmindbOwner (包含 dbAdmin,readWrite,userAdmin)userAdmin
群集管理員角色有:clusterAdmin (包含 clusterManager,clusterMonitor,hostManager)clusterManagerclusterMonitorhostManager
所有的資料庫角色有:readAnyDatabasereadWriterAnyDatabaseuserAdminAnyDatabasedbAdminAnyDatabase
超級使用者角色root(包含 readWriteAnyDatabase,dbAdminAnyDatabase,userAdminAnyDatabase,clusterAdmin)
內建角色(Built-in Roles)
資料庫角色
read:可以訪問非系統層級的所有collections的資料;也可以讀取 system.indexes system.js system.namespaces 集合中的資料;允許調用下列功能:collStatsdbHashdbStatsfindkillCursorslistIndexeslistCollections
readWrite:可以調用讀所有集合的功能,不能寫系統級的集合除 system.js允許調用下列功能:collStatsconvertToCappedcreateCollectiondbHashdbStatsdropCollectioncreateIndexdropIndexfindemptycappedinsertkillCurrsorslistIndexeslistCollectionsremoverenameCollectionSameDBupdate
資料庫管理員角色
dbAdmin1、可以在 system.indexes, system.namespaces, system.profile 集合上的下列操作:collStatsdbHashdbStatsfindkillCursorslistIndexeslistCollectionsdropCollection and createCollection on system.profile only 2、可以在非系統級集合上調用以下操作:collModcollStatscompactconvertToCappedcreateCollectioncreateIndexdbStatsdropCollectiondropDatabasedropIndexenableProfilerindexStatsreIndexrenameCollectionSameDBrepairDatabasestorageDetailsvalidate 3、dbAdmin角色不可全部訪問系統級集合
userAdmin該資料庫管理員角色 提供 在當前資料庫中 建立、修改 角色和使用者帳號的能力。擁有該角色的使用者可以給其他使用者授予任何許可權(包括userAdmin角色),這樣就會間接導致超級使用者的產生;提供下列功能:changeCustomDatachangePasswordcreateRolecreateUserdropRoledropUsergrantRolerevokeRoleviewRoleviewUser
dbOwner該資料庫管理員角色 具有 readWrite ,dbAdmin userAdmin 的所有角色
叢集(複製集)管理員角色
clusterAdmin該角色包含:clusterManager、clusterMonitor、hostManager和 dropDatabase
clusterManager可以訪問 local 和config 資料庫addShardapplicationMessagecleanupOrphanedflushRouterConfiglistShardsremoveShardreplSetConfigurereplSetGetStatusreplSetStateChangeresyncenableShardingmoveChunksplitChunksplitVector可以對 config 資料庫執行insertremoveupdatecollStatsdbHashfindkillCursors
clusterMonitordb.createUser({user:"mmsUser",pwd:"[email protected]",roles:["clusterMonitor"]}) connPollStatscursorInfogetCmdLineOptsgetLoggetParametergetShardMaphostInfoinproglistDatabaseslisstShardsnetstatreplSetGetStatusserverStatusshardingStatetopcollStatsdbStatsgetShardVersion在sharding的config 上提供collStatsdbHashdbStatsfindkillCursors
hostManagerapplicationMessagecloseAllDatabasesconnPoolSynccpuProfilerdiagLoggingflushRouterConfigfsyncinvalidateUserCachekilloplogRotateresyncsetParametershowdowntouchunlock
所有資料庫角色 All-Database Roles
readAnyDatabase在叢集的所有資料庫上 提供與 read角色相同的許可權 ,同時提供 listDatabases 命令許可權
readWriteAnyDatabase在叢集的所有資料庫上 提供與 readWrite 角色相同的許可權 ,同時提供 listDatabases 命令許可權
userAdminAnyDatabase在叢集中的所有資料庫上 提供和 userAdmin角色相同的許可權,除此外還提供一下許可權authSchemaUpgradeinvalidateUserCachelistDatabases該角色還提供在 admin資料庫的 system.users and system.roles 上下列執行許可權collStatsdbHashdbStatsfindkillCursorsplanCacheReadcreateIndexdropIndex
dbAdminAnyDatabase在叢集的所有資料庫上 提供與 dbAdmin角色相同的許可權 ,同時提供 listDatabases 命令許可權
超級使用者角色 Superuser Roles root
可以運行 rolesInfo 命令來查詢 某個角色在指定的資料庫上具有的詳細許可權
db.runCommand({rolesInfo:{role:"dbAdmin",db:"dbName"}.showPrivileges:true})
亦或
db.runCommand({rolesInfo:[{role:"roleName",db:"dbName01"},{role:"roleName02",db:"dbName02"}],showPrivileges:true})
查看所有使用者自訂角色和系統內建角色
db.runCommand({rolesInfo:1,showBuiltinRoles:true})
查看所有使用者自訂角色
db.runCommand(rolesInfo:1,showPrivileges:true)
mongodb 角色總結