orzdba安装与使用

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

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


安装:

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

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

还有一个依赖命令:

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/trunk

或者这样也可以

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。

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

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

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

这个时候就可以用了.


使用:

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

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
29
30
31
32
33
34
35
. /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的各项指标:

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
29
30
31
32
. /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性能:

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
29
30
31
32
33
34
35
36
. /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|

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

1
2
#查看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

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




     本文转自arthur376 51CTO博客,原文链接:http://blog.51cto.com/arthur376/1888931,如需转载请自行联系原作者





相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
7月前
|
Kubernetes Linux 网络安全
安装k8s
完成安装k8s集群以后,推荐使用[https://github.com/512team/dhorse](https://github.com/512team/dhorse)发布应用。 ## 准备环境 准备两台服务器节点,如果需要安装虚拟机,可以参考[《wmware和centos安装过程》](https://blog.csdn.net/huashetianzu/article/details/109510266) | 机器名 | IP | 角色 | CPU | 内存 | | :----: | :----: | :----: | :----: | :----: | | centos01 |
|
9月前
|
NoSQL 网络安全 Redis
redisd的简易安装运用
redisd的简易安装运用
48 0
|
Web App开发 存储 缓存
Tampermonkey的安装与使用
Tampermonkey 是一款免费的浏览器扩展和最为流行的用户脚本管理器,虽然有些受支持的浏览器拥有原生的用户脚本支持,但 Tampermonkey 将在您的用户脚本管理方面提供更多的便利。 它提供了诸如便捷脚本安装、自动更新检查、标签中的脚本运行状况速览、内置的编辑器等众多功能, 同时Tampermonkey还有可能正常运行原本并不兼容的脚本。
406 0
Tampermonkey的安装与使用
|
算法 Ubuntu Linux
fsarchiver安装及使用
fsarchiver安装及使用
567 0
|
C++
VS2019 的安装
安装固性能速度会比较快;
780 0
VS2019 的安装
|
Python 开发工具 git
|
Shell 数据库 Windows
KBEngine 安装
其实这篇的内容官方文档都有, 但是既然打算记录一下学习笔记, 也就先从安装开始了. 一 下载源代码 进入github下载最新release的源码压缩包. windows选择zip, 下载完成之后右键解压缩.
2428 0