欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Prometheus 插件mysql_exporter安裝過程

 更新時間:2023年06月10日 14:22:04   作者:日?近?長?安?遠(yuǎn)  
mysql_exporter是用來收集MysQL或者M(jìn)ariadb數(shù)據(jù)庫相關(guān)指標(biāo)的,mysql_exporter需要連接到數(shù)據(jù)庫并有相關(guān)權(quán)限,這篇文章主要介紹了Prometheus插件安裝(mysql_exporter),需要的朋友可以參考下

簡介

mysql_exporter是用來收集MysQL或者M(jìn)ariadb數(shù)據(jù)庫相關(guān)指標(biāo)的,mysql_exporter需要連接到數(shù)據(jù)庫并有相關(guān)權(quán)限。既可以用二進(jìn)制安裝部署,也可以通過容器形式部署,但為了數(shù)據(jù)收集的準(zhǔn)確性,推薦二進(jìn)制安裝。

一,下載安裝包并解壓

安裝包下載地址: https://github.com/prometheus/mysqld_exporter/releases

同樣物理機(jī)上下載,然后上傳到服務(wù)器,本次安裝使用的版本為:mysqld_exporter-0.14.0.linux-amd64

1,根據(jù)服務(wù)器情況選擇安裝目錄,上傳安裝包。

mkdir /mysqld_exporter
cd /mysqld_exporter/
[root@jd-mysql mysqld_exporter]# ls
mysqld_exporter-0.14.0.linux-amd64.tar.gz
#解壓
[root@jd-mysql mysqld_exporter]# tar -xvzf mysqld_exporter-0.14.0.linux-amd64.tar.gz
[root@jd-mysql mysqld_exporter]# cp mysqld_exporter-0.14.0.linux-amd64/* .
[root@jd-mysql mysqld_exporter]# rm -rf mysqld_exporter-0.14.0.linux-amd64
[root@jd-mysql mysqld_exporter]# ls
LICENSE  mysqld_exporter  mysqld_exporter-0.14.0.linux-amd64.tar.gz  NOTICE

二,創(chuàng)建配置文件

創(chuàng)建配置文件.my.cnf ,填入如下內(nèi)容后保存:wq

[root@jd-mysql mysqld_exporter]# cat .my.cnf 
[client]
user = exporter
password = Jd123456
host = 192.168.1.150
port = 3306

mysql創(chuàng)建用戶并授權(quán),注意服務(wù)ip不要填錯

[root@jd-mysql mysqld_exporter]# mysql -uroot -pJiangda123#
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.40-log MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@(none) 11:06  mysql>create user 'exporter'@'%' identified by 'Jd123456';
Query OK, 0 rows affected (1.02 sec)
root@(none) 11:07  mysql>GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'%'  WITH MAX_USER_CONNECTIONS 3;
Query OK, 0 rows affected, 1 warning (0.00 sec)
root@(none) 11:07  mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@(none) 11:07  mysql>exit
Bye

三,進(jìn)行系統(tǒng)service編寫

創(chuàng)建mysqld_exporter.service配置文件

cd /usr/lib/systemd/system
vim mysqld_exporter.service

mysqld_exporter.service 文件填入如下內(nèi)容后保存:wq

