MongoDB 安全

2018-01-02 19:16:19来源:CSDN作者:damage_e人点击

分享

安全

  • 开启
    1. auth开启
      在mongod.conf中加入auth = true
      查找mongod服务:ps -ef|grep mongod|grep 12345
      停止mongod服务:kill pid
      创建用户:createUser({user:"<name>",pwd:" ",customData:{"用户说明"},roles:[{role:"<role>",db:"<database>"}]})
      1.角色类型:read,readWrite,dbAdmin,dbOwner,userAdmin
      createUser({user:"testAdmin",pwd:"mongotest",customData:{"testAdmin"},roles:[{role:"userAdmin",db:"admin"},{role:"read",db:"test"}]})
      2.集群角色(clusterAdmin,clusterManager…)
      3.备份角色(backup,restore…)
      4.其他特殊权限(DBAdminAnyDatabase…)
      创建角色:creatRole()
      { _id: "myAPP.appUser,role:"appUser",db:"myApp",
      privileges:[
      {resource :{db:"myApp",collection:" "},actions:["find","createCollection","dbStats","collStats"]}
      {resource :{db:"myApp",collection:"logs"},actions:["insert"]}
      {resource :{db:"myApp",collection:"data"},actions:["insert","update","remove","compact"]}
      {resource :{db:"myApp",collection:"system.indexes"},actions:["find"]}
      {resource :{db:"myApp",collection:"system.namespaces"},actions:["find"]}
      ],roles:[]}
    2. keyfile开启

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台