本篇文章来简要介绍一下MySQL监控利器-PMM的部署过程。
环境:
主机名
IP
功能
系统
数据库版本
pmmclient
192.168.91.34
PMM-client(1.16.0)
RHEL7.4
MySQL5.7.26
pmmserver
192.168.91.35
PMM-server
RHEL7.4
部署:
server端:
[root@pmmserver ~]#yum -y install docker
[root@pmmserver ~]# systemctl start docker
[root@pmmserver ~]# systemctl enable docker
[root@pmmserver ~]# docker pull pmm-server
[root@pmmserver ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/percona/pmm-server latest cc8e60d34a15 7 weeks ago 1.2 GB
[root@pmmserver ~]# docker create -v /u02/monitor/prometheus/data -v /u02/monitor/consul-data -v /u02/monitor/lib/mysql -v /u02/monitor/lib/grafana --name pmm-data docker.io/percona/pmm-server:latest
[root@pmmserver ~]# docker run -d -p 80:80 -p 3000:3000 -p 13306:3306 --volumes-from pmm-data --name pmm-server --restart always docker.io/percona/pmm-server:latest
[root@pmmserver ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
569aaaca23a1 docker.io/percona/pmm-server:latest "/opt/entrypoint.sh" 21 hours ago Up 21 hours 0.0.0.0:80->80/tcp, 0.0.0.0:3000->3000/tcp, 443/tcp, 0.0.0.0:13306->3306/tcp pmm-server
访问server的IP地址就可以访问了(默认用户名密码:admin)
client端(被监控的服务器上)
[root@pmmclient soft]# ll pmm-client-1.16.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 23057592 Dec 18 10:44 pmm-client-1.16.0-1.el6.x86_64.rpm
[root@pmmclient soft]# rpm -ivh pmm-client-1.16.0-1.el6.x86_64.rpm
[root@pmmclient soft]# pmm-admin --version
1.16.0
[root@pmmclient soft]# pmm-admin config --server 192.168.91.35
OK, PMM server is alive.
PMM Server | 192.168.91.35
Client Name | master
Client Address | 192.168.91.34
pmm客户端监控MySQL到pmm服务器
[root@pmmclient soft]# mysql -uroot -pkavl7kAkkle! 建立监控用户
mysql> create user 'pmm_monitor'@'192.168.91.%' identified by 'kavl7kAkkle!';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'pmm_monitor'@'192.168.91.%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@pmmclient soft]# pmm-admin config --server 192.168.91.35
OK, PMM server is alive.
PMM Server | 192.168.91.35
Client Name | master
Client Address | 192.168.91.34
[root@pmmclient soft]# pmm-admin add mysql --user pmm_monitor --password kavl7kAkkle! --host 192.168.91.34 --port 3306
[linux:metrics] OK, already monitoring this system.
[mysql:metrics] OK, now monitoring MySQL metrics using DSN pmm_monitor:***@tcp(192.168.91.34:3306)
[mysql:queries] OK, now monitoring MySQL queries from slowlog using DSN pmm_monitor:***@tcp(192.168.91.34:3306)
此时可以在web页面上查看:
如果对PMM有兴趣的朋友可以加博主QQ,大家相互学习相互成长。
QQ:1127000483