设为首页 收藏本站
查看: 947|回复: 0

[经验分享] MongoDB用户及权限管理(一):角色说明

[复制链接]

尚未签到

发表于 2018-10-25 09:57:04 | 显示全部楼层 |阅读模式
  mongodb安装完后默认是不开启auth模块的,普通用户和超级管理员均不通过认证就可操作。当然裸奔有风险,安全起见还是开启auth模块。
  首先需要了解下面几点:
  1、mongodb是没有默认管理员账号,所以要先添加管理员账号,然后开启权限认证。
  2、切换到admin数据库,添加的账号才是管理员账号。
  3、用户只能在用户所在数据库登录,包括管理员账号。
  4、管理员可以管理所有数据库,但是不能直接管理其他数据库,要先在admin数据库认证后才可以。这一点比较怪。
  1.用户权限角色说明
  1.1  Database User Roles

  •   read
  允许用户读取指定数据库
  Provides the ability to read data on allnon-system collections and on the following system collections: system.indexes,system.js, and system.namespaces collections.
  拥有如下权限:
  aggregate,checkShardingIndex,cloneCollectionAsCapped,collStats
  count,dataSize,dbHash,dbStats,distinct,filemd5
  geoNear,geoSearch,geoWalk,group
  mapReduce (inline output only.),text (beta  feature.)

  •   readWrite
  允许用户读写指定数据库
  Provides all the privileges of the readrole and the ability to modify data on all non-system collections and thesystem.js collection.
  除了具有read权限,还拥有以下权限:
  cloneCollection (as the target  database.),convertToCapped
  create (and to create collections implicitly.)
  drop(),dropIndexes,emptycapped,ensureIndex()
  findAndModify,mapReduce (output to a collection.)
  renameCollection (within the same database.)
  read和readWrite只要就是对库中表的操作权限
  1.2 Database Administration Roles

  •   dbAdmin
  允许用户在指定数据库中执行管理函数,如索引创建、删除,查看统计或访问system.profile
  Provides the ability to performadministrative tasks such as schema-related tasks, indexing, gatheringstatistics. This role does not grant privileges for user and role management.
  拥有如下权限:
  clean,collMod,collStats,compact,convertToCapped
  create,db.createCollection(),dbStats,drop(),dropIndexes,ensureIndex()
  indexStats,profile,reIndex,renameCollection  (within a single database.),validate

  •   dbOwner
  Provides the ability to perform anyadministrative action on the database. This role combines the privilegesgranted by the readWrite, dbAdmin and userAdmin roles.

  •   userAdmin
  允许用户向system.users集合写入,可以找指定数据库里创建、删除和管理用户
  Provides the ability to create and modifyroles and users on the current database. Since the userAdmin role allows usersto grant any privilege to any user, including themselves, the role alsoindirectly provides superuser access to either the database or, if scoped tothe admin database, the cluster.
  1.3 Cluster Administration Roles

  •   clusterAdmin
  只在admin数据库中可用,赋予用户所有分片和复制集相关函数的管理权限。
  Provides the greatest cluster-managementaccess. This role combines the privileges granted by the clusterManager,clusterMonitor, and hostManager roles. Additionally, the role provides thedropDatabase action.
  拥有如下权限:
  addShard,closeAllDatabases,connPoolStats,connPoolSync,_cpuProfilerStart
  _cpuProfilerStop,cursorInfo,diagLogging,dropDatabase
  enableSharding,flushRouterConfig,fsync,db.fsyncUnlock()
  getCmdLineOpts,getLog,getParameter,getShardMap,getShardVersion
  hostInfo,db.currentOp(),db.killOp(),listDatabases,listShards
  logRotate,moveChunk,movePrimary,netstat,removeShard,unsetSharding
  repairDatabase,replSetFreeze,replSetGetStatus,replSetInitiate
  replSetMaintenance,replSetReconfig,replSetStepDown,replSetSyncFrom
  resync,serverStatus,setParameter,setShardVersion,shardCollection
  shardingState,shutdown,splitChunk,splitVector,split,top,touch

  •   clusterManager
  Provides management and monitoring actionson the cluster. A user with this role can access the config and localdatabases, which are used in sharding and replication, respectively.

  •   clusterMonitor
  Provides read-only access to monitoringtools, such as the MongoDB Cloud Manager and Ops Manager monitoring agent.

  •   hostManager
  Provides the ability to monitor and manageservers.
  1.4 Backup and Restoration Roles

  •   backup
  Provides privileges needed to back up data.This role provides sufficient privileges to use the MongoDB Cloud Managerbackup agent, Ops Manager backup agent, or to use mongodump.

  •   restore
  Provides privileges needed to restore datawith mongorestore without the --oplogReplay option or without system.profilecollection data.
  1.5 All-Database Roles

  •   readAnyDatabase
  只在admin数据库中可用,赋予用户所有数据库的读权限
  Provides the same read-only permissions asread, except it applies to all but the local and config databases in thecluster. The role also provides the listDatabases action on the cluster as awhole.

  •   readWriteAnyDatabase
  只在admin数据库中可用,赋予用户所有数据库的读写权限
  Provides the same read and writepermissions as readWrite, except it applies to all but the local and configdatabases in the cluster. The role also provides the listDatabases action onthe cluster as a whole.

  •   userAdminAnyDatabase
  只在admin数据库中可用,赋予用户所有数据库的userAdmin权限
  Provides the same access to useradministration operations as userAdmin, except it applies to all but the localand config databases in the cluster.
  Since the userAdminAnyDatabase role allowsusers to grant any privilege to any user, including themselves, the role alsoindirectly provides superuser access.

  •   dbAdminAnyDatabase
  只在admin数据库中可用,赋予用户所有数据库的dbAdmin权限。
  Provides the same access to databaseadministration operations as dbAdmin, except it applies to all but the localand config databases in the cluster. The role also provides the listDatabasesaction on the cluster as a whole.
  1.6 Superuser Roles

  •   root
  只在admin数据库中可用。超级账号,超级权限
  Provides access to the operations and allthe resources of the readWriteAnyDatabase, dbAdminAnyDatabase,userAdminAnyDatabase, clusterAdmin, restore, and backup combined.
  具体权限可参见:
  https://docs.mongodb.com/manual/reference/built-in-roles/#read


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-626209-1-1.html 上篇帖子: 记一次MongoDB CPU飙升至99%问题的解决 下篇帖子: MongoDB用户及权限管理(二):用户管理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表