1

I did recently a site migration; during that I had to erase all plugins and the reinstalling only the minimum as the site was causing the server to crash (A Vps with 1gb of ram), the most problematic seemed to be related to caching plugins (the site's running on wordpress). So now the sites is on, but once in a while I get a "Out of memory: The process “mysqld” was terminated because the system is low on memory." , actually every day, although not at a determined hour (I don't have any cron jobs on). I tried running Mysqltuner, and go with their suggestions: tmp_table_size and max_heap_table_size from 16M to 32M; innodb_buffer_pool_size from 250M to 800 (80% of the total ram); innodb_buffer_pool_instances=1 and key_buffer_size from 12.8M to 25M.

Now I ran mysqltuner again, today (after relizing that mysqld was killed again this morning)-- Of course I know that the statistical sake of this result is not very accurate (as the mysql serer's been running for less than 24h) but it would be unlikely to get the proper results as mysql keeps restarting every day due to the crashing-- :

    >>  MySQLTuner 1.6.13 - 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
[OK] Currently running supported MySQL version 5.6.30
[OK] Operating on 32-bit architecture with less than 2GB RAM

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA 
[--] Data in MyISAM tables: 30M (Tables: 33)
[--] Data in InnoDB tables: 249M (Tables: 127)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[!!] User 'leechprotect@localhost' has no password set.
[!!] There is no basic password file list!

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

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 13h 13m 58s (2M q [54.533 qps], 40K conn, TX: 74G, RX: 280M)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 1006.3M
[--] Max MySQL memory    : 1.0G
[--] Other process memory: 104.1M
[--] Total buffers: 874.0M global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 901.6M (89.60% of installed RAM)
[!!] Maximum possible memory usage: 1.0G (102.80% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/2M)
[OK] Highest usage of available connections: 17% (26/151)
[OK] Aborted connections: 0.04%  (17/40146)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (34 temp sorts / 219K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 82% (76K on disk / 92K total)
[OK] Table cache hit rate: 97% (273 open / 281 opened)
[OK] Open file limit used: 1% (113/10K)
[OK] Table locks acquired immediately: 100% (2M immediate / 2M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 12.4% (3M used / 26M cache)
[OK] Key buffer size / total MyISAM indexes: 25.0M/12.8M
[OK] Read Key buffer hit rate: 98.0% (10K cached / 211 reads)
[!!] Write Key buffer hit rate: 44.7% (2K cached / 1K writes)

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

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 800.0M/249.5M
[OK] InnoDB buffer pool instances: 1
[!!] InnoDB Used buffer: 9.87% (5055 used/ 51200 total)
[OK] InnoDB Read buffer efficiency: 100.00% (182843753 hits/ 182848469 total)
[!!] InnoDB Write Log efficiency: 50.11% (4188 hits/ 8357 total)
[OK] InnoDB log waits: 0.00% (0 waits / 12545 writes)

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

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

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    MySQL started within last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    tmp_table_size (> 32M)
    max_heap_table_size (> 32M)

So I have obviously to reduce the memory usage of MySQL. The VPS is only running 1 site, which barely has plugins now and not many visits either, so I think (and also hope) that the problem is not the RAM per se, but the my disastrous attempt of site migration. Thanks in advance for any suggestion.

  • This seems to be the work of the infamous OOM Killer. There's an article with some advice on the Oracle site, which should mostly be applicable to MySQL as well. – mustaccio Jun 24 '16 at 22:33
  • 2
    This is a perfect illustration of why nobody should use mysqltuner, or anything like it, not ever: each of those recommended changes would tend make your problem worse. – Michael - sqlbot Jun 25 '16 at 2:15
  • 1
    @javalik I do agree the observations can be interesting to look at, but the recommendations are just dreadful. Another issue with the script is a lack of design considerations for something analogous to the observer effect -- some queries run by the tuner a actually impact the results generated by the tuner. But maybe I should try to come across as less critical... the tool is easy to use and the output looks authoritative so perhaps that contributes to the seemingly frequent misuse of it... the author does warn you. – Michael - sqlbot Jun 25 '16 at 15:25
  • 1
    "It is extremely important for you to fully understand each change you make to a MySQL database server. If you don't understand portions of the script's output, or if you don't understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust. Always test your changes on staging environments, and always keep in mind that improvements in one area can negatively affect MySQL in other areas." -- part of the disclaimer at mysqltuner.com ...now this, I have no problem agreeing with whole-heartedly. – Michael - sqlbot Jun 25 '16 at 15:27
  • 1
    @Michael-sqlbot that full warning should be right there in the output, not on the web only.. The cases when people set temporary tables size in gigabytes and the tuner was still advising to make it bigger.. and the queries were just not "memory-compatible" with TEXT columns in them (cough wordpress cough). – jkavalik Jun 25 '16 at 19:16
1

In 1GB of RAM, you may be able to set innodb_buffer_pool_size to 50M, maybe 100M. But definitely not 800M. The 80% advice is predicated on having at least 4GB of RAM, and 80% is too high even for that.

Having other things on the same machine (Apache?) adds to the cramped quarters. If you have Apache, lower MaxClients to 10.

Other things to keep out of trouble on that tiny machine:

max_connections = 25
table_open_cache = 300
key_buffer_size = 4M
tmp_table_size = 4M
max_heap_table_size = 4M

And look at the queries -- they are taking far more resources than they should ("Temporary tables created on disk: 82%")

0

thanks for your answer. Ok, I did vmstat thing that's suggested in Oracle's site. Got this, I really don't know if there's something abnormal with these statistics.

    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0     39    280     43    378    0    0    84   189  137   12 29  4 61  6  0    
 0  0     39    279     43    379    0    0    26    59  414  397 27  3 63  7  0    
 1  0     39    258     43    379    0    0     5    38  314  316 21  3 73  3  0    
 0  0     39    348     43    379    0    0     1    34  202  204 12  2 82  4  0    
 0  0     39    348     43    379    0    0     0    39  227  219 14  2 78  6  0    
 0  0     39    348     44    379    0    0     3    30  184  191 11  1 83  5  0    
 0  0     39    346     44    379    0    0     2    44  383  374 27  3 65  5  0    
 1  1     39    325     44    379    0    0     0    32  222  224 14  2 81  3  0    
 0  0     39    346     44    379    0    0     8    51  381  338 26  3 64  6  0    
 0  0     39    346     44    379    0    0     1    41  328  328 22  3 73  3  0    

I also changed the innodb_buffer_size from 800M (which as I said was set by me) to 500M, in an attempt to avoid that MySQL's maximum memory usage is dangerously high .

  • You should mention the command you ran to get this output. Your system doesn't look stressed at all! – Vérace Jun 25 '16 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.