PMM 對MYSQL 的監控配製

 
系統選擇: centos 7.2
    關閉防火牆:
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    起用轉發:
    # vi /usr/lib/sysctl.d/00-system.conf
    添加以下代碼:
    net.ipv4.ip_forward=1
    重啓network服務
    # systemctl restart network
    查看是否修改爲功
    # sysctl net.ipv4.ip_forward
    若是返回爲「net.ipv4.ip_forward = 1」則表示成功了
   
pmm-server 安裝:
   pmm官方文檔:

    Pmm 組成: https://www.percona.com/doc/percona-monitoring-and-management/architecture.htmlhtml

    PMM 安裝: https://www.percona.com/doc/percona-monitoring-and-management/deploy/server/docker.html#run-server-dockermysql

    相關開源項目:
      https://www.sqlite.org/atomiccommit.html
      https://github.com/prometheuslinux

    1.安裝DOCKER,RPM包的名字是docker-io
     yum install docker -y
 
   2.啓動docker
     service docker start
     ps -ef |grep docker
 
   3.建立容器的數據磁盤
     docker create \
     -v /opt/prometheus/data \
     -v /opt/consul-data \
     -v /var/lib/mysql \
     -v /var/lib/grafana \                    
     --name pmm-data \
     docker.io/percona/pmm-server /bin/true   
     //默認本地不存pmm-server,會從官網下載 ,可是會很慢
   
    容器卷在宿主機的目錄位置:
    docker inspect pmm-data
 
        "Mounts": [
            {
                "Name": "134874af6736c9065c504d084eb0b754507da23a212cd90524d35463dcff8c54",
                "Source": "/var/lib/docker/volumes/134874af6736c9065c504d084eb0b754507da23a212cd90524d35463dcff8c54/_data",
                "Destination": "/var/lib/mysql",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "3d03268806f49143f8051aefc8ebef047ceeeeea24c5fe2828e06e0b08b36f6e",
                "Source": "/var/lib/docker/volumes/3d03268806f49143f8051aefc8ebef047ceeeeea24c5fe2828e06e0b08b36f6e/_data",
                "Destination": "/opt/consul-data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "47dde5e315f8123018a485d8a922d060761a508b9958bc5e8c38f4b934152321",
                "Source": "/var/lib/docker/volumes/47dde5e315f8123018a485d8a922d060761a508b9958bc5e8c38f4b934152321/_data",
                "Destination": "/opt/prometheus/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "4faad60a6619be2f2aa29c34dd8630427cd70810d849a21bc26733b3970dfb6b",
                "Source": "/var/lib/docker/volumes/4faad60a6619be2f2aa29c34dd8630427cd70810d849a21bc26733b3970dfb6b/_data",
                "Destination": "/var/lib/grafana",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
   
  4.建立容器的運行實例:
    docker run -d \
    -p 80:80 \
    --volumes-from pmm-data \
    --name pmm-server \
    --restart always \
    percona/pmm-server:1.2.0
   
 
    容器卷在宿主機的目錄位置:
 
     docker inspect pmm-server
     "Mounts": [
            {
                "Name": "47dde5e315f8123018a485d8a922d060761a508b9958bc5e8c38f4b934152321",
                "Source": "/var/lib/docker/volumes/47dde5e315f8123018a485d8a922d060761a508b9958bc5e8c38f4b934152321/_data",
                "Destination": "/opt/prometheus/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "4faad60a6619be2f2aa29c34dd8630427cd70810d849a21bc26733b3970dfb6b",
                "Source": "/var/lib/docker/volumes/4faad60a6619be2f2aa29c34dd8630427cd70810d849a21bc26733b3970dfb6b/_data",
                "Destination": "/var/lib/grafana",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "134874af6736c9065c504d084eb0b754507da23a212cd90524d35463dcff8c54",
                "Source": "/var/lib/docker/volumes/134874af6736c9065c504d084eb0b754507da23a212cd90524d35463dcff8c54/_data",
                "Destination": "/var/lib/mysql",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Name": "3d03268806f49143f8051aefc8ebef047ceeeeea24c5fe2828e06e0b08b36f6e",
                "Source": "/var/lib/docker/volumes/3d03268806f49143f8051aefc8ebef047ceeeeea24c5fe2828e06e0b08b36f6e/_data",
                "Destination": "/opt/consul-data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
 
    更改面板數據sqlite庫存儲類型爲MYSQL(容器自帶)
    [root@workstation2017 ~]# docker exec -i -t pmm-server /bin/bash
    [root@86b5c5955521 opt]# vi /etc/grafana/grafana.ini
     查/sqlite 改成MYSQL 存儲
     type=mysql
     host=127.0.0.1:3306
     name=grafana
     user=root
     password =
     在容器進入mysql客戶端,建立數據庫grafana,
     create database grafana;
    
     生效:
     docker restart pmm-server
    // 默認面板監控數據數據保在  /var/lib/grafana/grafana.db  
 
PMM client 安裝:
    [root@workstation2017 ~]# service mysql start
    Redirecting to /bin/systemctl start  mysql.service
    下載與PMM SERVER 一致的 PMM client
    https://www.percona.com/downloads/pmm-client/
    
    配製:
    [root@workstation2017 ~]# pmm-admin config --server 192.168.79.220
    OK, PMM server is alive.
    PMM Server      | 192.168.79.220
    Client Name     | workstation2017
    Client Address  | 192.168.79.220
 
     開始監控:
    pmm-admin add mysql --query-source perfschema  --user root --password xx
     
    WEB訪問頁面並配製相關值:
    http://192.168.79.220/graph
 
    data sources--->edit data source
       config:
          填入:
          name:prometheus
          type:prometheus
       http settings:加入
          http://127.0.0.1:9090/prometheus
    dashboards-->import
    點選導入import json文件
   
操做目的:監控指定的Metrics,減小系統的統計負載,並採用MYSQL做爲存儲後端  
詳細操做以下:
json文件容器導出到宿主機的目錄上,並在WEB 面板中導入
[root@f3e8318c8d7c dashboards]# pwd
/usr/share/percona-dashboards/dashboards
[root@f3e8318c8d7c dashboards]# ls
Amazon_RDS_OS_Metrics.json    MongoDB_Overview.json               MySQL_Performance_Schema.json      Prometheus.json
Cross_Server_Graphs.json      MongoDB_ReplSet.json                MySQL_Query_Response_Time.json     ProxySQL_Overview.json
Disk_Performance.json         MongoDB_RocksDB.json                MySQL_Replication.json             Summary_Dashboard.json
Disk_Space.json               MongoDB_WiredTiger.json             MySQL_Table_Statistics.json        System_Overview.json
MariaDB.json                  MySQL_InnoDB_Metrics.json           MySQL_TokuDB_Metrics.json          Trends_Dashboard.json
MongoDB_Cluster_Summary.json  MySQL_InnoDB_Metrics_Advanced.json  MySQL_User_Statistics.json
MongoDB_InMemory.json         MySQL_MyISAM_Metrics.json           PXC_Galera_Cluster_Overview.json
MongoDB_MMAPv1.json           MySQL_Overview.json                 PXC_Galera_Graphs.json
 
拷到宿主機的目錄中:
[root@workstation2017 ~]# docker cp f3e8318c8d7c:/usr/share/percona-dashboards/dashboards /soft/
而後用XSHELL 拷到WINDOW目錄下
在主機WEB界面中
在導入框中加入MySQL_InnoDB_Metrics.json
dashboard ---> import---> MySQL_InnoDB_Metrics.json
便可所有配製完成
 
 
PMM-SERVER 與 PMM-CLIENT 互聯檢測
   gui: http://192.168.79.220:80/prometheus/targets
   command: pmm-admin check-network
            pmm-admin list
EG:
[root@workstation2017 ~]#   pmm-admin check-network
PMM Network Status
Server Address | 192.168.79.220
Client Address | 192.168.79.220
* System Time
NTP Server (0.pool.ntp.org)         | 2017-07-24 22:57:08 -0400 EDT
PMM Server                          | 2017-07-25 02:57:08 +0000 GMT
PMM Client                          | 2017-07-24 22:57:08 -0400 EDT
PMM Server Time Drift               | OK
PMM Client Time Drift               | OK
PMM Client to PMM Server Time Drift | OK
* Connection: Client --> Server
-------------------- -------     
SERVER SERVICE       STATUS      
-------------------- -------     
Consul API           OK
Prometheus API       OK
Query Analytics API  OK
Connection duration | 465.152µs
Request duration    | 1.000382ms
Full round trip     | 1.465534ms
* Connection: Client <-- Server
-------------- ---------------- --------------------- ------- ---------- ---------
SERVICE TYPE   NAME             REMOTE ENDPOINT       STATUS  HTTPS/TLS  PASSWORD
-------------- ---------------- --------------------- ------- ---------- ---------
linux:metrics  workstation2017  192.168.79.220:42000  OK      YES        -       
mysql:metrics  workstation2017  192.168.79.220:42002  OK      YES        -
相關文章
相關標籤/搜索