溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

PMM監(jiān)控MySQL

發(fā)布時間:2020-07-05 12:20:36 來源:網(wǎng)絡(luò) 閱讀:944 作者:蘇黎世1995 欄目:MySQL數(shù)據(jù)庫

一、PMM-SERVER

1. 安裝docker
yum install -y docker-io
2. 拉取pmm-server鏡像
docker pull percona/pmm-server:latest
3. 創(chuàng)建持久化容器
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

查看運行狀態(tài)

[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. 關(guān)閉匿名登陸,并調(diào)整時區(qū)
[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. 在需要監(jiān)控的機器上安裝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 后邊接的是配置文件,默認(rèn)配置文件為/usr/local/percona/pmm-client/pmm.yml

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

以下是配置文件的內(nèi)容

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系統(tǒng)監(jiān)控
pmm-admin add linux:metrics 
4. 添加MySQL監(jiān)控

在MySQL實例中創(chuàng)建監(jiān)控用戶:

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監(jiān)控

pmm-admin add mysql --host 127.0.0.1 --user pmm --password pmm --port 3306 instance3306   ##此命令是監(jiān)控MySQL實例狀態(tài)以及慢查詢分析,如果不想監(jiān)控慢日志使用mysql:metrics即可

三、遇到的問題

1. purge報錯

某臺機器下線,需要清理pmm-server中關(guān)于這臺機器的數(shù)據(jù),執(zhí)行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,官方表名會在以后版本修復(fù):https://jira.percona.com/browse/PMM-2894

2. _PMM System Summary面板無法顯示MySQL信息匯總

報錯如下:

Server summary:mysql summary - Exit Status 1

解決辦法:將MySQL相關(guān)命令軟連接到/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

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI