婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > zabbix 監控mysql的方法

zabbix 監控mysql的方法

熱門標簽:比較穩定的外呼系統 信貸電銷機器人系統 江蘇自動外呼系統一般多少錢 鸚鵡螺號航海地圖標注時間 ai電話機器人營銷 400 電話 申請費用 山東電信外呼系統靠譜嗎 云南云電銷機器人招商 長沙回撥外呼系統

zabbix部署文檔

zabbix部署完之后

zabbix-agent操作

 1.監控mysql,首先要先安裝mysql

[root@localhost ~]# yum -y install mariadb mariadb-server

2.編寫mysql監控項的腳本

在zabbix-agent先授權個用戶 不然測試時沒有權限

[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (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 all on *.* to 'check'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)

mysql監控的內容主要有

  • 主從的狀態 (得先配置主從 在下面)
  • 流量檢測 發送,接受常規操作 增刪改查
  • 某個庫、某個表的大小
  • tps(每秒查詢處理的事務數)qps(每秒能處理多少次請求數)
[root@localhost ~]# mkdir /etc/zabbix/scipts
[root@localhost ~]# cd /etc/zabbix/scipts/
[root@localhost scipts]# vim mysql.sh 
#!/bin/bash
mysql="mysql -ucheck -p123"
case $1 in 
 # mysql主從狀態
 slave_status)
  $mysql -e "show slave status\G" |grep "Yes" |wc -l
 ;; 
 # mysql流量 接受
 Bytes_received)
  mysqladmin extended-status |grep "Bytes_received" |awk '{print $4}'
 ;;
 # mysql流量 發送
 Bytes_sent)
  mysqladmin extended-status |grep "Bytes_sent" |awk '{print $4}'
 ;;
 # mysql常規操作 增
 Com_insert)
  mysqladmin extended-status |grep -w "Com_insert" |awk '{print $4}'
 ;;
 # mysql常規操作 刪
 Com_delete)
  mysqladmin extended-status |grep -w "Com_delete" |awk '{print $4}'
 ;;
 # mysql常規操作 改
 Com_update)
  mysqladmin extended-status |grep -w "Com_update" |awk '{print $4}'
		;;
 # mysql常規操作 查
 Com_select)
  mysqladmin extended-status |grep -w "Com_select" |awk '{print $4}'
 ;;
 # mysql tps
 tps)
  mysqladmin status |awk '{print $6/$2}'
 ;;
 # mysql qps=(rollback+commit)/uptime
 qps)
  rollback=$(mysqladmin extended-status |grep -w "Com_rollback" |awk '{print $4}')
  commit=$(mysqladmin extended-status |grep -w "Com_commit" |awk '{print $4}')
  uptime=$(mysqladmin status |awk '{print $2}')
  count=$[$rollback+$commit]
  echo "$count $uptime" > /tmp/a.txt
  cat /tmp/a.txt |awk '{print $1/$2}'
 ;;
 # 庫大小 我們這里拿mysql庫舉例
 db)
  $mysql -e "select sum(data_length) from information_schema.tables where table_schema='mysql'" |sed -n '2p'
 ;;
 # 表大小 我們這里拿mysql下面的user表舉例
 tb)
  $mysql -e "select sum(data_length) from information_schema.tables where table_schema='mysql' and table_name='user'" |sed -n '2p'
 ;;
esac

3.自定義鍵值key 重啟zabbix-agent

[root@localhost scipts]# cd /etc/zabbix/zabbix_agentd.d/
[root@localhost zabbix_agentd.d]# vim mysql.conf
UserParameter=mysql[*],/etc/zabbix/scipts/mysql.sh $1
[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent

4.在zabbix-server測試 先安裝zabbix-get

[root@localhost ~]# yum -y install zabbix-get

[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]
2
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Bytes_received]
850970
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Bytes_sent]
224906
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_insert]
3001
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_delete]
135
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_update]
128
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_select]
19
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[qps]
0.864842
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[tps]
1.92936
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[db]
555118
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[tb]
420

報錯處理

