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

歡迎訪問 生活随笔!

生活随笔

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

数据库

oracle or使用速度快马_使用mysqld_exporter监控MySQL并展示数据

發布時間:2024/4/13 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle or使用速度快马_使用mysqld_exporter监控MySQL并展示数据 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

mysqld_exporter是Prometheus用于監控MySQL指標的一個導出器,支持對MySQL 5.5以上進行監控。用來抓取mysql的相關信息,下面是mysqld_exporter 安裝的相關信息

環境: 192.168.31.40 MariaDB-5.5.68 mysqld_exporter_0.12.1

一、下載mysqld_exporter 并安裝

官方網址:https://prometheus.io/download/

選擇對應的版本下載

[root@node-1 ~]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz

#解壓 ,移動到/usr/local 路徑下 并從命名為 mysqld_exporter

[root@node-1 ~]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz

[root@node-1 ~]# mv mysqld_exporter-0.12.1.linux-amd64 /usr/local/mysqld_exporter

二、登陸數據庫,創建授權賬戶

[root@node-1 ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or g.Your MariaDB connection id is 278Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.MariaDB [(none)]> grant PROCESS, REPLICATION CLIENT, SELECT on *.* to 'exporter'@'localhost' identified by 'fxkjnj';MariaDB [(none)]> flush privileges;

#注意: 這里我只授權了本機登陸,因為 mysqld_exporter 也安裝在數據庫這臺主機上

#退出驗證,使用exporter 用戶登陸數據庫

[root@node-1 ~]# mysql -uroot -p'fxkjnj'Welcome to the MariaDB monitor. Commands end with ; or g.Your MariaDB connection id is 286Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.MariaDB [(none)]> show grants;+----------------------------------------------------------------------------------------------------------------------------------------+| Grants for root@localhost |+----------------------------------------------------------------------------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*A88C2B91E04CF458B1EFF3228824DEA7CE4ABA22' WITH GRANT OPTION || GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |+----------------------------------------------------------------------------------------------------------------------------------------+2 rows in set (0.00 sec)MariaDB [(none)]>

三、創建mysqld_exporter 的配置文件 my.cnf

[root@node-1 mysqld_exporter]# vim /usr/local/mysqld_exporter/my.cnf

[client]

host=192.168.31.40

port=3306

user=exporter

password=fxkjnj

四、創建mysql_exporter 啟動文件,使用systemd 管理

[root@node-1 mysqld_exporter]# vim /etc/systemd/system/mysqld_exporter.service [Unit]Description=mysqld_exporterDocumentation=mysqld_exporter-doc [Service]ExecStart=/usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/my.cnf [Install]WantedBy=multi-user.target

#初始化并啟動mysqld_exporter

[root@node-1 mysqld_exporter]# systemctl daemon-reload

[root@node-1 mysqld_exporter]# systemctl start mysqld_exporter.service

#查看進程及端口

[root@node-1 ~]# ps -ef | grep mysqld_exporter | grep -v grep

root 60884 1 0 16:55 ? 00:00:02 /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/my.cnf

[root@node-1 ~]# netstat -ntlup | grep mysqld_export

tcp6 0 0 :::9104 :::* LISTEN 60884/mysqld_export

五、修改prometheus 配置文件 指定 mysqld_exporter 采集器地址

[root@prometheus ~]#vim /etc/prometheus/prometheus.yml

[root@prometheus ~]#vim /etc/prometheus/prometheus.yml..............scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['192.168.31.250:9090'] - job_name: 'mysql' static_configs: - targets: ['192.168.31.40:9104']..............

#熱加載prometheus

[root@prometheus ~]# ps -ef | grep prometheus | grep -v grep | awk '{print $2}' | xargs kill -HUP

#登陸到prometheus 控制臺,可以在status/targets 里看到 mysqld_exporter 采集器相關信息

點擊 http://192.168.31.40:9104/metrics 可以看到相關數據

六、使用grafana 展示 mysqld_exporter 采集器采集的數據

PS: grafana 添加 prometheus 數據源 過程 省略。。。。。。。。。。

為了最終的效果,我們使用 Grafana 官網小伙伴提供的dashboard 來展示數據

模板地址: https://grafana.com/grafana/dashboards/7362 ID: 7362

點擊 Download JSON , 下載完后 登陸Grafana ,默認地址 http://IP:3000

找到左側 + 號,import 導入剛剛下載的json 文件

選擇好數據源

稍等片刻,就可以看到 最終的效果

本篇只涉及到 使用mysqld_exporter 收集mysql 數據并展示 ,并沒有寫到 觸發器的配置告警,這個等后面再更新

總結

以上是生活随笔為你收集整理的oracle or使用速度快马_使用mysqld_exporter监控MySQL并展示数据的全部內容,希望文章能夠幫你解決所遇到的問題。

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