orzdba的安装
--orztop工具也可以看看(实时查看当前processlist和full processlist)
只能在本地服务器上运行,因为使用tcprstat收集信息
源码地址
http://code.taobao.org/svn/orzdba/trunk/
# chmod +x orzdba
tcprstat工具安装与使用
使用方法:
tcprstat是安装在server端,统计分析本地网卡地址请求的响应时间,可以用于临时分析,也可定时任务做信息收集
下载
# wget -c https://github.com/Lowercases/tcprstat/archive/v0.3.1.tar.gz
# cp tcprstat-static.v0.3.1.x86_64 tcprstat
# chmod a+x tcprstat
# mv tcprstat /usr/bin/
需要安装的perl依赖包:
yum install perl-Test-Simple
yum install perl-Time-HiRes
yum install perl-ExtUtils-CBuilder
yum install perl-ExtUtils-MakeMaker
yum install perl-DBD-MySQL
yum install perl-DBI
yum install perl-Module-Build-XSUtil
yum install perl-Class-Data-Inheritable.noarch
yum install perl-Module-Signature
yum install perl-Archive-Tar
yum install perl-Pod-Readme
安装Perl的File:LockFfile模块
安装version模块
wget http://search.cpan.org/CPAN/authors/id/J/JP/JPEACOCK/version-0.99.tar.gz
tar -zxvf version-0.99.tar.gz
cd version-0.99
perl Makefile.PL
make
make test
make install
安装安装File::Lockfile模块:
wget http://search.cpan.org/CPAN/authors/id/G/GL/GLORYBOX/File-Lockfile-v1.0.5.tar.gz
tar -zxvf File-Lockfile-v1.0.5.tar.gz
cd File-Lockfile-v1.0.5
perl Build.PL
perl ./Build
perl ./Build test
perl ./Build install
安装Class-Data-Inheritable模块:
wget http://search.cpan.org/CPAN/authors/id/T/TM/TMTM/Class-Data-Inheritable-0.08.tar.gz
tar -zxvf Class-Data-Inheritable-0.08.tar.gz
cd Class-Data-Inheritable-0.08
perl Makefile.PL
make
make test
make install
安装Module-Build模块:
wget http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Module-Build-0.31.tar.gz
tar -zxvf Module-Build-0.31.tar.gz
cd Module-Build-0.31
perl Build.PL
./Build
./Build test
./Build install
# ./orzdba -lazy -rt -S /u01/my3306/run/mysql.sock
count:此间隔内完成的请求数量
avg:此间隔内所有完成的请求,响应的平均时间
95_avg:此间隔内,95%的请求量的平均响应时间,单位微秒,该值较能体现MySQL Server查询的平均响应时间
./orzdba -innodb -S /u01/my3306/run/mysql.sock
远端orzdba: ./orzdba_remote --host=xxx.xxx.xxx.xxx --user=xx --port=3306 -mysql -sys
下载地址: http://down.51cto.com/data/2366812
参数:
-mysql 查看run的线程数,超过cpu个数后说明系统繁忙,有几次我的服务器过1000,服务器就没有反应了。最后检查时很多查询占用了cpu,导致大量的insert等待,又阻塞其它的如delete/update操作。解决的方案时,把这些查询业务迁移到只读库上,只需关注延迟了。
-innodb
-lazy
-sys 远程的指令下,貌似sys的不准
一一列举,现在来看看怎么用:
./orzdba -lazy -rt 2>/dev/null
注释:
count:此间隔内处理完成的请求数量
avg:此间隔内所有完成的请求,响应的平均时间
95_avg:此间隔内,95%的请求量的平均响应时间,单位微妙,该值较能体现MySQL Server的查询平均响应时间
注意:在mysql5.6版本之后,如果明文输出密码会有警告提示,造成输出异常,所以我们需要加上这个参数:2>/dev/null,来把它过滤掉.
监控InnoDB的各项指标:
./orzdba -innodb 2>/dev/null
监控MySQL Server性能:
./orzdba -mysql 2>/dev/null
还有几个稍微列举下,各位自己试试了
#查看Linux主机指标
./orzdba -sys -C 10 -i 1 -t -d sda
-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)
./orzdba -rt -C 10 -i 1 -t -d sda
-C : 打印10次
-i : 间隔1秒
注释:
./orzdba --help
==========================================================================================
Info :
Created By [email protected]
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 &
==========================================================================================
---------------------
作者:NeilNiu
来源:CSDN
原文:https://blog.csdn.net/qq_30353203/article/details/77943987
版权声明:本文为博主原创文章,转载请附上博文链接!