日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

潜力的监控mysql_Grafana 数据库监控平台

發布時間:2023/12/10 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 潜力的监控mysql_Grafana 数据库监控平台 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Grafana 數據庫監控平臺

簡介

Grafana

demo 地址:官方demo

文檔可以下載pdf離線閱讀

Percona監控和管理(PMM)是一個用于管理和監控MySQL和MongoDB性能的開源平臺。它由Percona與托管數據庫服務,支持和咨詢領域的專家合作開發。

PMM是一種免費的開源解決方案,您可以在自己的環境中運行,以獲得最大的安全性和可靠性。它為MySQL和MongoDB服務器提供全面的基于時間的分析,以確保您的數據盡可能高效地工作。

系統架構

PMM平臺基于客戶端 - 服務器模型,實現可伸縮性。它包括以下模塊:

PMM客戶端安裝在要監視的每個數據庫主機上。它收集服務器指標,常規系統指標和查詢分析數據,以獲得完整的性能概述。

PMM Server是PMM的核心部分,它聚合收集的數據并以Web界面中的表格,儀表板和圖形的形式呈現。

這些模塊的封裝便于安裝和使用。假設用戶不需要了解構成每個模塊的確切工具以及它們如何交互。但是,如果您想充分發揮PMM的潛力,內部結構非常重要。

PMM是一系列旨在無縫協同工作的工具。有些是由Percona開發的,有些是第三方開源工具。

注意

整體客戶端 - 服務器模型不太可能改變,但組成每個組件的工具集可能隨產品而變化。

下圖說明了PMM當前的結構:

image

PMM服務端安裝

pmm服務器安裝有多種方式。官方安裝介紹

本文主要介紹docker的安裝方式

docker 鏡像下載

$ docker pull percona/pmm-server:latest

創建pmm-data 容器

創建一個持久化的 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

docker create 參數說明:

The docker create command instructs the Docker daemon to create a container from an image.

The -v options initialize data volumes for the container.

The --name option assigns a custom name for the container that you can use to reference the container within a Docker network. In this case: pmm-data.

percona/pmm-server:latest is the name and version tag of the image to derive the container from.

/bin/true is the command that the container runs.

Note

這個容器不會運行,他的存在僅僅是保留PMM的數據,當你升級到一個新的PMM版本的時候。不要刪除、重新創建這個容器,除非你想要刪除所有的PMM數據。

創建PMM服務容器并啟動

官網提供的創建方式

$ docker run -d \

-p 80:80 \

--volumes-from pmm-data \

--name pmm-server \

--restart always \

percona/pmm-server:latest

docker run參數說明:

The -d option starts the container in the background (detached mode).

The -p option maps the port for accessing the PMM Server web UI. For example, if port 80 is not available, you can map the landing page to port 8080 using -p 8080:80.

The -v option mounts volumes from the pmm-data container (see Creating the pmm-data Container).

The --name option assigns a custom name to the container that you can use to reference the container within the Docker network. In this case: pmm-server.

The --restart option defines the container’s restart policy. Setting it to always ensures that the Docker daemon will start the container on startup and restart it if the container exits.

percona/pmm-server:latest is the name and version tag of the image to derive the container from.

我們在基礎配置上,添加用戶名密碼的配置信息:

$ docker run -d \

-p 80:80 \

--volumes-from pmm-data \

--name pmm-server \

--restart always \

-e SERVER_USER=test \

-e SERVER_PASSWORD=test \

-e ORCHESTRATOR_ENABLED=true \

percona/pmm-server:latest

新建PMM的客戶端

安裝Percona的軟件倉庫

sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm

驗證安裝結果

sudo yum list | grep percona

結果如下:

percona-release.noarch 0.1-6 @/percona-release-0.1-6.noarch

Percona-Server-55-debuginfo.x86_64 5.5.54-rel38.7.el7 percona-release-x86_64

Percona-Server-56-debuginfo.x86_64 5.6.35-rel81.0.el7 percona-release-x86_64

Percona-Server-57-debuginfo.x86_64 5.7.17-13.1.el7 percona-release-x86_64

...

安裝客戶端

sudo yum install pmm-client

PMM的客戶端配置

pmm客戶端的 配置命令是pmm-admin

一般步驟為

配置客戶端到服務器的連接信息

將需要監控的內容加入到監控列表

客戶端與服務端連接配置

pmm-admin config --server 192.168.0.157:80 --server-user test --server-password test

配置服務端的網絡信息,用戶名,密碼。

Note

