MySQL 淘宝网开源监控工具orzdba安装、使用

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: 转载:http://blog.51cto.com/arthur376/1888931orzdba是淘宝DBA团队开发出来的一个perl监控脚本,主要功能是监控mysql数据库,也有一些磁盘和cpu的监控选项,好不好用就见仁见智,毕竟各公司需求不尽相同.

转载:http://blog.51cto.com/arthur376/1888931

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

mvtcprstat-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行修改,

catorzdba

my  $used = 'root';    #用户名

my  $pswd = '****';    #密码

my  $ipdz = '127.0.0.1';    #ip地址

my  $port = 3306;       # -P 端口号

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

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

#先解压

tarxf orzdba_rt_depend_perl_module.tar.gz

#进去解压后的文件夹

cdPerl_Module

#里面有几个压缩包,一个个来安装

tarxf version-0.99.tar.gz

cdversion-0.99

perl Makefile.PL

make

makeinstall

cd..

tarxf File-Lockfile-v1.0.5.tar.gz 

cdFile-Lockfile-v1.0.5 

perl Build.PL

perl ./Build

perl ./Buildinstall

cd..

tarxf Class-Data-Inheritable-0.08.tar.gz

cdClass-Data-Inheritable-0.08 

perl Makefile.PL 

make

makeinstall

cd..

tarxf Module-Build-0.31.tar.gz 

cdModule-Build-0.31 

perl Build.PL 

./Build

./Buildinstall

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

#需要在代码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

这个时候就可以用了.

使用:

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

./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   freedirty flush| reads writes  readwritten|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 &

==========================================================================================

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
1天前
|
关系型数据库 MySQL 数据库
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
20 2
|
2天前
|
关系型数据库 MySQL Linux
本地虚拟机centos7通过docker安装主从mysql5.7.21
本地虚拟机centos7通过docker安装主从mysql5.7.21
10 0
|
4天前
|
关系型数据库 MySQL 数据库
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
|
4天前
|
关系型数据库 MySQL Linux
在Centos7中:通过Docker安装MySQL5.7(保姆级)
在Centos7中:通过Docker安装MySQL5.7(保姆级)
|
4天前
|
编解码 安全 关系型数据库
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
|
6天前
|
关系型数据库 MySQL Linux
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
Linux CentOs7 安装Mysql(5.7和8.0版本)密码修改 超详细教程
|
6天前
|
安全 关系型数据库 MySQL
MySQL安装教程
MySQL安装教程
29 0
|
6天前
|
SQL 关系型数据库 MySQL
【简单无脑】自动化脚本一键安装虚拟机下的MySQL服务
该文章提供了在虚拟机上安装MySQL服务的简化方法,特别是针对新手。作者提供了一个自动化脚本`install_mysql.sh`,使得安装过程更简单。用户需要下载`install.rpm`资源,将其放在指定目录下,然后创建并编辑脚本文件,将提供的代码粘贴进去,通过`chmod u+x`授权,最后运行脚本`./install_mysql.sh [rpm文件路径]`来安装MySQL。文章还附有相关图片说明。
17 1
【简单无脑】自动化脚本一键安装虚拟机下的MySQL服务
|
6天前
|
SQL 缓存 关系型数据库
MySQL常见问题解决和自动化安装脚本
这篇内容包含了两个主要部分:解决MySQL登录问题和处理GPG密钥问题。当MySQL密码正确但无法登录时,可以通过执行SQL命令`ALTER USER`和`flush privileges`来修改和重置密码。对于MySQL安装时的GPG密钥错误,首先需要强制删除旧的MySQL仓库包,导入新的GPG公钥,然后安装MySQL服务器。如果遇到GPG检查错误,可以使用`--nogpgcheck`参数忽略检查来安装。最后,提供了一个自动化安装MySQL的脚本,用于检查旧版本、卸载残留、安装MySQL8并启动服务。
22 1
MySQL常见问题解决和自动化安装脚本
|
11天前
|
SQL 关系型数据库 MySQL
【MySQL-3】图形化界面工具DataGrip安装&配置&使用
【MySQL-3】图形化界面工具DataGrip安装&配置&使用