行使mysqladmin检查和测试MySQL运维情况的课程

pt-mext完结的效果比较不难,正是将mysqladmin输出的反复迭代的等同status变量值放到同一行输出。

pt-mext实现的意义相比简单,正是将mysqladmin输出的再三迭代的如出一辙status变量值放到同一行输出。

pt-mext,mext奖学金

pt-mext达成的功用比较简单,便是将mysqladmin输出的反复迭代的一样status变量值放到同一行输出。

 

参数很少,除了–help和–version外,唯有四个–relative参数

short form: -r
Subtract each column from the previous column.

 

辅助三种用法:

  1. 一向对输出举行联谊

pt-mext -r — mysqladmin ext -i1 -c3

瞩目:上述命令中会有二回迭代,但只会输出第③回的结果,首次和第三回相差的结果。

其中,

行使mysqladmin检查和测试MySQL运维情况的课程。-i, –sleep=#       Execute commands repeatedly with a sleep between.

-c, –count=# Number of iterations to make. This works with
-i (–sleep) only.

extended-status Gives an extended status message from the server

[[email protected] ~]# pt-mext -r -- mysqladmin ext -i1 -c3
Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             2243      35
Bytes_sent                               158346    9246
......

 

上述命令若是不加-r参数的话,则形容输出。

# pt-mext — mysqladmin ext -i1 -c3

Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             1681    1716
Bytes_sent                               102690  111935
.....

 

  1. 对文件文件举行联谊

pt-mext -r — cat mysqladmin-output.txt

 

只顾:无论是或不是带-r参数,最后壹遍的迭代结果都不会纳入输出的限定。

 

关于它的规律,可参看官方文书档案的表达

pt-mext executes the COMMAND you specify, and reads through the result one line at a time. It places each line into a
temporary file. When it finds a blank line, it assumes that a new sample of SHOW GLOBAL STATUS is starting, and
it creates a new temporary file. At the end of this process, it has a number of temporary files. It joins the temporary
files together side-by-side and prints the result. If --relative option is given, it first subtracts each sample from
the one after it before printing results.

即每一回迭代的结果都会放入到贰个一时文件中,然后对这几个一时半刻文件举行join。

实则,该脚本的功用不限于mysqladmin的status变量值

正如所示:

# cat 4.txt

one 1  
two 2

one 2
two 3
three 4

one 3
two 4

 

# pt-mext — cat 4.txt 

one                                           1 2
two                                           2 3

 

pt-mext贯彻的功能相比不难,正是将mysqladmin输出的反复迭代的一样status变量值放到同一行输出。
参数很少,除了–help和…

选拔mysqladmin检查和测试MySQL运营情形的学科,mysqladminmysql

mysqladmin是MySQL2个关键的客户端,最广泛的是利用它来关闭数据库,除此,该命令还是能驾驭MySQL运维状态、进程新闻、进程杀死等。本文介绍一下怎样接纳mysqladmin
extended-status(因为尚未”歧义”,所以能够使用ext代替)驾驭MySQL的运维状态。

1. 使用-r/-i参数

运用mysqladmin extended-status命令能够赢得全数MySQL品质指标,即show
global
status的出口,不过,因为大部分那些指标都是一起值,如若想精通当前的情景,则要求进行一遍差值总结,那就是mysqladmin
extended-status的一个相当功效,相当实用。默许的,使用extended-status,看到也是一起值,可是,加上参数-r(–relative),就能够看看种种目的的差值,同盟参数-i(–sleep)就足以钦定刷新的频率,那么就有如下命令:

mysqladmin -uroot -r -i 1 -pxxx extended-status
+------------------------------------------+----------------------+
| Variable_name              | Value        |
+------------------------------------------+----------------------+
| Aborted_clients             | 0          |
| Com_select                | 336         |
| Com_insert                | 243         |
......
| Threads_created             | 0          |
+------------------------------------------+----------------------+

2. 配合grep使用

匹配grep使用,大家就有:

mysqladmin -uroot -r -i 1 -pxxx extended-status \
|grep "Questions\|Queries\|Innodb_rows\|Com_select \|Com_insert \|Com_update \|Com_delete "
| Com_delete                | 1          |
| Com_delete_multi             | 0          |
| Com_insert                | 321         |
| Com_select                | 286         |
| Com_update                | 63          |
| Innodb_rows_deleted           | 1          |
| Innodb_rows_inserted           | 207         |
| Innodb_rows_read             | 5211         |
| Innodb_rows_updated           | 65          |
| Queries                 | 2721         |
| Questions                | 2721         |

