码迷,mamicode.com
首页 > 数据库 > 详细

orzdba安装与使用

时间:2017-01-04 23:59:46      阅读:436      评论:0      收藏:0      [点我收藏+]

标签:mysql orzdba 监控

orzdba是淘宝DBA团队开发出来的一个perl监控脚本,主要功能是监控mysql数据库,也有一些磁盘和cpu的监控选项,好不好用就见仁见智,毕竟各公司需求不尽相同.


安装:

既然是perl脚本,那当然是先装各种perl相关的依赖包和控件:

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

还有一个依赖命令:

#先下载下来
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/trunk

或者这样也可以

#先安装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。

----------------------------------------------------------------------------------

这个我已经上传到51cto了,大家可以直接去下载,全部在里面

http://down.51cto.com/data/2277755

然后这个也是修改过的脚本,直接修改26-29行的变量就行,不用跳到160行修改,

cat orzdba
my  $used = ‘root‘;    #用户名
my  $pswd = ‘****‘;    #密码
my  $ipdz = ‘127.0.0.1‘;    #ip地址
my  $port = 3306;       # -P 端口号

-----------------------------------------------------------------------------------

下载回来的包会有个压缩包,要安装里面的控件,

#先解压
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

当然了,还要改下配置,不然你怎么确认他连的是哪里呢?

#需要在代码160行左右配置MySQL的相关验证信息,如username,password,host,port,sock等,改成类似下面这样
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

这个时候就可以用了.


使用:

当然了,有很多参数,请看最后面一一列举,现在来看看怎么用:

./orzdba -lazy -rt 2>/dev/null 

.=================================================.
|       Welcome to use the orzdba tool !          | 
|          Yep...Chinese English~                 |
‘=============== Date : 2017-01-04 ===============‘

HOST: 32044b19ae8c   IP: 172.17.0.2
DB  : XXX|XXX|XXX
Var : binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[500M] 
      max_connect_errors[100000] max_connections[200] max_user_connections[150] 
      open_files_limit[65535] sync_binlog[0] table_definition_cache[656] 
      table_open_cache[512] thread_cache_size[51] 

      innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[512M] 
      innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[2] innodb_flush_method[] 
      innodb_io_capacity[200] innodb_lock_wait_timeout[10] innodb_log_buffer_size[16M] 
      innodb_log_file_size[512M] innodb_log_files_in_group[2] innodb_max_dirty_pages_pct[35] 
      innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0] 
      innodb_write_io_threads[4] 

-------- -----load-avg---- ---cpu-usage--- ---swap---                     -QPS- -TPS-         -Hit%- --------tcprstat(us)-------- 
  time  |  1m    5m   15m |usr sys idl iow|   si   so|  ins   upd   del    sel   iud|     lor    hit|  count    avg 95-avg 99-avg|
14:43:31| 0.36  0.23  0.17|  1   0  98   0|    0    0|    0     0     0      0     0|       0 100.00|      0      0      0      0|
14:43:32| 0.36  0.23  0.17|  3   1  95   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:33| 0.36  0.23  0.17|  4   2  94   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:34| 0.36  0.23  0.17|  4   1  95   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:35| 0.33  0.23  0.17|  2   1  97   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:36| 0.33  0.23  0.17|  3   1  95   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:37| 0.33  0.23  0.17|  4   1  95   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:38| 0.33  0.23  0.17|  3   1  97   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:39| 0.30  0.22  0.16|  2   1  97   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:40| 0.30  0.22  0.16|  3   1  96   0|    0    0|    0     0     0      8     0|      16 100.00|      0      0      0      0|
14:43:41| 0.30  0.22  0.16|  3   1  97   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|
14:43:42| 0.30  0.22  0.16|  2   1  97   0|    0    0|    0     0     0      1     0|       0 100.00|      0      0      0      0|

注释:
count:此间隔内处理完成的请求数量
avg:此间隔内所有完成的请求,响应的平均时间
95_avg:此间隔内,95%的请求量的平均响应时间,单位微妙,该值较能体现MySQL Server的查询平均响应时间

注意:在mysql5.6版本之后,如果明文输出密码会有警告提示,造成输出异常,所以我们需要加上这个参数:2>/dev/null,来把它过滤掉.

监控InnoDB的各项指标:

./orzdba -innodb 2>/dev/null 

.=================================================.
|       Welcome to use the orzdba tool !          | 
|          Yep...Chinese English~                 |
‘=============== Date : 2017-01-04 ===============‘

HOST: 32044b19ae8c   IP: 172.17.0.2
DB  : xxx|xxx|xxx
Var : binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[500M] 
      max_connect_errors[100000] max_connections[200] max_user_connections[150] 
      open_files_limit[65535] sync_binlog[0] table_definition_cache[656] 
      table_open_cache[512] thread_cache_size[51] 

      innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[512M] 
      innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[2] innodb_flush_method[] 
      innodb_io_capacity[200] innodb_lock_wait_timeout[10] innodb_log_buffer_size[16M] 
      innodb_log_file_size[512M] innodb_log_files_in_group[2] innodb_max_dirty_pages_pct[35] 
      innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0] 
      innodb_write_io_threads[4] 

-------- ---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|
14:48:03|      0      0      0     0|     0      0      0      0|     0       0|    0      0      0     0     0     0|
14:48:04|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:05|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:06|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:07|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:08|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:09|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:10|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|
14:48:11|  29961   1024      0     0|     0      0      0      0|     0       0| 1754      0       0    0     0     0|

监控MySQL Server性能:

./orzdba -mysql 2>/dev/null 

.=================================================.
|       Welcome to use the orzdba tool !          | 
|          Yep...Chinese English~                 |
‘=============== Date : 2017-01-04 ===============‘

HOST: 32044b19ae8c   IP: 172.17.0.2
DB  : xxx|xxx|xxx
Var : binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[500M] 
      max_connect_errors[100000] max_connections[200] max_user_connections[150] 
      open_files_limit[65535] sync_binlog[0] table_definition_cache[656] 
      table_open_cache[512] thread_cache_size[51] 

      innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[512M] 
      innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[2] innodb_flush_method[] 
      innodb_io_capacity[200] innodb_lock_wait_timeout[10] innodb_log_buffer_size[16M] 
      innodb_log_file_size[512M] innodb_log_files_in_group[2] innodb_max_dirty_pages_pct[35] 
      innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0] 
      innodb_write_io_threads[4] 

--------                     -QPS- -TPS-         -Hit%- ------threads------ -----bytes---- 
  time  |  ins   upd   del    sel   iud|     lor    hit| run  con  cre  cac|   recv   send|
14:49:30|    0     0     0      0     0|       0 100.00|   0    0    0    0|      0      0|
14:49:31|    0     0     0      4     0|     179 100.00|   1   79    0   15|     1k    74k|
14:49:32|    0     0     0      5     0|    4228 100.00|   1   79    0   15|     2k     6k|
14:49:33|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:34|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:35|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:36|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:37|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:38|    0     0     0      1     0|       0 100.00|   1   79    0   15|    972     1k|
14:49:39|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:40|    0     0     0      8     0|      16 100.00|   1   79    0   15|     2k     4k|
14:49:41|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|
14:49:42|    0     0     0      1     0|       0 100.00|   1   79    0   15|    846     1k|

还有几个稍微列举下,各位自己试试了

#查看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 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 &
==========================================================================================



orzdba安装与使用

标签:mysql orzdba 监控

原文地址:http://arthur376.blog.51cto.com/2918801/1888931

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!