共計 7236 個字符,預計需要花費 19 分鐘才能閱讀完成。
這篇文章將為大家詳細講解有關 MySQL 監控工具中 orzdba 怎么安裝,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
安裝 orzdba
代碼 SVN 地址:http://code.taobao.org/p/orzdba/src/trunk/
說明:Perl 腳本,用于對 Linux 主機和 MySQL 相關指標進行實時監控。
修改代碼 160 行左右配置 MySQL 的相關驗證信息, 如 username,password,host,port,sock 等
安裝 tcprstat
安裝 orzdba_rt_depend_perl_module.tar.gz 依賴包(version 模塊、Class-Data-Inheritable 模塊、Module-Build 模塊、File-Lockfile 模塊)
shell grep -n my $MYSQL orzdba
160:my $MYSQL = qq{mysql -s –skip-column-names -uroot -P$port};
shell chmod +x orzdba
shell ./orzdba –help
==========================================================================================
Info :
Created By zhuxu@taobao.com
Usage :
Command line options :
-h,–help Print Help Info.
-i,–interval Time(second) Interval. # 數據抓取間隔 (秒)
-C,–count Times. # 抓取總次數
-t,–time Print The Current Time.
-nocolor Print NO Color.
-l,–load Print Load Info.
-c,–cpu Print Cpu Info.
-s,–swap Print Swap Info.
-d,–disk Print Disk Info.
-n,–net Print Net Info.
-P,–port Port number to use for mysql connection(default 3306).
-S,–socket Socket file to use for mysql connection.
-com Print MySQL Status(Com_select,Com_insert,Com_update,Com_delete).
-hit Print Innodb Hit%.
-innodb_rows Print Innodb Rows Status(Innodb_rows_inserted/updated/deleted/read).
-innodb_pages Print Innodb Buffer Pool Pages Status(Innodb_buffer_pool_pages_data/free/dirty/flushed)
-innodb_data Print Innodb Data Status(Innodb_data_reads/writes/read/written)
-innodb_log Print Innodb Log Status(Innodb_os_log_fsyncs/written)
-innodb_status Print Innodb Status from Command: Show Engine Innodb Status
(history list/ log unflushed/uncheckpointed bytes/ read views/ queries inside/queued)
-T,–threads Print Threads Status(Threads_running,Threads_connected,Threads_created,Threads_cached).
-rt Print MySQL DB RT(us).
-B,–bytes Print Bytes received from/send to MySQL(Bytes_received,Bytes_sent).
-mysql Print MySQLInfo (include -t,-com,-hit,-T,-B).
-innodb Print InnodbInfo(include -t,-innodb_pages,-innodb_data,-innodb_log,-innodb_status)
-sys Print SysInfo (include -t,-l,-c,-s).
-lazy Print Info (include -t,-l,-c,-s,-com,-hit).
-L,–logfile Print to Logfile.
-logfile_by_day One day a logfile,the suffix of logfile is yyyy-mm-dd
and is valid with -L.
Sample :
shell nohup ./orzdba -lazy -d sda -C 5 -i 2 -L /tmp/orzdba.log /dev/null 2 1
==========================================================================================
查看 Linux 主機指標
shell ./orzdba -sys -C 10 -i 1 -t -d sda
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep…Chinese English~ |
=============== Date : 2014-12-31 ===============
HOST: rac3 IP: 127.0.0.1
——– —–load-avg—- —cpu-usage— —swap— ————————-io-usage———————–
time | 1m 5m 15m |usr sys idl iow| si so| r/s w/s rkB/s wkB/s queue await svctm %util|
02:14:13| 0.08 0.02 0.01| 0 0 100 0| 0 0| 0.3 0.3 7.7 2.7 0.0 6.0 2.0 0.1|
02:14:14| 0.08 0.02 0.01| 0 3 97 0| 0 0| 0.0 3.0 0.0 11.9 0.0 4.0 1.3 0.4|
02:14:15| 0.08 0.02 0.01| 0 3 97 0| 0 0| 0.0 6.7 0.0 30.5 0.0 2.1 0.7 0.5|
02:14:16| 0.08 0.02 0.01| 0 2 98 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
02:14:17| 0.08 0.02 0.01| 0 3 97 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
02:14:18| 0.07 0.02 0.00| 0 3 96 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
02:14:19| 0.07 0.02 0.00| 0 3 97 0| 0 0| 0.0 1.9 0.0 7.5 0.0 4.0 2.0 0.4|
02:14:20| 0.07 0.02 0.00| 0 4 96 0| 0 0| 0.0 5.0 0.0 51.7 0.0 0.8 0.4 0.2|
02:14:21| 0.07 0.02 0.00| 0 3 96 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
02:14:22| 0.07 0.02 0.00| 0 4 96 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
02:14:23| 0.07 0.02 0.00| 0 3 97 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
-sys:打印系統信息,包括 -t(打印當前時間)、-l(打印負載信息,分 1 分鐘、5 分鐘、15 分鐘)、-c(打印 cpu 信息)、-s(打印交換分區信息)
-d:打印磁盤信息,需要指點磁盤設備名
-n:打印網絡信息,接收和發送大小,需要指點網卡設備名
查看 DISK(-d)和 NET(-n)需要帶具體的設備名(具體可以查看 /proc/diskstats 和 /proc/net/dev 中的設備或者可以取自 iostat
和 sar -n DEV)
Linux 指標的數據都來自 /proc 目錄下的相關系統元數據:
LOAD : /proc/loadavg
CPU : /proc/stat
SWAP : /proc/vmstat
DISK : /proc/diskstats
NET : /proc/net/dev
查看 MySQL 響應時間 (rt)
通過調用 tcprstat 來監控 MySQL 的響應時間。
shell ./orzdba -rt -C 10 -i 1 -t -d sda
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep…Chinese English~ |
=============== Date : 2014-12-31 ===============
——– ————————-io-usage———————– ——–tcprstat(us)——–
time | r/s w/s rkB/s wkB/s queue await svctm %util| count avg 95-avg 99-avg|
01:53:22| 0.0 0.0 0.1 0.0 0.0 0.4 0.4 0.0| 0 0 0 0|
01:53:24| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:25| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:26| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:27| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:28| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:29| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:30| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:31| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:32| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
01:53:33| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0| 0 0 0 0|
監控 InnoDB 的性能指標
shell ./orzdba -innodb -C 10 -i 1
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep…Chinese English~ |
=============== Date : 2014-12-31 ===============
——– —innodb bp pages status– —–innodb data status—- –innodb log– his –log(byte)– read —query—
time | data free dirty flush| reads writes read written|fsyncs written| list uflush uckpt view inside que|
01:48:38| 0 0 0 0| 0 0 0 0| 0 0| 0 0 0 0 0 0|
01:48:39| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:40| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:41| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:42| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:43| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:44| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:45| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:46| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:47| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
01:48:48| 638 7553 0 0| 0 0 0 0| 0 0| 350 0 0 0 0 0|
監控 MySQL Server 性能
shell ./orzdba -mysql -C 10 -i 1
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep…Chinese English~ |
=============== Date : 2014-12-31 ===============
——– -QPS- -TPS- -Hit%- ——threads—— —–bytes—-
time | ins upd del sel iud| lor hit| run con cre cac| recv send|
01:45:58| 0 0 0 0 0| 0 100.00| 0 0 0 0| 0 0|
01:45:59| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:01| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:02| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:03| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:04| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:05| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:06| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:07| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:08| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
01:46:09| 0 0 0 1 0| 0 100.00| 1 2 0 0| 839 1k|
安裝問題:
Usage: Socket::inet_ntoa(ip_address_sv) at ./orz line 477
因主機名不能解析,將主機名和 IP 寫到 /etc/hosts 文件。
關于“MySQL 監控工具中 orzdba 怎么安裝”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。