成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_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国内精品久久久久久久
天堂午夜影视日韩欧美一区二区| 丁香激情综合国产| 国产精品久久久久久户外露出| 日韩一区二区麻豆国产| 欧美一区二区免费| 91精品在线免费观看| 在线播放91灌醉迷j高跟美女| 欧美日本一道本在线视频| 欧美中文一区二区三区| 欧美性受xxxx| 欧美日韩精品综合在线| 7777精品伊人久久久大香线蕉经典版下载| 欧洲精品一区二区三区在线观看| 在线免费观看日韩欧美| 欧美三区在线观看| 3d成人h动漫网站入口| 日韩欧美国产高清| 久久夜色精品一区| 亚洲欧洲日产国码二区| 亚洲一级片在线观看| 亚洲3atv精品一区二区三区| 免费欧美高清视频| 福利91精品一区二区三区| 91视频国产资源| 精品999网站| 久久精品日产第一区二区| 欧美午夜精品免费| 欧美成人一区二区| 1区2区3区欧美| 水野朝阳av一区二区三区| 久久电影国产免费久久电影| 福利一区二区在线观看| 欧美日韩亚洲三区| 亚洲免费婷婷| 538prom精品视频线放| 欧美激情艳妇裸体舞| 一区二区久久久久久| 精品一区二区免费| 女同性一区二区三区人了人一| 亚洲毛片网站| 欧美剧情片在线观看| 欧美国产视频在线| 五月天中文字幕一区二区| 国产成人av电影在线观看| 欧美体内she精视频在线观看| 亚洲欧美久久久| 日韩美女视频在线| 亚洲精品videosex极品| 国产成人综合精品三级| 国产精品高清一区二区三区| 久久午夜精品| 国产欧美日韩在线观看| 男女视频一区二区| 国内精品国语自产拍在线观看| 日本久久一区二区| 国产无遮挡一区二区三区毛片日本| 婷婷六月综合网| 色综合久久综合网欧美综合网| 国产精品一区在线播放| 欧美成人vps| 日本vs亚洲vs韩国一区三区二区| 色综合网色综合| 在线观看日韩国产| 亚洲欧洲综合另类| 97久久久精品综合88久久| 色综合久久88色综合天天6| 国产日产欧美一区| 国产精品88888| 色综合久久久久综合体桃花网| www国产精品av| 久久99国内精品| 国产欧美成人| 国产精品色婷婷久久58| 成人黄色大片在线观看| 欧美性猛交xxxx黑人交| 亚洲男人的天堂在线观看| 色综合一区二区| 日韩精品中午字幕| 精品一区在线看| 免费视频久久| 亚洲男人都懂的| 91免费国产在线| 日韩欧美一二三区| 激情六月婷婷久久| 日本久久电影网| 一区2区3区在线看| 精品不卡一区二区三区| 国产亚洲制服色| 白白色 亚洲乱淫| 欧美肥妇free| 国产一区视频在线看| 免费一级欧美片在线播放| 亚洲免费大片在线观看| 国产一区自拍视频| 中国色在线观看另类| 99re66热这里只有精品3直播 | 国产九九精品| 一区二区三区四区国产精品| 亚洲天堂激情| 亚洲色图欧美偷拍| 合欧美一区二区三区| 亚洲国产成人在线| 欧美不卡一区| 国产精品久久久久毛片软件| 午夜日韩在线| 中文字幕一区二区三区不卡 | 久久一区二区视频| 91尤物视频在线观看| 国产亚洲成aⅴ人片在线观看| caoporn国产精品| 久久久影院官网| 欧美黄色一区| 亚洲少妇30p| 国产欧美一级| 日本女人一区二区三区| 欧美区一区二区三区| 国产一区二区毛片| 精品88久久久久88久久久| av中文字幕不卡| 国产精品欧美极品| 日韩一级网站| 免费观看一级欧美片| 欧美一级在线视频| 91免费版在线看| 一区二区三区四区中文字幕| 麻豆9191精品国产| 国产在线日韩欧美| 2019国产精品| 亚洲精品日韩久久| 久久精品国产亚洲a| 日韩精品一区二区三区四区| 欧美二区不卡| 亚洲mv在线观看| 3atv一区二区三区| 欧美日韩精品免费观看视频完整 | 国产69精品久久久久777| 国产亚洲欧美在线| 亚洲一区二区四区| 国内外精品视频| 国产精品人妖ts系列视频| 欧美亚洲免费| 99视频精品在线| 亚洲一区二区三区中文字幕| 4438亚洲最大| 黄色在线成人| 久久99国产精品麻豆| 国产精品国产三级国产普通话三级| 久久久久一区| 欧美一区视频| 免费成人在线视频观看| 欧美韩国一区二区| 欧美午夜免费电影| 亚洲二区精品| 国产乱码精品一区二区三区忘忧草| 国产精品久久毛片a| 欧美色视频一区| 国内精品久久久久久久97牛牛| 久久福利视频一区二区| 亚洲欧美福利一区二区| 日韩欧美一区在线| 性久久久久久| 91免费看片在线观看| 无吗不卡中文字幕| 亚洲国产精品一区制服丝袜 | 久久精品一级爱片| 欧美色图片你懂的| 91美女在线视频| 亚洲一区二区三区四区在线观看 | 欧美三级视频在线观看| 国内精品视频在线播放| 裸体一区二区三区| 国产欧美一区在线| 久久婷婷丁香| a91a精品视频在线观看| 国产乱人伦偷精品视频不卡| 国产精品人成在线观看免费| 在线观看国产91| 女同性一区二区三区人了人一| 午夜精品123| 国产午夜亚洲精品不卡| 日韩一区二区精品葵司在线| 99国产精品私拍| www.日韩av| 精品无人码麻豆乱码1区2区 | 一本色道久久综合狠狠躁的推荐| 欧美精品偷拍| 国产麻豆午夜三级精品| 亚洲精品老司机| 国产精品三级av在线播放| 91精品国产高清一区二区三区 | 欧美日韩dvd在线观看| 夜夜嗨一区二区三区| 亚洲网站在线| 成人午夜av影视| 美国欧美日韩国产在线播放| 丝袜亚洲另类欧美| 中文字幕综合网| 久久久天堂av| 久久久久久久久久久久久9999| 国产视频在线观看一区|