Mysqladmin incorrect use of--sleep parameters in SuSE Linux systems

Source: Internet
Author: User

As we all know, in MySQL, you can use the Extended-status option of the mysqladmin command to see the running state of MySQL, such as getting several values that we often care about:

# 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                                 &N bsp;| 2304578     | |  Questions                                | 2259777     |
But the resulting values are cumulative, if you want to know the current state, you need to do a difference calculation, and fortunately, the client tool provides two parameters, so that the current database can be in real-time related parameter values:

-I,--sleep=# Execute commands again and again with a sleep between, unit is seconds

-R,--relative Show difference between current and previous values when
Used With-i. Currently works 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     |
This gives the MySQL current database per second of the corresponding value, very intuitive, this command on the Rhel 6.4 x86_64 system can be used normally. However, in the SUSE Linux 11sp1 x86_64 system, it is inaccurate to specify the number of seconds to refresh using-I (or--sleep=), but that is not the case.

In the test, it is often specified--sleep=1, but the display result is about 1 minutes to refresh, very strange. However, the cause was found using strace tracing:

# 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"], [/*/*/*/*/*/]) = 0 BRK (0) = 0x62a000mmap (NULL, 4096, prot_read| Prot_write, map_private| Map_anonymous,-1, 0) = 0x7f0c036fe000access ("/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) = 1ENOENT (No such file or directory) open ("/usr/lib64/mysql/libmysqlclient.so.15", o_rdonly) = 3read (3, "\177elf\2\1\1\0\0 \0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\262\1\0\0\0\0\0 "..., 832) = 832fstat (3, {st_mode=s_ifreg|0755, st_size=1420448 , ...}) = 0mmap (NULL, 3521032, prot_read| Prot_exec, map_private| Map_denywrite, 3, 0) = 0x7f0c03185000fadvise64 (3, 0, 3521032, posix_fadv_willneed) = 0mprotect (0x7f0c032ac000, 2093056, P Rot_none) = 0mmap (0x7f0c034ab000, 217088, prot_read| Prot_write, map_private| map_fixed| Map_denywrite, 3, 0x126000) = 0x7f0c034ab000mmap (0x7f0c034e0000, 2568, prot_read| Prot_write, map_private| map_fixed| Map_anonymous,-1, 0) = 0x7f0c034e0000close (3) = 0 ... <==== omit several ====>write (1, "+---- ---------------------------"..., 4096) = 4096write (1," | 0 "..., 4096) = 4096write (1," |\n| Com_truncate "..., 4096) = 4096write (1," ze | 163 "..., 4096) = 4096rt_sigprocmask (Sig_block, [CHLD], [], 8) = 0rt_sigaction (SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0rt_sigprocmask (Sig_setmask, [], NULL, 8) = 0<span style = "COLOR: #ff0000;" >nanosleep ({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 |
The problem is that even if you specify a 1-second refresh, the system call is 83s refreshed once:
Nanosleep ({83, 0}
Unfortunately, this feature is not used in this system, and more unfortunate when the production environment is all SUSE Linux 11SP1 system, depressed ...

Get ready for a chance to ask the SuSE manufacturer what the situation is.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.