MongoDB Authorization to use Mongotop

Source: Internet
Author: User

After MongoDB opens the authorization login, the use of commands such as Mongotop and Mongostat requires the appropriate role authorization. You can use an internal role for authorization, or you can customize the rules for authorization. The second, self-built rules are described here.

1. Switch to admin
use admin
2. Create rules
db.createRole({    role: "mongotopRole",    privileges: [{        resource: { cluster: true },        actions: [ "serverStatus", "top" ]    }],    roles: []})

Specific permission requirements can be viewed in the official documentation.

Demo (mongotop):

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

? There are mentions in required access, including self-built rules, and built-in roles that meet the requirements. For example:

? In order to connect to a Mongod this enforces authorization with the--auth option, you must use the--username and--pass Word options, and the connecting user must have the serverstatus and top privileges.

? The most appropriate built-in role, which has these privileges is clustermonitor.

3. Authorization Role Rules
db.grantRolesToUser(‘cool‘, [{    role: ‘mongotopRole‘,    db: ‘admin‘    }])
4. Using the Mongotop command

At this point, the permissions configuration has been completed, the command can be used normally, but some parameters need to be attached, for example:

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

Mongtop configuration is complete, Mongostat also according to the above operation, specific permissions can be directly to the official document search to know.

MongoDB Authorization to use Mongotop

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.