1024programmer Java Relevant configuration of mongostat running status monitoring after MongoDB enables authorization

Relevant configuration of mongostat running status monitoring after MongoDB enables authorization

2019 Unicorn Enterprises Recruit Python Engineer Standards with Large Money>>> hot3.png

To monitor the operating status of MongoDB, the commonly used command line commands are mongostat and mongotop. But ,when authorization is turned on,using mongostat is not so smooth,you need to authorize the role to the management account.

Use

mongo --port 27017 -u myUserAdmin -p abc123 --authenticationDatabase admin

After logging in to the terminal&#xff0c ;Use the following command to create a role.

use admin
db.createRole({role: "mongostatRole",privileges: [{ resource: { cluster: true }, actions: [ "serverStatus" ] }],roles: []}
)

Not finished yet,Grant the role to the operating user

db.grantRolesToUser("mongoadmin",
[{role: "mongostatRole",db: "admin"}
])

In this way,admin is assigned the above role,such as As shown in the picture:

Use the following command to execute mongostat.

mongostat --host=192.168.8.234:27017 -u mongoadmin -p mongoadmin --authenticationDatabase=admin

The result is as shown in the figure& #xff1a;

Reference link :

https://docs.mongodb.com/manual/tutorial/manage-users-and-roles/#create-a-role-to-run-mongostat

Redirect: https://my.oschina.net/jiangbianwanghai/blog/811002

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/746488

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索