• mysqladmin在SuSE linux系统中--sleep參数使用不准确问题


    我们都知道,在MySQL中。能够使用mysqladmin命令的extended-status选项来查看MySQL的执行状态,比方获取我们经常关注的几个值:

    # mysqladmin -uroot -proot ext |grep "Questions|Queries|Innodb_rows|Com_select |Com_insert |Com_update |Com_delete "
    | Com_delete                               | 26750       |
    | Com_insert                               | 347420      |
    | Com_select                               | 1341126     |
    | Com_update                               | 454425      |
    | Innodb_rows_deleted                      | 26590       |
    | Innodb_rows_inserted                     | 347416      |
    | Innodb_rows_read                         | 2964050     |
    | Innodb_rows_updated                      | 695605      |
    | Queries                                  | 2304578     |
    | Questions                                | 2259777     |
    但这样得到的数值都累计的。假设想了解当前的状态。则须要进行一次差值计算。而庆幸的是,这个client工具提供了两个參数,这样就能实时的得到当前数据库的相关參数值:

    -i, --sleep=#       Execute commands again and again with a sleep between,单位是秒

    -r, --relative        Show difference between current and previous values when
                                          used with -i. Currently works only with extended-status.

    # mysqladmin -uroot -proot ext -i 1 -r |grep "Questions|Queries|Innodb_rows|Com_select |Com_insert |Com_update |Com_delete "
    | Com_delete                               | 26750       |
    | Com_insert                               | 347420      |
    | Com_select                               | 1341129     |
    | Com_update                               | 454425      |
    | Innodb_rows_deleted                      | 26590       |
    | Innodb_rows_inserted                     | 347416      |
    | Innodb_rows_read                         | 2964050     |
    | Innodb_rows_updated                      | 695605      |
    | Queries                                  | 2304592     |
    | Questions                                | 2259791     |
    这样就得到了MySQL当前数据库每秒中相应值。非常直观,这个命令在RHEL 6.4 x86_64系统上能够正常使用。但在SuSE linux 11sp1 x86_64系统中,却是不准确的。即使用-i(或--sleep=)指定刷新的秒数,但事实并不是如此。

    在測试中。常常是指定了--sleep=1,但显示结果却是大概1分多钟刷新一次,很奇怪。但在使用strace跟踪发现了原因:

    # strace mysqladmin -uroot -proot ext -i 1 -r |grep "Questions|Queries|Innodb_rows|Com_select |Com_insert |Com_update |Com_delete "
    execve("/usr/bin/mysqladmin", ["mysqladmin", "-uroot", "-proot", "ext", "-i", "1", "-r"], [/* 59 vars */]) = 0
    brk(0)                                  = 0x62a000
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0c036fe000
    access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
    open("/usr/lib64/mysql/tls/x86_64/libmysqlclient.so.15", O_RDONLY) = -1 ENOENT (No such file or directory)
    stat("/usr/lib64/mysql/tls/x86_64", 0x7fffbb00c0f0) = -1 ENOENT (No such file or directory)
    open("/usr/lib64/mysql/tls/libmysqlclient.so.15", O_RDONLY) = -1 ENOENT (No such file or directory)
    stat("/usr/lib64/mysql/tls", 0x7fffbb00c0f0) = -1 ENOENT (No such file or directory)
    open("/usr/lib64/mysql/x86_64/libmysqlclient.so.15", O_RDONLY) = -1 ENOENT (No such file or directory)
    stat("/usr/lib64/mysql/x86_64", 0x7fffbb00c0f0) = -1 ENOENT (No such file or directory)
    open("/usr/lib64/mysql/libmysqlclient.so.15", O_RDONLY) = 3
    read(3, "177ELF2113>13002621"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=1420448, ...}) = 0
    mmap(NULL, 3521032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0c03185000
    fadvise64(3, 0, 3521032, POSIX_FADV_WILLNEED) = 0
    mprotect(0x7f0c032ac000, 2093056, PROT_NONE) = 0
    mmap(0x7f0c034ab000, 217088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x126000) = 0x7f0c034ab000
    mmap(0x7f0c034e0000, 2568, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f0c034e0000
    close(3)                                = 0
    ……  <==== 省略若干 ====>
    write(1, "+-------------------------------"..., 4096) = 4096
    write(1, "                  | 0           "..., 4096) = 4096
    write(1, "       |
    | Com_truncate         "..., 4096) = 4096
    write(1, "ze                         | 163"..., 4096) = 4096
    rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
    rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
    rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
    <span style="color:#ff0000;">nanosleep({83, 0}</span>,| Com_delete                               | 26750       |
    | Com_insert                               | 347420      |
    | Com_select                               | 1341136     |
    | Com_update                               | 454425      |
    | Innodb_rows_deleted                      | 26590       |
    | Innodb_rows_inserted                     | 347416      |
    | Innodb_rows_read                         | 2964050     |
    | Innodb_rows_updated                      | 695605      |
    | Queries                                  | 2304622     |
    | Questions                                | 2259821     |
    问题就在即使指定的是1秒刷新,但系统调用时却是83s刷新一次:
    nanosleep({83, 0}
    非常可惜。这个功能不在这个系统中使用。更不幸的时。生产环境中的全都SuSE linux 11sp1系统,郁闷......

    准备找个机会,向SUSE原厂问一下,究竟什么情况的。

  • 相关阅读:
    web自动化--如何在不同页面间游刃有余
    web自动化-窗口句柄及位置变化
    [bug] 验证selenium的显式和隐式等待而发现的一个低级错误
    Web自动化
    Appium 实战练习一
    Appium1.9 之 Chromedriver安装方式
    Appium1.9.1 之 Desired Capabilities 释疑
    [BUG]Appium1.9.1 这个问题竟然花了我5分钟进行定位
    Appium1.9.1 部署及结果检验
    selenium 初探
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5171558.html
Copyright © 2020-2023  润新知