執行后會生成配置文件,配置文件的默認路徑為 /usr/local/percona/pmm-client/pmm.yml

配置好后可以使用以下命令查看連接信息

配置信息

# pmm-admin info

pmm-admin 1.13.0

PMM Server | 192.168.0.157:80 (password-protected)

Client Name | 192.168.0.156

Client Address | 192.168.0.156

Service Manager | linux-systemd

Go Version | 1.10.1

Runtime Info | linux/amd64

2.網絡連接信息

# pmm-admin check-network

PMM Network Status

Server Address | 192.168.0.157:80

Client Address | 192.168.0.156

* System Time

NTP Server (0.pool.ntp.org) | 2018-08-16 09:17:22 +0000 UTC

PMM Server | 2018-08-16 09:17:20 +0000 GMT

PMM Client | 2018-08-16 17:17:22 +0800 CST

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 | 617.745μs

Request duration | -207.451μs

Full round trip | 410.294μs

* Connection: Client

-------------- -------------- -------------------- ------- ---------- ---------

SERVICE TYPE NAME REMOTE ENDPOINT STATUS HTTPS/TLS PASSWORD

-------------- -------------- -------------------- ------- ---------- ---------

linux:metrics 192.168.0.156 192.168.0.156:42000 OK YES YES

mysql:metrics 192.168.0.156 192.168.0.156:42002 OK YES YES

mysql數據配置

grafana收集mysql的信息方式的配置需要針對mysql的版本

mysql5.5 之后增加 performance_schema。mysql開啟performance_schema后grafana可以直接獲取信息。MySQL 5.6.9之后的版本默認開啟,之前的版本需要手動開啟。

mysql5.5之前的mysql版本可以通過slow-log獲取慢查詢的信息。

Note

本節主要介紹使用performance_schema的方式,即 mysql5.5之后版本的數據庫監控。

mysql5.5之前版本的數據庫監控,見下一節。

創建pmm數據庫賬號

GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD ON *.* TO pmm@'%' IDENTIFIED BY 'pmm' WITH MAX_USER_CONNECTIONS 10;

GRANT SELECT, UPDATE, DELETE, DROP ON performance_schema.* TO 'pmm'@'%';

flush privileges;

查看數據的關鍵參數

mysql> SHOW VARIABLES LIKE 'performance_schema';

+--------------------+-------+

| Variable_name | Value |

+--------------------+-------+

| performance_schema | ON |

+--------------------+-------+

mysql> select * from setup_consumers;

+----------------------------------+---------+

| NAME | ENABLED |

+----------------------------------+---------+

| events_stages_current | NO |

| events_stages_history | NO |

| events_stages_history_long | NO |

| events_statements_current | YES |

| events_statements_history | YES |

| events_statements_history_long | NO |

| events_transactions_current | NO |

| events_transactions_history | NO |

| events_transactions_history_long | NO |

| events_waits_current | NO |

| events_waits_history | NO |

| events_waits_history_long | NO |

| global_instrumentation | YES |

| thread_instrumentation | YES |

| statements_digest | YES |

+----------------------------------+---------+

15 rows in set (0.00 sec)

確保 statements_digest是 開啟的

如果以上關鍵參數沒有開啟就需要修改配置文件

mysql配置文件修改

Percona Server(or XtraDB Cluster)

log_output=file

slow_query_log=ON

long_query_time=0

log_slow_rate_limit=100

log_slow_rate_type=query

log_slow_verbosity=full

log_slow_admin_statements=ON

log_slow_slave_statements=ON

slow_query_log_always_write_time=1

slow_query_log_use_global_control=all

innodb_monitor_enable=all

userstat=1

MySQL 5.6+ or MariaDB 10.0+

innodb_monitor_enable=all

performance_schema=ON

MySQL 5.5 or MariaDB 5.5

log_output=file

slow_query_log=ON

long_query_time=0

log_slow_admin_statements=ON

log_slow_slave_statements=ON

mysql5.5之前版本的配置

mysql 5.5之前的版本是通過慢查詢文件進行查詢語句的查看,所以需要配置慢查詢

slow_query_log

long_query_time = 3

PMM客戶端添加數據庫

performance_schema方式

pmm-admin add mysql --user pmm --password pmm --socket /application/mysql3307/logs/mysql.sock --query-source perfschema

慢查詢的方式

pmm-admin add mysql --user pmm --password pmm --socket /application/mysql3307/logs/mysql.sock

參考文檔

總結

以上是生活随笔為你收集整理的潜力的监控mysql_Grafana 数据库监控平台的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。