3. 卓殊简单的awk使用

运用awk,同时输出时间新闻:

mysqladmin -uroot -p -h127.0.0.1 -P3306 -r -i 1 ext |\
awk -F"|" '{\
 if($2 ~ /Variable_name/){\
  print " <-------------  " strftime("%H:%M:%S") "  ------------->";\
 }\
 if($2 ~ /Questions|Queries|Innodb_rows|Com_select |Com_insert |Com_update |Com_delete |Innodb_buffer_pool_read_requests/)\
  print $2 $3;\
}'
<-------------  12:38:49  ------------->
 Com_delete               0
 Com_insert               0
 Com_select               0
 Com_update               0
 Innodb_buffer_pool_read_requests    589
 Innodb_rows_deleted          0
 Innodb_rows_inserted          2
 Innodb_rows_read            50
 Innodb_rows_updated          50
 Queries                105
 Questions               1
 <-------------  12:38:50  ------------->
 Com_delete               0
 Com_insert               0
 Com_select               0
 Com_update               0
 Innodb_buffer_pool_read_requests    1814
 Innodb_rows_deleted          0
 Innodb_rows_inserted          0
 Innodb_rows_read            8
 Innodb_rows_updated          8
 Queries                17
 Questions               1

4. 拾叁分复杂一点的awk

左右也不不难了,那就更复杂一点,那样让输出结果更融洽点,因为awk不支持动态变量,所以代码看起来相比复杂:

mysqladmin -P3306 -uroot -p -h127.0.0.1 -r -i 1 ext |\
awk -F"|" \
"BEGIN{ count=0; }"\
'{ if($2 ~ /Variable_name/ && ((++count)%20 == 1)){\
  print "----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --";\
  print "---Time---|---QPS---|select insert update delete| read inserted updated deleted|  logical  physical";\
}\
else if ($2 ~ /Queries/){queries=$3;}\
else if ($2 ~ /Com_select /){com_select=$3;}\
else if ($2 ~ /Com_insert /){com_insert=$3;}\
else if ($2 ~ /Com_update /){com_update=$3;}\
else if ($2 ~ /Com_delete /){com_delete=$3;}\
else if ($2 ~ /Innodb_rows_read/){innodb_rows_read=$3;}\
else if ($2 ~ /Innodb_rows_deleted/){innodb_rows_deleted=$3;}\
else if ($2 ~ /Innodb_rows_inserted/){innodb_rows_inserted=$3;}\
else if ($2 ~ /Innodb_rows_updated/){innodb_rows_updated=$3;}\
else if ($2 ~ /Innodb_buffer_pool_read_requests/){innodb_lor=$3;}\
else if ($2 ~ /Innodb_buffer_pool_reads/){innodb_phr=$3;}\
else if ($2 ~ /Uptime / && count >= 2){\
 printf(" %s |%9d",strftime("%H:%M:%S"),queries);\
 printf("|%6d %6d %6d %6d",com_select,com_insert,com_update,com_delete);\
 printf("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);\
 printf("|%10d %11d\n",innodb_lor,innodb_phr);\
}}'

----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --
---Time---|---QPS---|select insert update delete| read inserted updated deleted|  logical  physical
 10:37:13 |   2231|  274  214   70   0| 4811   160   71    0|   4146      0
 10:37:14 |   2972|  403  256   84   23| 2509   173   85   23|   4545      0
 10:37:15 |   2334|  282  232   66   1| 1266   154   67    1|   3543      0
 10:37:15 |   2241|  271  217   66   0| 1160   129   66    0|   2935      0
 10:37:17 |   2497|  299  224   97   0| 1141   149   95    0|   3831      0
 10:37:18 |   2871|  352  304   74   23| 8202   226   73   23|   6167      0
 10:37:19 |   2441|  284  233   82   0| 1099   121   78    0|   3292      0
 10:37:20 |   2342|  279  242   61   0| 1083   224   61    0|   3366      0

就像此了,那多少个指令本身用的可比多,随手分享出来。

