MySQL-MongoDB开源监控利器之PMM
admin
2023-01-26 08:22:19
0

    最近要对数据库的监控体系进行改进,发现Percona 公司的一款开源的监控工具Percona Monitoring and Management(PMM) 对于MySQL的监控指标各项值比较全面准确,现在公司内部的开发测试环境进行了部署体验。

    主要的架构图如下:源于官方

MySQL-MongoDB开源监控利器之PMM

    可以看到主要是由客户端的代理程序node_export\mysqld_export\mongodb_export等和客户端管理工具pmm-admin做为数据的收集方式并发送到服务端的QAN API\Consul API\Prometheus等各个API然后通过Grafana来展示数据指标,界面非常靓丽


    Pmm 的server端的运行方式主要有官方提供的以下三种方式:

      1.已经集成好的Docker方式

      2.集成好的VirtualBox方式

      3. Amazon Machine Image (AMI)

     在这里我用的是Docker方式,轻量部署、升级很方便

    PMM的client安装比较方便,直接安装官方的yum安装就OK了


#详细的请参考官方文档

https://www.percona.com/doc/percona-monitoring-and-management/index.html


#Dokcer方式部署

提前准备好系统和Docker服务,安装不在这里展示

1-创建容器的数据磁盘

docker create \
   -v /opt/prometheus/data \
   -v /opt/consul-data \
   -v /var/lib/mysql \
   -v /var/lib/grafana \
   --name pmm-data \
   percona/pmm-server:1.1.1 /bin/true

2-创建容器的运行实例

docker run -d \
   -p 80:80 \
   --volumes-from pmm-data \
   --name pmm-server \
   --restart always \
   percona/pmm-server:1.1.1



#客户端安装

[root@master ~]# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

[root@master ~]# yum install -y pmm-client


#增加客户端mysql监控


[root@master ~]# pmm-admin config  --server 192.168.100.171

OK, PMM server is alive.


PMM Server      | 192.168.100.171 

Client Name     | master.wboy.com

Client Address  | 192.168.100.41 


[root@master ~]# pmm-admin list

pmm-admin 1.1.1


PMM Server      | 192.168.100.171 

Client Name     | master.wboy.com

Client Address  | 192.168.100.41 

Service Manager | unix-systemv


No monitoring registered for this node identified as 'master.wboy.com'.


#命令帮助

[root@master ~]# pmm-admin  add --help

This command is used to add a monitoring service.


Usage:

  pmm-admin add [command]


Available Commands:

  mysql            Add complete monitoring for MySQL instance (linux and mysql metrics, queries).

  linux:metrics    Add this system to metrics monitoring.

  mysql:metrics    Add MySQL instance to metrics monitoring.

  mysql:queries    Add MySQL instance to Query Analytics.

  mongodb          Add complete monitoring for MongoDB instance (linux and mongodb metrics).

  mongodb:metrics  Add MongoDB instance to metrics monitoring.

  proxysql:metrics Add ProxySQL instance to metrics monitoring.


Flags:

      --service-port uint16   service port


Global Flags:

  -c, --config-file string   PMM config file (default "/usr/local/percona/pmm-client/pmm.yml")


Use "pmm-admin add [command] --help" for more information about a command.

[root@master ~]# pmm-admin  add  mysql --help

This command adds the given MySQL instance to system, metrics and queries monitoring.


When adding a MySQL instance, this tool tries to auto-detect the DSN and credentials.

If you want to create a new user to be used for metrics collecting, provide --create-user option. pmm-admin will create

a new user 'pmm@' automatically using the given (auto-detected) MySQL credentials for granting purpose.


Table statistics is automatically disabled when there are more than 10000 tables on MySQL.


[name] is an optional argument, by default it is set to the client name of this PMM client.


Usage:

  pmm-admin add mysql [name] [flags]


Examples:

  pmm-admin add mysql --password abc123

  pmm-admin add mysql --password abc123 --create-user

  pmm-admin add mysql --password abc123 --port 3307 instance3307


