轉載地址來源:http://blog.51cto.com/arthur376/1888931mysql
orzdba是淘寶DBA團隊開發出來的一個perl監控腳本,主要功能是監控mysql數據庫,也有一些磁盤和cpu的監控選項,好很差用就見仁見智,畢竟各公司需求不盡相同.git
安裝:github
既然是perl腳本,那固然是先裝各類perl相關的依賴包和控件:sql
1
2
|
yum
install
-y perl-Test-Simple.x86_64 perl-Time-HiRes perl-ExtUtils-CBuilder
yum
install
-y perl-ExtUtils-MakeMaker perl-DBD-MySQL perl-DBI perl-Module-Build
|
還有一個依賴命令:shell
1
2
3
4
5
6
|
#先下載下來
wget http:
//github
.com
/downloads/Lowercases/tcprstat/tcprstat-static
.v0.3.1.x86_64
#移動到/usr/bin
mv
tcprstat-static.v0.3.1.x86_64
/usr/bin/
#作個鏈接
ln
-sf
/usr/bin/tcprstat-static
.v0.3.1.x86_64
/usr/bin/tcprstat
|
而後來下載腳本和依賴包,數據庫
http://code.taobao.org/svn/orzdba/trunkbash
或者這樣也能夠socket
1
2
3
4
5
6
7
8
9
10
|
#先安裝svn客戶端
yum
install
-y subversion
#或
apt-get
install
-y subversion
#而後下載
svn co http:
//code
.taobao.org
/svn/orzdba/trunk
A trunk
/orzdba_rt_depend_perl_module
.
tar
.gz
A trunk
/orzdba
A trunk
/orzdba
工具使用說明.pdf
取出版本 4。
|
----------------------------------------------------------------------------------tcp
這個我已經上傳到51cto了,你們能夠直接去下載,所有在裏面ide
http://down.51cto.com/data/2277755
而後這個也是修改過的腳本,直接修改26-29行的變量就行,不用跳到160行修改,
1
2
3
4
5
|
cat
orzdba
my $used =
'root'
;
#用戶名
my $pswd =
'****'
;
#密碼
my $ipdz =
'127.0.0.1'
;
#ip地址
my $port = 3306;
# -P 端口號
|
-----------------------------------------------------------------------------------
下載回來的包會有個壓縮包,要安裝裏面的控件,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#先解壓
tar
xf orzdba_rt_depend_perl_module.
tar
.gz
#進去解壓後的文件夾
cd
Perl_Module
#裏面有幾個壓縮包,一個個來安裝
tar
xf version-0.99.
tar
.gz
cd
version-0.99
perl Makefile.PL
make
make
install
cd
..
tar
xf File-Lockfile-v1.0.5.
tar
.gz
cd
File-Lockfile-v1.0.5
perl Build.PL
perl .
/Build
perl .
/Build
install
cd
..
tar
xf Class-Data-Inheritable-0.08.
tar
.gz
cd
Class-Data-Inheritable-0.08
perl Makefile.PL
make
make
install
cd
..
tar
xf Module-Build-0.31.
tar
.gz
cd
Module-Build-0.31
perl Build.PL
.
/Build
.
/Build
install
|
固然了,還要改下配置,否則你怎麼確認他連的是哪裏呢?
1
2
3
4
5
6
7
8
9
|
#須要在代碼160行左右配置MySQL的相關驗證信息,如username,password,host,port,sock等,改爲相似下面這樣
#若是你是用我上傳到51cto的包,那就改26-29行就好了
grep
-n
'my $MYSQL'
orzdba
160:my $MYSQL = qq{mysql -s --skip-column-names -uroot -p123123 -h127.0.0.1 -P$port };
#而後改一下host信息,否則會報錯(不要在乎個人計算機名)
cat
/etc/hosts
172.17.0.2 32044b19ae8c
#最後,加個執行權限吧
chmod
+x orzdba
|
這個時候就能夠用了.
使用參數說明
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 &
監控InnoDB的各項指標: ./orzdba -innodb 2>/dev/null
監控MySQL Server性能: ./orzdba -mysql 2>/dev/null
展現內容:load-avg、cpu-usage、swap、QPS、TPS、Hit%、threads、bytes:
./orzdba -mysql -lazy