成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

zabbix 監控mysql的方法

瀏覽:284日期:2023-04-06 15:09:37

zabbix部署文檔

zabbix部署完之后

zabbix-agent操作

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

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

2.編寫mysql監控項的腳本

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

[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 33Server version: 5.5.65-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 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/bashmysql="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.confUserParameter=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 ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 33Server version: 5.5.65-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 all on *.* to "check"@"localhost" identified by "123";Query OK, 0 rows affected (0.00 sec)[root@localhost scipts]# vim mysql.sh #!/bin/bashmysql="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 ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 7Server version: 5.5.65-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 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 ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 2Server version: 5.5.65-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)]> 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: NULLMaster_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: 11 row in set (0.00 sec)ERROR: No query specified

報錯處理

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

[root@localhost ~]# systemctl restart mariadb[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 4Server version: 5.5.65-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 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: 0Master_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: 11 row in set (0.00 sec)

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

標簽: Zabbix
相關文章:
成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久
国产精品全国免费观看高清 | 懂色一区二区三区免费观看 | 国产亚洲欧美日韩俺去了| 久久国产精品露脸对白| 久久久久久色| 亚洲成a人v欧美综合天堂下载| 黄页网站一区| 国产精品素人视频| 欧美日韩一区二区三区四区在线观看 | 国产69精品久久777的优势| 亚洲一级二级在线| 麻豆精品视频在线观看视频| 在线中文字幕一区二区| 日本一道高清亚洲日美韩| 亚洲激情啪啪| 一区二区在线观看视频| 中日韩在线视频| 一区二区三区高清不卡| 亚洲视频福利| 91玉足脚交白嫩脚丫在线播放| 亚洲欧美一区二区久久| 9l国产精品久久久久麻豆| 久久久久久久久久久久久久久99 | 欧美亚州在线观看| 日韩美女视频19| 久久综合九色综合欧美狠狠| 国产不卡在线一区| 五月激情丁香一区二区三区| 国产精品伦理在线| 日韩av网站在线观看| 男人的天堂成人在线| 亚洲国产成人porn| 欧美亚洲一区三区| 国产精品88888| 久久精品水蜜桃av综合天堂| 欧美日韩国产在线一区| 最新中文字幕一区二区三区| 亚洲午夜精品久久| 亚洲va中文字幕| 欧美日韩国产小视频在线观看| 国产**成人网毛片九色| 国产亚洲一区二区三区四区| 亚洲欧洲一级| 午夜影院久久久| 欧美电影在线免费观看| 99久久婷婷国产精品综合| 中文字幕第一区| 国产精品永久入口久久久| 蜜臀av性久久久久蜜臀aⅴ| 777久久久精品| 91免费观看国产| 一区二区三区成人| 91精彩视频在线观看| 国产成人精品亚洲777人妖| 国产三级欧美三级| 国产婷婷精品| 久草精品在线观看| 久久综合色之久久综合| 99精品久久| 国精产品一区一区三区mba视频| 亚洲精品在线电影| 夜久久久久久| 国产一区二区女| 国产精品色在线观看| 一本到高清视频免费精品| 成人sese在线| 亚洲精品视频在线| 欧美色图一区二区三区| 91在线观看美女| 午夜精品福利久久久| 日韩欧美123| 亚洲美女黄网| 黄色精品一二区| 国产精品三级av在线播放| 久热综合在线亚洲精品| 99麻豆久久久国产精品免费| 亚洲一区二区三区激情| 欧美不卡123| 国产精品一区二区三区四区五区| 国产一区 二区 三区一级| 国产精品久久久久影视| 欧美亚洲另类激情小说| 色综合天天综合网国产成人综合天 | 国产精品午夜在线| 一本久久精品一区二区| av电影一区二区| 五月综合激情网| 日韩一级片在线观看| 亚洲承认在线| 精品一区二区三区久久久| 久久精品人人做人人综合| 一区二区三区三区在线| 精品一区二区成人精品| 国产精品久久久久国产精品日日 | 欧美jizzhd精品欧美喷水| 丝袜美腿亚洲色图| 日韩精品一区二区在线| 国产精品亚洲不卡a| 懂色av一区二区三区蜜臀| 亚洲国产精品久久人人爱蜜臀| 欧美一级二级在线观看| 国产伦精品一区| kk眼镜猥琐国模调教系列一区二区| 亚洲人成亚洲人成在线观看图片 | 国自产拍偷拍福利精品免费一| 日韩av网站在线观看| 国产精品美女久久久久高潮| 欧美理论电影在线| 国产偷久久久精品专区| 福利电影一区二区三区| 一区二区三区欧美在线观看| 日韩欧美123| 91高清视频在线| 好吊色欧美一区二区三区四区| 国产精品综合久久| 亚洲午夜视频在线观看| 亚洲精品一区二区三区香蕉| 色视频欧美一区二区三区| 欧美三级不卡| 成人在线综合网| 日韩精品国产欧美| 国产清纯美女被跳蛋高潮一区二区久久w | 激情偷乱视频一区二区三区| 亚洲欧美日韩国产手机在线| 欧美福利电影网| 亚洲一区二区在线免费观看| 99久久精品国产导航| 久久福利资源站| 亚洲综合在线观看视频| 久久综合一区二区三区| 欧美日韩国产亚洲一区| 亚洲午夜久久久久久久久久久| 精品久久久网站| 欧美三级中文字幕| 亚洲欧美日韩国产综合精品二区 | 亚洲精品乱码久久久久久久久| 欧美大片免费久久精品三p| 91久久精品网| 免费一级欧美片在线播放| 欧美日韩国内| 99精品视频一区| 国产精品一区二区三区四区| 日本女人一区二区三区| 亚洲黄色尤物视频| 国产精品全国免费观看高清| 欧美成人精精品一区二区频| 欧美日韩精品欧美日韩精品| 久久久777| 国产精品区一区| 亚洲国产激情| 国产在线日韩| 欧美日韩一区二区高清| 91小视频免费看| 成人黄色小视频| 国产成人午夜99999| 久国产精品韩国三级视频| 三级在线观看一区二区 | 亚洲美女屁股眼交3| 国产精品理论片| 久久精品男人的天堂| www激情久久| 欧美电视剧在线看免费| 91精品麻豆日日躁夜夜躁| 欧美丝袜丝交足nylons图片| 美女精品国产| 国产精品久久久对白| 9国产精品视频| 亚洲三级国产| 夜夜爽99久久国产综合精品女不卡| 精品av久久久久电影| 在线观看日韩av电影| 激情婷婷亚洲| 伊人久久大香线蕉综合热线 | 欧美在线啊v一区| 国产一区二区三区成人欧美日韩在线观看 | 欧美激情一区二区| 国产日韩欧美电影| 中文字幕的久久| 中文字幕五月欧美| 亚洲天堂免费看| 亚洲精品国产无天堂网2021| 一区二区三区美女| 亚洲第一成人在线| 视频一区二区三区在线| 日韩精品成人一区二区在线| 日韩成人精品视频| 另类中文字幕网| 精品一区二区av| 国产成人在线视频网站| 成人h动漫精品一区二| 97se亚洲国产综合自在线| 欧美成人国产| 国一区二区在线观看| 一本一本久久| 亚洲影视在线| 欧美在线观看一区| 911精品国产一区二区在线| 日韩精品一区二区三区在线| 久久久精品国产免费观看同学| 亚洲国产成人午夜在线一区|