日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

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

zabbix 監控mysql的方法

瀏覽:382日期: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
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
日韩视频久久| 激情久久婷婷| 亚洲黄色网址| 国产精品亚洲欧美一级在线| 一区二区三区国产盗摄| 国产视频一区三区| 红桃视频国产精品| 黄色成人精品网站| 欧美特黄一级| 亚洲婷婷在线| 久久精品动漫| 久久久夜夜夜| 亚洲成人精品| 福利一区二区三区视频在线观看| 欧美精品一卡| 蜜桃tv一区二区三区| 婷婷成人在线| 99亚洲精品| 石原莉奈在线亚洲三区| 蜜臀av在线播放一区二区三区| 欧美特黄视频| 亚洲一区二区动漫| 热久久国产精品| 亚洲一区有码| 日韩一区二区三区在线看| 少妇精品久久久一区二区三区| 日本亚洲最大的色成网站www| 蜜臀av国产精品久久久久| 亚洲高清不卡| 日韩一级网站| 日本亚洲最大的色成网站www | 欧美一区在线观看视频| 日韩视频1区| 国产精品videossex| 国产一区二区三区探花| av亚洲一区二区三区| 亚州av乱码久久精品蜜桃| 蜜桃av一区二区在线观看| 日韩av中文字幕一区二区 | 欧美一级网站| 日韩中文字幕无砖| 日韩一区免费| 国产精品**亚洲精品| 黄色aa久久| 日韩一级网站| 国产欧美日韩一级| 久久青青视频| 亚洲专区欧美专区| 国产另类在线| 日韩精品免费一区二区三区| 国产亚洲一区在线| 欧美日韩黄网站| 国产高清不卡| 亚洲免费观看高清完整版在线观| 国产精品久久久免费| 国产精品黄色片| 久久久蜜桃一区二区人| 亚洲深深色噜噜狠狠爱网站 | 亚洲精品1区2区| 人人爱人人干婷婷丁香亚洲| 麻豆精品蜜桃| 奇米狠狠一区二区三区| 三上悠亚国产精品一区二区三区| 午夜亚洲一区| 日韩.com| 日本亚洲三级在线| 一本大道色婷婷在线| 日韩av一二三| 日韩三区免费| 国产精品视频一区视频二区| 欧美va天堂| 久久99青青| 一区在线免费| 成人污污视频| 日韩欧美精品一区二区综合视频| 韩国精品主播一区二区在线观看| 婷婷亚洲成人| 欧美日韩激情在线一区二区三区| 国产精区一区二区| 免费在线看一区| 神马日本精品| 视频在线观看一区二区三区| 麻豆国产精品| 黄色欧美日韩| 久久婷婷国产| 亚洲精品一二三**| 91精品亚洲| 美女久久精品| 亚洲精品动态| 欧美日韩黑人| 91嫩草亚洲精品| 91欧美极品| 石原莉奈在线亚洲三区| 亚洲成人二区| 97精品国产福利一区二区三区| 日韩二区三区在线观看| 激情综合网址| 精品一区视频| 亚洲精品九九| 亚洲激情中文在线| 久久精品理论片| 亚洲精品伊人| 亚洲免费中文| 亚洲一区成人| 欧美特黄视频| 亚洲不卡av不卡一区二区| 国产一区二区三区不卡视频网站| 国产一精品一av一免费爽爽| 亚洲青青久久| 综合亚洲视频| 婷婷综合社区| 欧美黄色网页| 九色porny丨国产首页在线| 国产精品久久久久久久久久白浆| 欧美精品一区二区久久| 久久久久国产精品一区二区| 蜜桃精品在线| 久久精品影视| 欧美日一区二区| 久久蜜桃av| 91高清一区| 国产在线欧美| 欧美日韩国产高清| 亚洲欧洲一区| 国产美女一区| 亚洲伊人影院| 最新国产精品久久久| 日韩精品午夜视频| 欧美一区自拍| 日本aⅴ精品一区二区三区| 欧美影院视频| 91成人在线网站| 国产精区一区二区| 精品午夜视频| 精品淫伦v久久水蜜桃| 国产精品主播在线观看| 国产精品主播| www.九色在线| 成人日韩在线观看| 午夜欧美精品久久久久久久| 免费视频久久| 日本成人在线网站| 欧美精品99| av日韩中文| 精品亚洲美女网站| 狠狠干综合网| 日韩精选在线| 麻豆久久久久久| 偷拍精品精品一区二区三区| 日韩一级精品| 久久亚洲风情| 亚洲精品韩国| 日韩精品中文字幕一区二区| 麻豆中文一区二区| 免费在线看一区| 久久亚洲国产精品尤物| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美日韩精品一区二区视频| 国产乱码午夜在线视频| 狠狠躁少妇一区二区三区| 国产日韩中文在线中文字幕| 1000部精品久久久久久久久| 午夜av成人| 亚州国产精品| 久久99蜜桃| 日韩av网站免费在线| 日韩成人精品一区| 免费欧美一区| 久久爱www.| 国产精品国码视频| 精品视频网站| 亚洲第一精品影视| 日韩av资源网| 国产精品久久乐| 在线一区欧美| 激情综合自拍| 美女国产精品久久久| 精品视频在线你懂得| 国产美女高潮在线观看| 亚洲手机视频| 国产亚洲一区二区三区啪| 吉吉日韩欧美| 99在线|亚洲一区二区| 视频一区日韩精品| 欧美日韩精品一区二区三区视频 | 国产精品一区二区三区av| 国产免费av一区二区三区| 国产乱子精品一区二区在线观看 | 亚洲毛片在线| 欧美激情99| 日韩黄色在线观看| 激情婷婷综合| 鲁大师精品99久久久| 老司机精品久久| 日韩欧美三区| 日韩一区二区三区四区五区| 亚洲四虎影院| 麻豆理论在线观看| 一本大道色婷婷在线| 欧美亚洲一区二区三区|