PMM2监控MongoDB分片集群
2022-01-15 21:47 abce 阅读(341) 评论(0) 编辑 收藏 举报1.注册节点到pmm
1 | pmm-admin config --server-insecure-tls --server-url=https: //admin :admin@X.X.X.X:443 --node-address=被监控节点ip --node- type =generic --node-name=被监控节点的名称 |
2.创建数据库用户
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | db.getSiblingDB( "admin" ).createRole({ role: "explainRole" , privileges: [{ resource: { db: "" , collection: "" }, actions: [ "listIndexes" , "listCollections" , "dbStats" , "dbHash" , "collStats" , "find" ] }], roles:[] }) db.getSiblingDB( "admin" ).createUser({ user: "pmm_mongodb" , pwd : "password" , roles: [ { role: "explainRole" , db: "admin" }, { role: "clusterMonitor" , db: "admin" }, { role: "read" , db: "local" } ] }) |
如果想使用PMM Query Analytics,需要开启profiling feature,默认是不开启,因为会影响性能。
3.开启profiling功能
这一步是可选项。
·在实例级别启动profiler
1 | mongod <other options> --profile 2 --slowms 200 --rateLimit 100 |
或者配置在配置文件中
1 2 3 4 5 | operationProfiling: mode: all slowOpThresholdMs: 200 # (Below variable is available only with Percona Server for MongoDB.) rateLimit: 100 |
·在DB级别开启profiler
1 2 | use dbname db.setProfilingLevel(2) |
4.添加mongodb实例
1 | pmm-admin add mongodb --username=pmm_mongodb --password=password --query- source =profiler --cluster=mycluster --service-name=myc_mongoc2 --host=127.0.0.1 --port=27017 |
5.查看
1 2 3 4 5 6 7 8 9 | $ sudo pmm-admin list Service type Service name Address and port Service ID MongoDB myc_mongoc2 127.0.0.1:37061 /service_id/02e261a1-e8e0-4eb4-8043-8616424500de Agent type Status Metrics Mode Agent ID Service ID pmm_agent Connected /agent_id/281b4046-4f4b-4897-bd2e-b771d3e97922 node_exporter Running push /agent_id/5e9b17a8-ecb9-47c3-8477-ce322047c4d9 mongodb_exporter Running push /agent_id/0067dd85-9a0a-47dd-976e-ae779deb982b /service_id/5c92f132-3005-45ab-84df-7541c286c34a mongodb_profiler_agent Running /agent_id/18d3d87a-9bb9-48c1-8e3e-d8bae3f043bb /service_id/02e261a1-e8e0-4eb4-8043-8616424500de |
#########################################
考虑到密码的问题,可以做一下密码隐藏
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | cat <<EOF > /home/ .pmm-admin-config.conf --server-insecure-tls --server-url=https://admin:admin@X.X.X.X:443 --node-address=被监控节点ip --node-type=generic --node-name=被监控节点的名称 EOF cat <<EOF >/home/.pmm-admin-mysql.conf --username=pmm_mongodb --password=password --query-source=profiler --cluster=mycluster --service-name=xxxx --host=127.0.0.1 --port=27017 EOF |
1 2 | pmm-admin config @ /home/ .pmm-admin-config.conf pmm-admin add mongodb @ /home/ .pmm-admin-mongodb.conf |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
2021-01-15 Inner join和Outer join一起使用的注意点
2018-01-15 mysqlcheck与myisamchk的区别