【MySQL】通过Percona Monitoring and Management实现数据库的监控

[root@wallet01 ~]# yum install -y docker
[root@wallet01 ~]# systemctl start docker
[root@wallet01 ~]# systemctl status docker
[root@wallet01 ~]# wget https://downloads.percona.com/downloads/pmm2/2.18.0/docker/pmm-server-2.18.0.docker
[root@wallet01 ~]# wget https://downloads.percona.com/downloads/pmm2/2.18.0/docker/pmm-server-2.18.0.sha256sum
[root@wallet01 ~]# shasum -ca 256 pmm-server-2.18.0.sha256sum
pmm-server-2.18.0.docker: OK

[root@wallet01 ~]# docker load -i pmm-server-2.18.0.docker
174f56854903: Loading layer [>] 211.7 MB/211.7 MB
47a701705911: Loading layer [
>] 1.695 GB/1.695 GB
Loaded image: percona/pmm-server:2.18.0

[root@wallet01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
percona/pmm-server 2.18.0 2e017837f6be 17 hours ago 1.87 GB

[root@wallet01 ~]# docker create --volume /srv
–name pmm-data percona/pmm-server:2.18.0 /bin/true
1544353947fde465491006f94d71290703670e3f62c1bc60a036c04eb550556d

[root@wallet01 ~]# docker run
–detach
–restart always
–publish 443:443
–volumes-from pmm-data
–name pmm-server
percona/pmm-server:2.18.0
9425b65fc9f0156d79d06324a80e894ee3ff751174c89e34da66c4720501d111

[root@wallet01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9425b65fc9f0 percona/pmm-server:2.18.0 “/opt/entrypoint.sh” 22 seconds ago Up 20 seconds (healthy) 80/tcp, 0.0.0.0:443->443/tcp pmm-server

[root@wallet02 ~]# mysql -uroot -pabcd.1234
mysql> create user ‘pmm’@‘localhost’ identified by ‘pmm@2020’ with max_user_connections 10;
Query OK, 0 rows affected (0.05 sec)

mysql> grant select, process, super, replication client, reload on . to ‘pmm’@‘localhost’;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

mysql> show grants for pmm@localhost;
±-------------------------------------------------------------------------------------+
| Grants for pmm@localhost |
±-------------------------------------------------------------------------------------+
| GRANT SELECT, RELOAD, PROCESS, SUPER, REPLICATION CLIENT ON . TO ‘pmm’@‘localhost’ |
±-------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

[root@wallet02 ~]# wget https://downloads.percona.com/downloads/pmm2/2.18.0/binary/redhat/7/x86_64/pmm2-client-2.18.0-6.el7.x86_64.rpm
[root@wallet02 ~]# rpm -ivh pmm2-client-2.18.0-6.el7.x86_64.rpm
[root@wallet02 ~]# pmm-admin config --server-insecure-tls --server-url=https://admin:abcd.1234@192.168.40.31:443 192.168.40.32 generic mysql_4032
Checking local pmm-agent status…
pmm-agent is running.
Registering pmm-agent on PMM Server…
Registered.
Configuration file /usr/local/percona/pmm2/config/pmm-agent.yaml updated.
Reloading pmm-agent configuration…
Configuration reloaded.
Checking local pmm-agent status…
pmm-agent is running.

[root@wallet02 ~]# pmm-admin add mysql --query-source=perfschema --username=pmm --password=pmm@2020 --service-name=mysql_4032 --host=localhost --port=3306
MySQL Service added.
Service ID : /service_id/3a1c26f8-946e-4e21-9cae-9a9b9ff9179e
Service name: mysql_4032

Table statistics collection enabled (the limit is 1000, the actual table count is 599).

[root@wallet02 ~]# pmm-admin list
Service type Service name Address and port Service ID
MySQL mysql_4032 localhost:3306 /service_id/3a1c26f8-946e-4e21-9cae-9a9b9ff9179e

Agent type Status Metrics Mode Agent ID Service ID
pmm_agent Connected /agent_id/aeec83ac-0405-453f-8ff9-71220689fb7b
node_exporter Running push /agent_id/61828592-421b-4018-82ca-331e74b81b19
mysqld_exporter Running push /agent_id/f942c777-ac9a-4a4f-a753-9dbc76fcf85c /service_id/3a1c26f8-946e-4e21-9cae-9a9b9ff9179e
mysql_perfschema_agent Running /agent_id/9352c7ec-11af-4c85-9c25-a23aef8f5a4e /service_id/3a1c26f8-946e-4e21-9cae-9a9b9ff9179e
vmagent Running push /agent_id/37f3e3f7-40fd-47d8-b756-c75332bb2ed0

[root@wallet02 ~www.meimeitu8.com]# pmm-admin status
Agent ID: /agent_id/aeec83ac-0405-453f-8ff9-71220689fb7b
Node ID : /node_id/60c78880-ae63-4932-b946-773f4f703bf6

PMM Server:
URL : https://192.168.40.31:443/
Version: 2.18.0

PMM Client:
Connected : true
Time drift : 78.878533ms
Latency : 430.453μs
pmm-admin version: 2.18.0
pmm-agent version: 2.18.0
Agents:
/agent_id/37f3e3f7-40fd-47d8-b756-c75332bb2ed0 vmagent Running
/agent_id/61828592-421b-4018-82ca-331e74b81b19 node_exporter Running
/agent_id/9352c7ec-11af-4c85-9c25-a23aef8f5a4e mysql_perfschema_agent Running
/agent_id/f942c777-ac9a-4a4f-a753-9dbc76fcf85c mysqld_exporter Running

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值