[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/mysqld_exporter/mysqld_exporter --config.my-cnf=/mysqld_exporter/.my.cnf --web.listen-address=:9104
[Install]
WantedBy=multi-user.target

查看配置文件

cat mysqld_exporter.service 

刷新服務(wù)配置并啟動服務(wù)

systemctl daemon-reload
systemctl start mysqld_exporter.service

查看服務(wù)運(yùn)行狀態(tài)

systemctl status mysqld_exporter.service

設(shè)置開機(jī)自啟動

systemctl enable mysqld_exporter.service

測試服務(wù)返回

curl localhost:9104/metrics

Docker部署

  • 在Docker部署之前,首先要確保擁有Docker環(huán)境
  • 拉取mysqld-exporter最新鏡像
docker pull prom/mysqld-exporter

創(chuàng)建mysql監(jiān)聽用戶并授權(quán),注意服務(wù)ip不要填錯

CREATE USER 'exporter'@'<安裝Prometheus的主機(jī)IP>' IDENTIFIED BY '<your password>';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'<安裝Prometheus的主機(jī)IP>';
flush privileges;

啟動容器
注意:?? 若二進(jìn)制章節(jié)部署后,需要執(zhí)行systemctl stop mysqld_exporter.service關(guān)閉服務(wù),否則會造成端口沖突,或者docker的端口映射改為-p 9194:9104也可。注意環(huán)境變量DATA_SOURCE_NAME的mysql帳號密碼與地址無誤

docker run -d  --restart=always  --name mysqld-exporter -p 9104:9104 -e DATA_SOURCE_NAME="exporter:<pass>(11x.xx.xx.7:13306)/"  prom/mysqld-exporter

測試服務(wù)返回

curl localhost:9104/metrics

對接prometheus

打開prometheus.yml添加以下內(nèi)容,并執(zhí)行:wq,點(diǎn)擊回車保存

   
 - job_name: "mysql"
   static_configs:
     - targets: ["192.168.1.150:9104"]
       labels:
         instance: mysqld-exporter

執(zhí)行prometheus配置刷新

curl -XPOST localhost:9090/-/reload

打開prometheus,搜索mysql,可以看到出現(xiàn)了很多的參數(shù)指標(biāo)

打開targets,可以看到節(jié)點(diǎn)狀態(tài)已經(jīng)UP

至此mysqld-exporter插件安裝完畢

用Grafana出圖

[root@nfs yum.repos.d]# mkdir /grafana
[root@nfs yum.repos.d]# cd /grafana/
[root@nfs grafana]# ls
grafana-enterprise-9.1.2-1.x86_64.rpm
[root@nfs grafana]# yum install grafana-enterprise-9.1.2-1.x86_64.rpm -y

安裝好后

[root@nfs grafana]# service grafana-server start
Starting grafana-server (via systemctl):                   [  確定  ]
[root@nfs grafana]# systemctl enable grafana-server  
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
[root@nfs grafana]# netstat -anplut|grep grafana
tcp        0      0 192.168.1.130:56948     34.120.177.193:443      ESTABLISHED 8775/grafana-server 
tcp        0      0 192.168.1.130:48842     185.199.110.133:443     ESTABLISHED 8775/grafana-server 
tcp6       0      0 :::3000                 :::*                    LISTEN      8775/grafana-server 

訪問http://192.168.1.130:3000/

默認(rèn)的用戶名和密碼是
用戶名admin
密碼admin

配置數(shù)據(jù)源

成功效果:

到此這篇關(guān)于Prometheus插件安裝(mysql_exporter)的文章就介紹到這了,更多相關(guān)Prometheus mysql_exporter安裝內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解 MySQL中count函數(shù)的正確使用方法

    詳解 MySQL中count函數(shù)的正確使用方法

    這篇文章主要介紹了 MySQL中count函數(shù)的正確使用方法,幫助大家更好的理解和使用MySQL數(shù)據(jù)庫,感興趣的朋友可以了解下。
    2020-11-11
  • mysql下載與安裝過程詳解

    mysql下載與安裝過程詳解

    這篇文章主要介紹了mysql下載與安裝過程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • mysql如何創(chuàng)建數(shù)據(jù)庫并指定字符集

    mysql如何創(chuàng)建數(shù)據(jù)庫并指定字符集

    這篇文章主要介紹了mysql如何創(chuàng)建數(shù)據(jù)庫并指定字符集問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • MySQL獲取行號的示例代碼

    MySQL獲取行號的示例代碼

    MySQL變量是一種用于存儲和操縱數(shù)據(jù)的數(shù)據(jù)類型,通過在SQL查詢中使用變量,我們可以創(chuàng)建一個MySQL查詢,用于獲取每行數(shù)據(jù)的行號,這篇文章主要介紹了MySQL 如何獲取行號,需要的朋友可以參考下
    2023-08-08
  • MySQL 8.0 之索引跳躍掃描(Index Skip Scan)

    MySQL 8.0 之索引跳躍掃描(Index Skip Scan)

    這篇文章主要介紹了MySQL 8.0 之索引跳躍掃描(Index Skip Scan)的相關(guān)資料,幫助大家學(xué)習(xí)MySQL8.0的新特性,感興趣的朋友可以了解下
    2020-10-10
  • mysql報錯:1406 Data too long for column問題的多種解決方案

    mysql報錯:1406 Data too long for colu

    這篇文章給大家介紹了多種解決mysql報錯:1406, Data too long for column的解決方法,如果有遇到相同問題的朋友可以參考閱讀本文,對解決問題有一定的幫助,需要的朋友可以參考下
    2023-09-09
  • mysql Innodb表空間卸載、遷移、裝載的使用方法

    mysql Innodb表空間卸載、遷移、裝載的使用方法

    從MySQL的Innodb特性中我們知道,Inndob的表空間有共享和獨(dú)享的特點(diǎn),如果是共享的。則默認(rèn)會把表空間存放在一個文件中(ibdata1),當(dāng)開啟獨(dú)享表空間參數(shù)Innodb_file_per_table時,會為每個Innodb表創(chuàng)建一個.ibd的文件。文章討論在獨(dú)享表空間卸載、裝載、遷移Innodb表的情況
    2013-11-11
  • mysql數(shù)據(jù)庫中字段的注釋和類型長度獲取方式

    mysql數(shù)據(jù)庫中字段的注釋和類型長度獲取方式

    這篇文章主要介紹了mysql數(shù)據(jù)庫中字段的注釋和類型長度獲取方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • 解決MySQL登錄報錯1045-Access?denied?for?user?'root'@' '(using?password:YES)

    解決MySQL登錄報錯1045-Access?denied?for?user?'root'@

    這篇文章主要給大家介紹了關(guān)于解決MySQL登錄報錯1045-Access?denied?for?user?‘root‘@‘‘(using?password:YES)的相關(guān)資料,文中一步步將解決的辦法介紹的非常詳細(xì),需要的朋友可以參考下
    2023-07-07

最新評論