Flags:

      --create-user                       create a new MySQL user

      --create-user-maxconn uint16        max user connections for a new user (default 10)

      --create-user-password string       optional password for a new MySQL user

      --defaults-file string              path to my.cnf

      --disable-binlogstats               disable binlog statistics

      --disable-processlist               disable process state metrics

      --disable-tablestats                disable table statistics

      --disable-tablestats-limit uint16   number of tables after which table stats are disabled automatically (default 1000)

      --disable-userstats                 disable user statistics

      --force                             force to create/update MySQL user

      --host string                       MySQL host

      --password string                   MySQL password

      --port string                       MySQL port

      --query-source string               source of SQL queries: auto, slowlog, perfschema (default "auto")

      --socket string                     MySQL socket

      --user string                       MySQL username


Global Flags:

  -c, --config-file string    PMM config file (default "/usr/local/percona/pmm-client/pmm.yml")

      --service-port uint16   service port


#增加本地mysql实例

[root@master ~]# pmm-admin  add  mysql  --user root --password root

[linux:metrics] OK, now monitoring this system.

[mysql:metrics] OK, now monitoring MySQL metrics using DSN root:***@unix(/var/lib/mysql/mysql.sock)

[mysql:queries] OK, now monitoring MySQL queries from slowlog using DSN root:***@unix(/var/lib/mysql/mysql.sock)


安装完成后的访问地址列表:其实在 landing page包含了下面三个功能的页面


各个组件功能访问地址
PMM landing pagehttp://192.168.100.1
Query Analytics (QAN web app)http://192.168.100.1/qan/
Metrics Monitor (Grafana)

http://192.168.100.1/graph/

User name: admin

Password: admin

Orchestratorhttp://192.168.100.1/orchestrator

##

下面是一些截图界面


MySQL-MongoDB开源监控利器之PMM

MySQL-MongoDB开源监控利器之PMM

MySQL-MongoDB开源监控利器之PMM

MySQL-MongoDB开源监控利器之PMM

MySQL-MongoDB开源监控利器之PMM


相关内容

热门资讯

德国总理:美国正在被伊朗羞辱 德国之声4月27日报道,德国总理默茨在访问一所学校时表示,在当前的持续冲突中,伊朗领导层正试图羞辱美...
理响中国|“长”歌以行,风云激... 光阴如梭,东方潮阔。这里是中国的长三角,世界的长三角。无论过去、现在还是未来,这片土地都因时代而生,...
白宫:特朗普及其国安团队开会讨... 新华社华盛顿4月27日电 美国白宫新闻秘书莱维特27日在记者会上证实,总统特朗普及其国家安全团队当天...
人民日报刊文:日本放开杀伤性武... 日本放开杀伤性武器出口推高地缘冲突风险(国际论坛)常思纯《人民日报》(2026年04月28日 第 0...
医疗保障法草案二审:明确生育保... 满足多样化健康保障需求本报记者 彭 波4月27日,医疗保障法草案二审稿提请十四届全国人大常委会第二十...
天津一景区发生自转旋翼机事故1... 澎湃新闻记者 吕新文中国民用航空华北地区管理局4月22日公布《豪客通航“10•1”天津长芦汉盐旅游区...
卡塔尔埃米尔与美国总统特朗普通... 当地时间24日,卡塔尔埃米尔塔米姆与美国总统特朗普通电话,重点就中东地区局势以及伊朗与美国谈判问题交...
男子30年前被扣押2859克黄... 澎湃新闻记者 王鑫家住辽宁省大连市的潘永嘉近日向澎湃新闻反映称,三十年前,他在大连周水子机场被盖州市...
商务部:取消反制欧盟两家金融机... 中华人民共和国商务部令二〇二六年 第1号鉴于欧盟已取消对中国两家金融机构的制裁措施,现公布《关于取消...
过去24小时共有5艘船只通过霍... 总台记者当地时间24日获悉,过去24小时内,共有5艘船只通过霍尔木兹海峡,其中包括一艘伊朗油轮。(总...