PMM监控MySQL

发布时间:2020-07-05 12:20:36 作者:苏黎世1995
来源:网络 阅读:946

一、PMM-SERVER

1. 安装docker
yum install -y docker-io
2. 拉取pmm-server镜像
docker pull percona/pmm-server:latest
3. 创建持久化容器
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
4. 启动pmm-server
docker run -d \
   -p 8888:80 \     #将docker的80端口映射到宿主机的8888端口
   --volumes-from pmm-data \
   --name pmm-server \
   --restart always \
   percona/pmm-server:latest

查看运行状态

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS              PORTS                           NAMES
983cb32aa7ca        percona/pmm-server:latest   "/opt/entrypoint.sh"   4 days ago          Up 4 days           443/tcp, 0.0.0.0:8888->80/tcp   pmm-server          
670aaeb497cf        percona/pmm-server:latest   "/bin/true"            4 days ago                                                              pmm-data    
5. 关闭匿名登陆,并调整时区
[root@localhost docker]# docker exec -it pmm-server /bin/bash    #进入docker容器
[root@983cb32aa7ca opt]# vi /etc/grafana/grafana.ini
#################################### Anonymous Auth ##########################
[auth.anonymous]
# enable anonymous access
#enabled = True

[root@983cb32aa7ca opt]# cat /etc/localtime 
TZif2UTCTZif2UTC
UTC0
[root@983cb32aa7ca opt]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
cp: overwrite '/etc/localtime'? y
6. 登陆dashboard

浏览器中输入: xx.xx.xx.xx:8888

二、PMM-CLIENT

1. 在需要监控的机器上安装pmm-client
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm   #配置percona源

yum install pmm-client #安装pmm-client
2. 配置pmm-server地址

--server 后接的是pmm-server的地址和端口
-c 后边接的是配置文件,默认配置文件为/usr/local/percona/pmm-client/pmm.yml

pmm-admin config --server xx.xx.xx.xx:8888 -c /usr/local/percona/pmm-client/pmm.yml             

以下是配置文件的内容

cat /usr/local/percona/pmm-client/pmm.yml

server_address: xx.xx.xx.xx:8888
client_address: xx.xx.xx.xx
bind_address: xx.xx.xx.xx
client_name: monitor-node1
3. 添加linux系统监控
pmm-admin add linux:metrics 
4. 添加MySQL监控

在MySQL实例中创建监控用户:

GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO 'pmm'@'127.0.0.1' IDENTIFIED BY 'pmm' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, UPDATE, DELETE, DROP ON performance_schema.* TO 'pmm'@'127.0.0.1';

添加MySQL监控

pmm-admin add mysql --host 127.0.0.1 --user pmm --password pmm --port 3306 instance3306   ##此命令是监控MySQL实例状态以及慢查询分析,如果不想监控慢日志使用mysql:metrics即可

三、遇到的问题

1. purge报错

某台机器下线,需要清理pmm-server中关于这台机器的数据,执行purge命令后报错

[root@localhost ~]# pmm-admin purge linux:metrics
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/percona/pmm-client/pmm.(*Admin).PurgeMetrics(0xbe4e60, 0x7ffc82a0674b, 0xd, 0xc4201f68b8, 0xc4201abb68, 0x7ff262)
    /tmp/go/src/github.com/percona/pmm-client/pmm/main.go:427 +0x5a4
main.glob..func39(0xbde460, 0xc4200a1730, 0x1, 0x1)
    /tmp/go/src/github.com/percona/pmm-client/pmm-admin.go:1179 +0xd1
github.com/percona/pmm-client/vendor/github.com/spf13/cobra.(*Command).execute(0xbde460, 0xc4200a16e0, 0x1, 0x1, 0xbde460, 0xc4200a16e0)
    /tmp/go/src/github.com/percona/pmm-client/vendor/github.com/spf13/cobra/command.go:654 +0x2a2
github.com/percona/pmm-client/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xbdeb20, 0xc4201abdd0, 0x49b302, 0x0)
    /tmp/go/src/github.com/percona/pmm-client/vendor/github.com/spf13/cobra/command.go:729 +0x2d4
github.com/percona/pmm-client/vendor/github.com/spf13/cobra.(*Command).Execute(0xbdeb20, 0xc0263c, 0x92bf0f)
    /tmp/go/src/github.com/percona/pmm-client/vendor/github.com/spf13/cobra/command.go:688 +0x2b
main.main()
    /tmp/go/src/github.com/percona/pmm-client/pmm-admin.go:1398 +0x18dc

疑似为bug,官方表名会在以后版本修复:https://jira.percona.com/browse/PMM-2894

2. _PMM System Summary面板无法显示MySQL信息汇总

报错如下:

Server summary:mysql summary - Exit Status 1

解决办法:将MySQL相关命令软连接到/usr/bin/

ln -s /usr/local/mysql/bin/* /usr/bin/

参考地址:https://www.percona.com/forums/questions-discussions/percona-monitoring-and-management/47268-server-summary-mysql-summary-exit-status-1

推荐阅读:
  1. MySQL-MongoDB开源监控利器PMM增加slack报
  2. MySQL-MongoDB开源监控利器之PMM

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

pmm mysql mysql监控

上一篇:wordpress 分类使用不同的模版

下一篇:禁止按钮在一定时间内连续点击

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》