這篇文章主要介紹“prometheus服務(wù)監(jiān)控之MySQL監(jiān)控怎么配置”,在日常操作中,相信很多人在prometheus服務(wù)監(jiān)控之mysql監(jiān)控怎么配置問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”prometheus服務(wù)監(jiān)控之mysql監(jiān)控怎么配置”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),大田企業(yè)網(wǎng)站建設(shè),大田品牌網(wǎng)站建設(shè),網(wǎng)站定制,大田網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,大田網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
若你的機器還沒有安裝prometheus,先參考下面的安裝步驟:
part 1:prometheus的介紹與安裝
熟悉了上面的兩個部分后,我們進入今天的服務(wù)監(jiān)控,以mariadb為例:
監(jiān)控mysql需要在被監(jiān)控機器安裝mysql_exporter
1.上傳解壓安裝mysqld_exporter
root@xinsz08-20 ~]# tar xf mysqld_exporter-0.12.1.linux-amd64.tar.gz 文件名字太長,重命名一下: [root@xinsz08-20 ~]# mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter [root@xinsz08-20 ~]# cd mysqld_exporter/ [root@xinsz08-20 mysqld_exporter]# pwd /root/mysqld_exporter
2. 安裝mariadb
root@xinsz08-20 mysqld_exporter]# yum install mariadb\* -y [root@xinsz08-20 ~]# systemctl start mariadb [root@xinsz08-20 ~]# systemctl enable mariadb [root@xinsz08-20 ~]# ss -natlp |grep 3306 //查看端口是否開啟 LISTEN 0 80 0.0.0.0:3306 0.0.0.0:* users:(("mysqld",pid=67872,fd=22))
3. 在數(shù)據(jù)庫里創(chuàng)建mysql賬號用戶收集數(shù)據(jù)
[root@xinsz08-20 ~]# mysql MariaDB [(none)]> grant select,replication client,process ON *.* to 'mysql_monitor'@'localhost' identified by '12345678'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> exit Bye
#備注:此處是prometheus服務(wù)器來找mysql_exporter,然后mysql_exporter 在找mariadb,所以這里用的是localhost,指的是mysql_exporter的ip
4. 在mysql_exporter中設(shè)置mysql配置信息
[root@xinsz08-20 mysqld_exporter]# pwd /root/mysqld_exporter [root@xinsz08-20 mysqld_exporter]# vim .my.cnf (手工創(chuàng)建) [client] user=mysql_monitor password=12345678
5. 啟動mysql_exporter
[root@xinsz08-20 mysqld_exporter]# nohup ./mysqld_exporter --config.my -cnf=/root/mysqld_exporter/.my.cnf & [1] 68166
6. 配置prometheus拉取mysql節(jié)點信息
[root@zmedu-17 prometheus-2.16.0.linux-amd64]# pwd /root/prometheus-2.16.0.linux-amd64 [root@zmedu-17 prometheus-2.16.0.linux-amd64]# vim prometheus.yml - job_name: 'mariadb' static_configs: - targets: ['192.168.1.20:9104']
#在prometheus的server端進行修改
重啟prometheus服務(wù)
[root@zmedu-17 prometheus-2.16.0.linux-amd64]# pkill prometheus [root@zmedu-17 prometheus-2.16.0.linux-amd64]# lsof -i:9090 [root@zmedu-17 prometheus-2.16.0.linux-amd64]# ./prometheus & [1] 84662 [root@zmedu-17 ~]# ss -naltp |grep 9090 LISTEN 0 128 [::]:9090 [::]:* users:(("prometheus",pid=84662,fd=9))
7. 通過web端查看
http://192.168.1.17:9090
查看mysql的連接數(shù),看到只有一個連接數(shù):
mysql_global_status_aria_pagecache_blocks_unused
8. prometheus.yml配置文件詳解
global: # 全局配置 scrape_interval: 15s # 多久收集一次數(shù)據(jù) evaluation_interval: 15s # 多久評估一次規(guī)則 scrape_timeout:10s # 每次收集數(shù)據(jù)的超時時間 # Alertmanager configuration #告警設(shè)置 alerting: alertmanagers: - static_configs: #告警規(guī)則,也可以基于動態(tài)方式進行告警 - targets: rule_files: #規(guī)則文件 #收集數(shù)據(jù)配置列表 scrape_configs: - job_name: 'prometheus'
9. prometheusUI的英文翻譯
Alerts: 表示可以看到我們定義的告警規(guī)則 Graph:表示界面查詢數(shù)據(jù),生成圖片,或者返回數(shù)據(jù) Status: 下面的target:表示我們的遠(yuǎn)端的監(jiān)控,可以看exporter的運行情況
到此,關(guān)于“prometheus服務(wù)監(jiān)控之mysql監(jiān)控怎么配置”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
文章題目:prometheus服務(wù)監(jiān)控之mysql監(jiān)控怎么配置
標(biāo)題來源:http://chinadenli.net/article4/gsgeoe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、App設(shè)計、標(biāo)簽優(yōu)化、移動網(wǎng)站建設(shè)、、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)