mongodb授權使用mongotop

來源:互聯網
上載者:User

標籤:mongod   ram   html   開啟   tab   文檔查看   enc   red   com   

mongodb開啟授權登入後,使用mongotop和mongostat等命令都需要進行相應角色授權。可使用內部角色進行授權,也可自建規則進行授權。此處介紹第二種,即自建規則。

1、切換到admin
use admin
2、建立規則
db.createRole({    role: "mongotopRole",    privileges: [{        resource: { cluster: true },        actions: [ "serverStatus", "top" ]    }],    roles: []})

具體許可權要求,可在官方文檔查看。

Demo (mongotop):

? 連結:https://docs.mongodb.com/manual/reference/program/mongotop/index.html

? 其中Required Access中有提及,包括自建規則,以及符合要求的內建角色。例如:

? In order to connect to a mongod that enforces authorization with the --auth option, you must use the --username and --password options, and the connecting user must have the serverStatus and top privileges.

? The most appropriate built-in role that has these privileges is clusterMonitor.

3、授權角色規則
db.grantRolesToUser(‘cool‘, [{    role: ‘mongotopRole‘,    db: ‘admin‘    }])
4、使用mongotop命令

至此,許可權配置已經完成,可正常使用命令,不過需要附加一些參數,例如:

mongotop -u username -p password --authenticationDatabase=admin

mongtop配置完成,mongostat同樣按以上操作,具體許可權可直接到官方文檔進行搜尋得知。

mongodb授權使用mongotop

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.