pmm部署监控mysql数据库

详细的部署信息请参考官方文档:

创新互联是一家专注于成都网站设计、网站建设与策划设计,钟山网站建设哪家好?创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:钟山等地区。钟山做网站价格咨询:028-86922220

https://www.percona.com/doc/percona-monitoring-and-management/deploy/server/docker.setting-up.html#pmm-server-docker-image-pulling

一、server端部署:
1.监控机器安装docker:
ip:192.168.56.101
操作系统版本:
[root@my-mm ~]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)
安装:
yum install -y docker

启动:
systemctl start docker
systemctl enable docker


2.拉取PMM服务器映像:
docker pull percona/pmm-server:latest

[root@my-mm ~]# docker pull percona/pmm-server:latest
Trying to pull repository docker.io/percona/pmm-server ...
latest: Pulling from docker.io/percona/pmm-server
aeb7866da422: Pull complete
904d1ed4e1e3: Pull complete
Digest: sha256:5eb0fe89d2e93198e7070e92f22cdd95fcef5db257f70a3e05071685f2503a56
Status: Downloaded newer image for docker.io/percona/pmm-server:latest


3.创建一个PMM数据容器:

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

[root@my-mm ~]# docker create \
>    -v /opt/prometheus/data \
>    -v /opt/consul-data \
>    -v /var/lib/mysql \
>    -v /var/lib/grafana \
>    --name pmm-data \
>    percona/pmm-server:latest /bin/true
8448b22b99f7d667f6bfa9dcc78a4e662aed57a4d36473061d2533afa6c3e515

  
4.创建和运行 PMM Server Container:
docker run -d -p 80:80 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:latest

[root@my-mm ~]# docker run -d -p 80:80 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:latest
56372ece726b9e61f29d2f0dd1e72a5353237015997f2e7637a7164b05f38727


检查docker状态:
[root@my-mm ~]# docker ps
CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS              PORTS                         NAMES
56372ece726b        percona/pmm-server:latest   "/opt/entrypoint.sh"   28 seconds ago      Up 27 seconds       0.0.0.0:80->80/tcp, 443/tcp   pmm-server

5.登录:
http://192.168.56.101
默认登录信息如下,可以自行修改:
username:admin   password:admin

pmm 部署监控mysql数据库

登录界面:

pmm 部署监控mysql数据库

二、客户端部署:
6.客户端部署软件,在需要被监控MySQL服务端安装pmm-client:
客户端信息(192.168.56.102)
添加yum源(或者下载安装包):
rpm -ivh https://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-6.noarch.rpm
安装pmm-client:
yum install pmm-client –y

卸载软件:
yum remove pmm-client -y

6.添加监控:
客户端连接pmm server,配置监控服务器:
pmm-admin config --server 192.168.56.101

添加操作系统监控:
[root@my2 ~]# pmm-admin add linux:metrics
OK, now monitoring this system.

在需要监控的数据库上面创建用户:
GRANT ALL PRIVILEGES ON  *.* TO 'pmm-monitor'@'%' IDENTIFIED BY 'pmm-monitor';
flush privileges;

添加mysql监控:
pmm-admin add mysql --user pmm-monitor --password pmm-monitor --host 192.168.56.102 --port 3306

[root@my2 ~]# pmm-admin add mysql --user pmm-monitor --password pmm-monitor --host 192.168.56.102 --port 3306
[linux:metrics] OK, already monitoring this system.
[mysql:metrics] OK, now monitoring MySQL metrics using DSN pmm-monitor:***@tcp(192.168.56.102:3306)
[mysql:queries] OK, now monitoring MySQL queries from slowlog using DSN pmm-monitor:***@tcp(192.168.56.102:3306)

web页面查看添加的mysql监控信息:

pmm 部署监控mysql数据库

客户端查看监控信息:
[root@my2 ~]# pmm-admin list
pmm-admin 1.16.0

PMM Server      | 192.168.56.101
Client Name     | my2.ml.com
Client Address  | 192.168.56.102
Service Manager | linux-upstart

-------------- ----------- ----------- -------- ----------------------------------------- --------------------------------------------------------------------------------------
SERVICE TYPE   NAME        LOCAL PORT  RUNNING  DATA SOURCE                               OPTIONS                                                                              
-------------- ----------- ----------- -------- ----------------------------------------- --------------------------------------------------------------------------------------
mysql:queries  my2.ml.com  -           YES      pmm-monitor:***@tcp(192.168.56.102:3306)  query_source=slowlog, query_examples=true, slow_log_rotation=true, retain_slow_logs=1
linux:metrics  my2.ml.com  42000       YES      -                                                                                                                              
mysql:metrics  my2.ml.com  42002       YES      pmm-monitor:***@tcp(192.168.56.102:3306)

默认监控显示是以主机名字显示,如果机器上面部署多个mysql或者需要指定显示的主机名:

pmm-admin config --server 192.168.56.101 client-name   #client-name是指定监控显示名称client-name

例如:

pmm-admin add mysql --user pmm-monitor --password 'pmm-monitor' --socket=/data/mysql_3317/data/mysql.sock  mysql-3307

清除监控数据:
pmm-admin purge 会提示帮助信息,示例如下:
pmm-admin purge linux:metrics my2.ml.com
pmm-admin purge mysql:metrics my2.ml.com

删除添加的监控项:

pmm-admin remove mysql:metrics my2.ml.com

直接输入pmm-admin会显示所有的帮助信息:

[root@my2 ~]# pmm-admin
Usage:
   pmm-admin [flags]
   pmm-admin [command]

Available Commands:
   config         Configure PMM Client.
   add            Add service to monitoring.
   annotate       Annotate application events.
   remove         Remove service from monitoring.
   list           List monitoring services for this system.
   info           Display PMM Client information (works offline).
   check-network  Check network connectivity between client and server.
   ping           Check if PMM server is alive.
   start          Start monitoring service.
   stop           Stop monitoring service.
   restart        Restart monitoring service.
   show-passwords Show PMM Client password information (works offline).
   purge          Purge metrics data on PMM server.
   repair         Repair installation.
   uninstall      Removes all monitoring services with the best effort.
   summary        Fetch system data for diagnostics.
   help           Help about any command

Flags:
   -c, --config-file string   PMM config file (default "/usr/local/percona/pmm-client/pmm.yml")
   -h, --help                 help for pmm-admin
       --skip-root            skip UID check (experimental)
       --timeout duration     timeout (default 5s)
       --verbose              verbose output
   -v, --version              show version

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


文章标题:pmm部署监控mysql数据库
本文路径:http://myzitong.com/article/jiecsc.html