淘宝开源工具:OrzDBA
安装部署:
安装参考文档:http://wenku.baidu.com/view/79ca1eb065ce0508763213bf
1.先需要安装svn客户端以及tcprstat
yum安装即可:yum install -y svn;yuminstall -y tcprstat;
如果yum安装tcprstat提示无包可下载注册,选择集成方式安装tcprstat
wget http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64
cp tcprstat-static.v0.3.1.x86_64 tcprstat
chmod a+x tcprstat
[root@reserve opt]# ./tcprstat -p 3306 -t 1 -n5
timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
1498368673 0 0 0 0 0 0 0 0 0 0 0 0
1498368674 0 0 0 0 0 0 0 0 0 0 0 0
到此tcprstat安装成功
2.然后下载orzdba包:
svn co http://code.taobao.org/svn/orzdba/trunk
cd trunk/
chmod a+x orzdba
[root@reserve opt]# svn cohttp://code.taobao.org/svn/orzdba/trunk
A trunk/orzdba_rt_depend_perl_module.tar.gz
A trunk/orzdba
A trunk/orzdba工具使用说明.pdf
Checked out revision 4.
[root@reserve opt]# cd trunk/
[root@reserve trunk]# ls
orzdba orzdba_rt_depend_perl_module.tar.gz orzdba工具使用说明.pdf
[root@reserve trunk]# cp orzdba orzdba.bak
[root@reserve trunk]# chmod a+x orzdba
大概包括Sys、mysql、innodb、lazy 4个方面的,是一个集大成者,是淘宝的一个工程师写的,它把系统的,我们需要记住lazy就足够用了,用lazy就基本可以满足我们大部分的应用需要了
3.orzdba参数帮助介绍
[root@reserve trunk]# ./orzdba
==========================================================================================
Info :
Created By [email protected]
Usage :
Command line options :
-h,--help Print HelpInfo.
-i,--interval Time(second)Interval.
-C,--count Times.
-t,--time Print TheCurrent Time.
-nocolor Print NOColor.
-l,--load Print LoadInfo.
-c,--cpu Print Cpu Info.
-s,--swap Print SwapInfo.
-d,--disk Print DiskInfo.
-n,--net Print Net Info.
-P,--port Port number touse for mysql connection(default 3306).
-S,--socket Socket file to use for mysql connection.
-com Print MySQLStatus(Com_select,Com_insert,Com_update,Com_delete).
-hit Print Innodb Hit%.
-innodb_rows Print InnodbRows Status(Innodb_rows_inserted/updated/deleted/read).
-innodb_pages Print InnodbBuffer Pool Pages Status(Innodb_buffer_pool_pages_data/free/dirty/flushed)
-innodb_data Print InnodbData Status(Innodb_data_reads/writes/read/written)
-innodb_log Print InnodbLog Status(Innodb_os_log_fsyncs/written)
-innodb_status Print InnodbStatus from Command: 'Show Engine Innodb Status'
(history list/ logunflushed/uncheckpointed bytes/ read views/ queries inside/queued)
-T,--threads Print ThreadsStatus(Threads_running,Threads_connected,Threads_created,Threads_cached).
-rt Print MySQL DB RT(us).
-B,--bytes Print Bytesreceived from/send to MySQL(Bytes_received,Bytes_sent).
-mysql Print MySQLInfo(include -t,-com,-hit,-T,-B).
-innodb PrintInnodbInfo(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 toLogfile.
-logfile_by_day One day alogfile,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 &
==========================================================================================
4.给orzdba脚本添加root密码
orzdba为perl脚本,源脚本未写mysql的root账户的密码,但是当登陆mysql需要root密码时,就必须在此脚本中加入mysql的登陆账户root和root密码,为此在此perl脚本中添加了mysql的账户和密码
5.测试脚本出现的问题
[root@reserve opt]# ./trunk/orzdba -lazy -C 5 -i 2 -L /tmp/orzdba.log
Usage: Socket::inet_ntoa(ip_address_sv) at./trunk/orzdba line 477.
原因是服务器的设置了其他的主机名reseve.cplus.co.cn,但是没有在/etc/hosts 文件中进行本地解析,才导致上面的问题
解析主机名cat /etc/hosts
211.144.69.249 reseve.cplus.co.cn
当主机名是localhost.localdomain也不会出现上面的问题
6.测试:
-lazy 参数介绍:
大概包括Sys、mysql、innodb、lazy 4个方面的,是一个集大成者,是淘宝的一个工程师写的,它把系统的,我们需要记住lazy就足够用了,用lazy就基本可以满足我们大部分的应用需要了
nohup /opt/trunk/orzdba -lazy -C 5 -i 2 -L /tmp/orzdba.log > /dev/null 2>&1 &
-rt参数:tcprstat(us)
nohup ./orzdba -lazy -rt -C 5 -i 2 -L/tmp/orzdba.log > /dev/null2>&1 &
如果你还想看更详细的信息,可以不用lazy,可以用innodb的参数来,可以就看到buffer pool里面的data、free、dirty等,非常全的信息,大家可以作为非常重要的参考,命令如下:
nohup ./orzdba -lazy -innodb -rt -C 5 -i 2-L /tmp/orzdba.log > /dev/null2>&1 &
-B参数
-B,--bytes Print Bytes received from/sendto MySQL(Bytes_received,Bytes_sent)
/opt/trunk/orzdba -mysql -B -C 5 -i 2 -L /tmp/orzdba.log > /dev/null 2>&1 &
-B 加 –T参数使用:
/opt/trunk/orzdba -B -T -C 5 -i 2 -L/tmp/orzdba.log > /dev/null2>&1 &
参考资料:https://wenku.baidu.com/view/79ca1eb065ce0508763213bf
后面附件:orzDBA使用说明PDF版