mysqladmin是MySQL叁个生死攸关的客户端,最常见的是利用它来关闭数据库,除此,该命令还可以够…

 

 

参数很少,除了–help和–version外,唯有1个–relative参数

参数很少,除了–help和–version外,唯有3个–relative参数

short form: -r
Subtract each column from the previous column.
short form: -r
Subtract each column from the previous column.

 

 

扶助三种用法:

支持二种用法:

  1. 一向对输出实行联谊
  1. 直接对输出进行联谊

pt-mext -r — mysqladmin ext -i1 -c3

pt-mext -r — mysqladmin ext -i1 -c3

留神:上述命令中会有一遍迭代,但只会输出第①回的结果,第三次和率先次相差的结果。

留意:上述命令中会有三回迭代,但只会输出第二回的结果,第叁回和第①回相差的结果。

其中,

其中,

-i, –sleep=#       Execute commands repeatedly with a sleep between.

-i, –sleep=#       Execute commands repeatedly with a sleep between.

-c, –count=# Number of iterations to make. This works with
-i (–sleep) only.

-c, –count=# Number of iterations to make. This works with
-i (–sleep) only.

extended-status Gives an extended status message from the server

extended-status Gives an extended status message from the server

[root@localhost ~]# pt-mext -r -- mysqladmin ext -i1 -c3
Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             2243      35
Bytes_sent                               158346    9246
......
[root@localhost ~]# pt-mext -r -- mysqladmin ext -i1 -c3
Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             2243      35
Bytes_sent                               158346    9246
......

 

 

上述命令借使不加-r参数的话,则形容输出。

上述命令借使不加-r参数的话,则形容输出。

# pt-mext — mysqladmin ext -i1 -c3

# pt-mext — mysqladmin ext -i1 -c3

Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             1681    1716
Bytes_sent                               102690  111935
.....
Aborted_clients                               0       0
Aborted_connects                              0       0
Binlog_cache_disk_use                         0       0
Binlog_cache_use                              0       0
Binlog_stmt_cache_disk_use                    0       0
Binlog_stmt_cache_use                         0       0
Bytes_received                             1681    1716
Bytes_sent                               102690  111935
.....

 

 

  1. 对文本文件进行联谊
  1. 对文本文件进行联谊

pt-mext -r — cat mysqladmin-output.txt

pt-mext -r — cat mysqladmin-output.txt

 

 

只顾:无论是不是带-r参数,最终2回的迭代结果都不会纳入输出的限量。

小心:无论是不是带-r参数,最终二遍的迭代结果都不会纳入输出的限制。

 

 

关于它的规律,可参照官方文书档案的申明

关于它的规律,可参看官方文书档案的印证

pt-mext executes the COMMAND you specify, and reads through the result one line at a time. It places each line into a
temporary file. When it finds a blank line, it assumes that a new sample of SHOW GLOBAL STATUS is starting, and
it creates a new temporary file. At the end of this process, it has a number of temporary files. It joins the temporary
files together side-by-side and prints the result. If --relative option is given, it first subtracts each sample from
the one after it before printing results.
pt-mext executes the COMMAND you specify, and reads through the result one line at a time. It places each line into a
temporary file. When it finds a blank line, it assumes that a new sample of SHOW GLOBAL STATUS is starting, and
it creates a new temporary file. At the end of this process, it has a number of temporary files. It joins the temporary
files together side-by-side and prints the result. If --relative option is given, it first subtracts each sample from
the one after it before printing results.

即每一次迭代的结果都会放入到3个最近文件中,然后对这几个一时文件进行join。

即每一遍迭代的结果都会放入到八个权且文件中,然后对那个暂且文件实行join。

实际上,该脚本的作用不限于mysqladmin的status变量值

事实上,该脚本的功力不限于mysqladmin的status变量值

如下所示:

一般来说所示:

#997755.com澳门葡京 , cat 4.txt

# cat 4.txt

one 1  
two 2

one 2
two 3
three 4

one 3
two 4
one 1  
two 2

one 2
two 3
three 4

one 3
two 4

 

 

# pt-mext — cat 4.txt 

# pt-mext — cat 4.txt 

one                                           1 2
two                                           2 3
one                                           1 2
two                                           2 3

 

 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website