High load due to MYSQL

General support questions
Post Reply
tejas5555
Posts: 8
Joined: 2018/02/23 11:33:42

High load due to MYSQL

Post by tejas5555 » 2018/03/22 08:54:38

Dear all,
In my server , CPU is continuously under heavy load due to mysql. Also ideal time is 0.
Please find the output of mysqltuner.pl script. Any help to reduce load is appreciated.

-bash-4.1# ./mysqltuner.pl
>> MySQLTuner 1.7.7 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: [OK] Currently running supported MySQL version 5.1.73
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysqld.log(442M)
[OK] Log file /var/log/mysqld.log exists
[OK] Log file /var/log/mysqld.log is readable.
[OK] Log file /var/log/mysqld.log is not empty
[!!] Log file /var/log/mysqld.log is bigger than 32 Mb
[!!] /var/log/mysqld.log contains 1 warning(s).
[!!] /var/log/mysqld.log contains 857631 error(s).
[--] 360 start(s) detected in /var/log/mysqld.log
[--] 1) 180301 15:15:36 [Note] /usr/libexec/mysqld: ready for connections.
[--] 2) 180227 16:44:00 [Note] /usr/libexec/mysqld: ready for connections.
[--] 3) 180222 14:29:14 [Note] /usr/libexec/mysqld: ready for connections.
[--] 4) 180214 12:59:28 [Note] /usr/libexec/mysqld: ready for connections.
[--] 5) 180212 16:17:48 [Note] /usr/libexec/mysqld: ready for connections.
[--] 6) 180212 12:34:39 [Note] /usr/libexec/mysqld: ready for connections.
[--] 7) 180205 11:54:19 [Note] /usr/libexec/mysqld: ready for connections.
[--] 8) 180124 15:32:20 [Note] /usr/libexec/mysqld: ready for connections.
[--] 9) 180124 14:58:11 [Note] /usr/libexec/mysqld: ready for connections.
[--] 10) 171206 18:08:52 [Note] /usr/libexec/mysqld: ready for connections.
[--] 28 shutdown(s) detected in /var/log/mysqld.log
[--] 1) 180301 15:15:34 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 2) 180227 16:43:59 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 3) 180222 14:29:12 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 4) 180214 12:59:26 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 5) 180212 16:17:47 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 6) 180212 12:34:37 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 7) 180205 11:54:18 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 8) 180124 15:32:19 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 9) 180124 14:58:10 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 10) 171206 18:08:51 [Note] /usr/libexec/mysqld: Shutdown complete

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +CSV +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 65G (Tables: 122)
[--] Data in InnoDB tables: 4G (Tables: 621)
[!!] Total fragmented tables: 1

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'cdn@localhost' has user name as password.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 20d 21h 19m 50s (6M q [3.409 qps], 13K conn, TX: 8G, RX: 11G)
[--] Reads / Writes: 23% / 77%
[--] Binary logging is disabled
[--] Physical Memory : 3.7G
[--] Max MySQL memory : 449.2M
[--] Other process memory: 514.8M
[--] Total buffers: 34.0M global + 2.7M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 163.2M (4.36% of installed RAM)
[OK] Maximum possible memory usage: 449.2M (12.01% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (1K/6M)
[OK] Highest usage of available connections: 31% (47/151)
[OK] Aborted connections: 0.06% (8/13524)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 1M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (7 temp sorts / 8K sorts)
[OK] No joins without indexes
[OK] Temporary tables created on disk: 0% (0 on disk / 119K total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 3% (64 open / 2K opened)
[OK] Open file limit used: 0% (182/50K)
[OK] Table locks acquired immediately: 99% (7M immediate / 7M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 100.0% (8M used / 8M cache)
[!!] Key buffer size / total MyISAM indexes: 8.0M/25.3G
[!!] Read Key buffer hit rate: 87.0% (530M cached / 68M reads)
[!!] Write Key buffer hit rate: 69.8% (83M cached / 58M writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 8
[!!] InnoDB File per table is not activated
[!!] InnoDB buffer pool / data size: 8.0M/4.0G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (125 %): 5.0M * 2/8.0M should be equal 25%
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 99.97% (3114982800 hits/ 3115816604 total)
[!!] InnoDB Write Log efficiency: 83.44% (9668047 hits/ 11586898 total)
[!!] InnoDB log waits: 0.01% (107 waits / 1918851 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.

-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.

-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: STATEMENT
[--] XA support enabled: ON
Use of uninitialized value in concatenation (.) or string at ./mysqltuner.pl
line 233 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl will try to tell you the
name of the variable (if any) that was undefined. In some cases it cannot
do this, so it also tells you what operation you used the undefined value
in. Note, however, that perl optimizes your program and the operation
displayed in the warning may not necessarily appear literally in your
program. For example, "that $foo" is usually optimized into "that "
. $foo, and the warning will refer to the concatenation (.) operator,
even though there is no . in your program.

[--]
[--]
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
/var/log/mysqld.log is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!
Control warning line(s) into /var/log/mysqld.log file
Control error line(s) into /var/log/mysqld.log file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE `tendersinfo_com`.`tenders_archive_new`; -- can free 4628.83363723755 MB
Total freed space after theses OPTIMIZE TABLE : 4628.83363723755 Mb
Set up a Secure Password for user@host ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
Enable the slow query log to troubleshoot bad queries
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
Set thread_cache_size to 4 as a starting value
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
This is MyISAM only table_cache scalability problem, InnoDB not affected.
See more details here: https://bugs.mysql.com/bug.php?id=49177
This bug already fixed in MySQL 5.7.9 and newer MySQL versions.
Beware that open_files_limit (50000) variable
should be greater than table_open_cache (64)
Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: http://bit.ly/2wgkDvS
Variables to adjust:
query_cache_size (=0)
query_cache_type (=0)
query_cache_limit (> 1M, or use smaller result sets)
thread_cache_size (start at 4)
table_open_cache (> 64)
key_buffer_size (> 25.3G)
innodb_file_per_table=ON
innodb_buffer_pool_size (>= 4G) if possible.
innodb_log_file_size should be (=1M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
innodb_log_buffer_size (>= 1M)

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: High load due to MYSQL

Post by TrevorH » 2018/03/22 09:51:13

There are some useful recommendations in that output that you should read but I do not see anything there to explain high cpu usage. It's more likely that you have some badly tuned queries running so I'd turn on the slow query log and keep an eye on that so you can see the worst offenders. Once you have those then use 'explain' to see why they are slow and adjust the query and/or add indexes to make them perform better.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

tejas5555
Posts: 8
Joined: 2018/02/23 11:33:42

Re: High load due to MYSQL

Post by tejas5555 » 2018/03/23 04:46:51

Thanks for your help. It was the faulty disk which is located in our DC. Anyway will align hardware team for the replacement

Post Reply