[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]
sh: /etc/zabbix/scipts/mysql.sh: 權限不夠

腳本執行權限不夠 去zabbix-agent 加權限
[root@localhost zabbix_agentd.d]# chmod +x /etc/zabbix/scipts/mysql.sh 

[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]
ERROR 1227 (42000) at line 1: Access denied; you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation

是因為用戶沒有權限查看 去zabbix-agent 授權個用戶在腳本里面加上
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (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 all on *.* to 'check'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)

[root@localhost scipts]# vim mysql.sh 
#!/bin/bash
mysql="mysql -ucheck -p123"
case $1 in 
 # mysql主從狀態
 slave_status)
  $mysql -e "show slave status\G" |grep "Yes" |wc -l
 ;; 

zabbix頁面上添加監控項和圖形




查看mysql流量數據


查看mysql qps tps

查看mysql主從狀態

查看mysql常規操作

查看mysql庫表大小

mysql主從配置

一.zabbix-server端

[root@localhost ~]# vim /etc/my.cnf

[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (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 master status;
+------------------+----------+--------------+------------------+
| File  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 175170 |  |   |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> grant all on *.* to 'tom'@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

二.zabbix-agent端

[root@localhost ~]# vim /etc/my.cnf

[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (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)]> change master to
 -> master_host='192.168.27.136',
 -> master_user='tom',
 -> master_password='123',
 -> master_log_file='mysql-bin.000001',
 -> master_log_pos=175170;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
  Slave_IO_State: Waiting for master to send event
   Master_Host: 192.168.27.136
   Master_User: tom
   Master_Port: 3306
  Connect_Retry: 60
  Master_Log_File: mysql-bin.000001
  Read_Master_Log_Pos: 175170
  Relay_Log_File: mysql-relay.000004
  Relay_Log_Pos: 529
 Relay_Master_Log_File: mysql-bin.000001
  Slave_IO_Running: Yes
  Slave_SQL_Running: No
  Replicate_Do_DB: 
  Replicate_Ignore_DB: 
  Replicate_Do_Table: 
 Replicate_Ignore_Table: 
 Replicate_Wild_Do_Table: 
 Replicate_Wild_Ignore_Table: 
   Last_Errno: 1146
   Last_Error: Error 'Table 'zabbix.history_uint' doesn't exist' on query. Default database: 'zabbix'. Query: 'insert into history_uint (itemid,clock,ns,value) values (23287,1602301747,810415730,1)'
   Skip_Counter: 0
  Exec_Master_Log_Pos: 173424
  Relay_Log_Space: 2565
  Until_Condition: None
  Until_Log_File: 
  Until_Log_Pos: 0
  Master_SSL_Allowed: No
  Master_SSL_CA_File: 
  Master_SSL_CA_Path: 
  Master_SSL_Cert: 
  Master_SSL_Cipher: 
  Master_SSL_Key: 
 Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
  Last_IO_Errno: 0
  Last_IO_Error: 
  Last_SQL_Errno: 1146
  Last_SQL_Error: Error 'Table 'zabbix.history_uint' doesn't exist' on query. Default database: 'zabbix'. Query: 'insert into history_uint (itemid,clock,ns,value) values (23287,1602301747,810415730,1)'
 Replicate_Ignore_Server_Ids: 
  Master_Server_Id: 1
1 row in set (0.00 sec)

ERROR: No query specified

報錯處理

[root@localhost ~]# vim /etc/my.cnf

[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (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 slave status \G;
*************************** 1. row ***************************
  Slave_IO_State: Waiting for master to send event
   Master_Host: 192.168.27.136
   Master_User: tom
   Master_Port: 3306
  Connect_Retry: 60
  Master_Log_File: mysql-bin.000001
  Read_Master_Log_Pos: 199126
  Relay_Log_File: mysql-relay.000006
  Relay_Log_Pos: 3950
 Relay_Master_Log_File: mysql-bin.000001
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
  Replicate_Do_DB: 
  Replicate_Ignore_DB: 
  Replicate_Do_Table: 
 Replicate_Ignore_Table: 
 Replicate_Wild_Do_Table: 
 Replicate_Wild_Ignore_Table: 
   Last_Errno: 0
   Last_Error: 
   Skip_Counter: 0
  Exec_Master_Log_Pos: 199126
  Relay_Log_Space: 4240
  Until_Condition: None
  Until_Log_File: 
  Until_Log_Pos: 0
  Master_SSL_Allowed: No
  Master_SSL_CA_File: 
  Master_SSL_CA_Path: 
  Master_SSL_Cert: 
  Master_SSL_Cipher: 
  Master_SSL_Key: 
 Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
  Last_IO_Errno: 0
  Last_IO_Error: 
  Last_SQL_Errno: 0
  Last_SQL_Error: 
 Replicate_Ignore_Server_Ids: 
  Master_Server_Id: 1
1 row in set (0.00 sec)

到此這篇關于zabbix 監控mysql的方法的文章就介紹到這了,更多相關zabbix 監控mysql內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!

標簽:亳州 拉薩 衡陽 嘉興 運城 烏海 齊齊哈爾 澳門

巨人網絡通訊聲明:本文標題《zabbix 監控mysql的方法》,本文關鍵詞  zabbix,監控,mysql,的,方法,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《zabbix 監控mysql的方法》相關的同類信息!
  • 本頁收集關于zabbix 監控mysql的方法的相關信息資訊供網民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    欧美草草影院在线视频| 国产精品女同互慰在线看| 欧美电影一区二区| 精品国产乱子伦一区| 亚洲福利视频三区| 91免费在线看| 亚洲精品老司机| 北岛玲一区二区三区四区| 日韩精品一区在线| 精品一区二区三区欧美| 2023国产精品| 国产99久久久久久免费看农村| 日韩女优av电影| 国内一区二区视频| 久久午夜羞羞影院免费观看| 国产精品一区二区久久精品爱涩| 欧美xxxx老人做受| 国产成人午夜99999| 久久精品人人做人人综合| 美女高潮久久久| 精品国产乱码91久久久久久网站| 国产美女久久久久| 久久久久综合网| 色综合久久天天| 亚洲欧美偷拍另类a∨色屁股| 97精品久久久久中文字幕| 亚洲欧美另类久久久精品| 欧洲国内综合视频| 亚洲国产高清在线观看视频| 亚洲激情图片qvod| 国产精品久久久久久久久久久免费看 | 亚洲福利视频导航| 欧美三区在线视频| 精品一区二区精品| 亚洲欧洲色图综合| 91丨九色丨蝌蚪丨老版| 日韩在线卡一卡二| 久久影音资源网| 99热精品一区二区| 免费观看成人av| 国产精品乱码一区二三区小蝌蚪| 欧美放荡的少妇| 99久久精品国产网站| 精品一区二区三区久久久| 亚洲一区二区三区精品在线| 久久一区二区三区四区| 欧美日韩亚洲高清一区二区| 成人精品免费视频| 久草中文综合在线| 亚洲一区电影777| 中文字幕免费一区| 精品理论电影在线| 制服丝袜中文字幕一区| 欧日韩精品视频| 色婷婷亚洲精品| eeuss鲁片一区二区三区| 国产尤物一区二区在线 | 中文字幕亚洲电影| 精品久久人人做人人爰| 777久久久精品| 欧洲一区二区av| 91亚洲资源网| 成人国产精品免费观看动漫| 韩国在线一区二区| 日本 国产 欧美色综合| 久久免费精品国产久精品久久久久| 日韩欧美电影在线| 国产亚洲精品免费| 亚洲欧美日韩国产中文在线| 五月天网站亚洲| www.在线成人| 久久综合av免费| 日本 国产 欧美色综合| 色国产精品一区在线观看| 日韩美女视频在线| 一区二区三区四区中文字幕| 久久99精品久久久久久国产越南 | 日韩免费视频一区二区| 亚洲美女屁股眼交3| 另类小说图片综合网| 日韩一区二区三区免费观看| 亚洲成av人片在线| 欧美日本乱大交xxxxx| 色欧美88888久久久久久影院| 国产精品素人一区二区| 亚洲精品视频自拍| 精品夜夜嗨av一区二区三区| 国产精品久久久久一区| 久久夜色精品国产噜噜av| 欧美在线一区二区| 九九热在线视频观看这里只有精品| 一区二区三区.www| 3d成人动漫网站| 久久久不卡影院| 69堂亚洲精品首页| 99久久国产免费看| 欧美疯狂性受xxxxx喷水图片| 激情综合色综合久久| 91麻豆精品国产自产在线| 九色综合狠狠综合久久| 久久久三级国产网站| 波多野结衣视频一区| 亚洲欧美欧美一区二区三区| 欧美日韩情趣电影| 开心九九激情九九欧美日韩精美视频电影 | 亚洲欧美色图小说| 成人精品一区二区三区中文字幕| 日韩码欧中文字| 日韩美女在线视频| 欧美四级电影网| 成人性生交大片免费看视频在线 | 亚洲激情在线激情| 欧美亚洲高清一区| 成人免费福利片| 日韩不卡手机在线v区| 亚洲天堂网中文字| 国产香蕉久久精品综合网| 欧美无砖砖区免费| 99久久伊人久久99| 欧美一级高清片| 欧美电影影音先锋| 欧美性大战久久| 欧美私人免费视频| 欧美在线三级电影| 色就色 综合激情| 在线国产电影不卡| 91国偷自产一区二区开放时间 | 欧美日韩五月天| 欧美日韩国产123区| 欧美日韩一级片网站| 欧美日韩高清影院| 日韩欧美国产综合在线一区二区三区| 日本精品裸体写真集在线观看| 99精品久久99久久久久| 91亚洲精华国产精华精华液| 99国产精品久久久久久久久久久| 色视频欧美一区二区三区| 欧美亚洲高清一区二区三区不卡| jizz一区二区| 色av成人天堂桃色av| 91精品久久久久久久91蜜桃| 久久综合九色综合97_久久久| 亚洲人成伊人成综合网小说| 日韩在线一二三区| 成人在线视频首页| 91精品国模一区二区三区| 久久先锋影音av鲁色资源| 亚洲制服丝袜av| 高清不卡在线观看| 欧美一区二区三区在| 亚洲综合一二区| 99热99精品| 中文字幕乱码亚洲精品一区| 欧美aⅴ一区二区三区视频| 日本韩国一区二区三区| 1区2区3区欧美| 成人午夜在线视频| 国产女主播视频一区二区| 精品一区二区国语对白| 欧美精品一区二区三区蜜臀| 日韩高清一级片| 5566中文字幕一区二区电影 | 在线观看91精品国产麻豆| 亚洲欧美自拍偷拍色图| 懂色av一区二区在线播放| 久久视频一区二区| 风间由美一区二区av101| 中日韩av电影| 在线视频你懂得一区| 天涯成人国产亚洲精品一区av| 欧美性三三影院| 天天做天天摸天天爽国产一区| k8久久久一区二区三区| 亚洲男人都懂的| 精品少妇一区二区三区视频免付费| 久久99精品久久只有精品| 国产精品无人区| 成人禁用看黄a在线| 亚洲一二三四久久| 日韩美女一区二区三区四区| 国产另类ts人妖一区二区| 欧美精品一区二区久久久| 国产999精品久久久久久绿帽| 亚洲免费色视频| 欧美一区二区三级| 不卡的av中国片| 激情综合网最新| 一区二区三区国产豹纹内裤在线| 91浏览器打开| 国产精品亚洲第一| 亚洲18影院在线观看| 国产精品免费观看视频| 91福利视频久久久久| 国产乱人伦偷精品视频免下载| 亚洲高清不卡在线观看| 国产欧美日韩精品一区| 日韩欧美的一区二区| 色婷婷精品大视频在线蜜桃视频| 国产乱色国产精品免费视频| 国产一区在线视频|