Wordpress - mysql crash

July 24, 2017 533 views
WordPress MySQL Ubuntu 16.04

Hello what's wrong on Digital Ocean?

I have a droplet with 1 GB Memory / 30 GB Disk / AMS2 - Ubuntu 16.04.2 x64 and it work very well in the last 2 months.

Now i want know why in the last 4 days mysql stop working???
i really don't understand why this occured, i have one more droplet with same specs and more Wordpress site on it, and work very well.

problem is related to ram consuption, but i try a2dissite all my sites and leave just one active, problem persist!!!!!!

tail -40 /var/log/mysql/error.log

2017-07-24T19:04:30.218958Z 0 [Note] InnoDB: Number of pools: 1
2017-07-24T19:04:30.219177Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-24T19:04:30.222532Z 0 [Note] InnoDB: Initializing buffer pool, total siz e = 128M, instances = 1, chunk size = 128M
2017-07-24T19:04:30.222644Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errn o 12
2017-07-24T19:04:30.222824Z 0 [ERROR] InnoDB: Cannot allocate memory for the buf fer pool
2017-07-24T19:04:30.222864Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-07-24T19:04:30.222887Z 0 [ERROR] Plugin 'InnoDB' init function returned err or.
2017-07-24T19:04:30.222904Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-07-24T19:04:30.222921Z 0 [ERROR] Failed to initialize plugins.
2017-07-24T19:04:30.222935Z 0 [ERROR] Aborting

2017-07-24T19:04:30.222951Z 0 [Note] Binlog end
2017-07-24T19:04:30.223066Z 0 [Note] Shutting down plugin 'MyISAM'
2017-07-24T19:04:30.223766Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2017-07-24T19:05:00.448335Z 0 [Warning] Changed limits: maxopenfiles: 1024 (re quested 5000)
2017-07-24T19:05:00.448433Z 0 [Warning] Changed limits: tableopencache: 431 (r equested 2000)
2017-07-24T19:05:00.658943Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicitdefaultsfortimestamp server option (see doc umentation for more details).
2017-07-24T19:05:00.662549Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19-0ubuntu0.16 .04.1) starting as process 5831 ...
2017-07-24T19:05:00.672747Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-07-24T19:05:00.672879Z 0 [Note] InnoDB: Mutexes and rw
locks use GCC atomic builtins
2017-07-24T19:05:00.672910Z 0 [Note] InnoDB: Uses event mutexes
2017-07-24T19:05:00.673003Z 0 [Note] InnoDB: GCC builtin _atomicthread_fence() is used for memory barrier
2017-07-24T19:05:00.673107Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-07-24T19:05:00.673136Z 0 [Note] InnoDB: Using Linux native AIO
2017-07-24T19:05:00.674193Z 0 [Note] InnoDB: Number of pools: 1
2017-07-24T19:05:00.674524Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-24T19:05:00.677755Z 0 [Note] InnoDB: Initializing buffer pool, total siz e = 128M, instances = 1, chunk size = 128M
2017-07-24T19:05:00.677867Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errn o 12
2017-07-24T19:05:00.677951Z 0 [ERROR] InnoDB: Cannot allocate memory for the buf fer pool
2017-07-24T19:05:00.677980Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-07-24T19:05:00.677996Z 0 [ERROR] Plugin 'InnoDB' init function returned err or.
2017-07-24T19:05:00.678006Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-07-24T19:05:00.678017Z 0 [ERROR] Failed to initialize plugins.
2017-07-24T19:05:00.678025Z 0 [ERROR] Aborting

2017-07-24T19:05:00.678051Z 0 [Note] Binlog end
2017-07-24T19:05:00.678201Z 0 [Note] Shutting down plugin 'MyISAM'
2017-07-24T19:05:00.679034Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

3 Answers

Hi @ghostpizza

You're running out of memory, that's why MySQL is being crashed, so the entire system doesn't crash.

Are you using CloudFlare? If yes, then make sure it's not doing offline-cache of your site, since it hammers every page on your site every hour. Otherwise you need to setup cache.

Also make sure you're not being attacked by having a look in the access log:

# If you're using Apache, then this is the default path
tail -f /var/log/apache2/access.log
# If you're using Nginx, then this is the default path
tail -f /var/log/nginx/access.log
# Press CTRL+C to exit the monitoring
  • hello @hansen thanks for your reply

    Yes i use Cloudflare free account, now i switch it on pause and i know that is a problem regarding out of memory but why now and why for 2 months all worked well!

    i start command you suggested, but how i can recognize attack?

    • @ghostpizza

      I don't know if CloudFlare maybe changed something in their offline-cache - maybe it's hitting the server much more. You have to ask them.

      Or it could be a plugin/theme update, which is doing heavier/longer queries.

      You can see if there are many requests per second going to the same URL (usually someone trying to brute-force the login to gain access) or if the amount of many requests doesn't correlate with your amount of visitors (that could be the CloudFlare offline-cache or a bad search engine web-crawler).

i am very frustating, here you can see graph of my droplet, memory drop down just after droplet shutdown - r : https://ibb.co/kqOhS5

I had memory issues with my droplet hosting just a couple of WordPress sites with very low traffic.

However, I added the following to my apache2.conf:

<files xmlrpc.php>
        order allow,deny
        deny from all
</files>

My issues with MariaDB running out of RAM seem to have disappeared after doing this, so I suspect it could have been an XML RPC attack against WordPress.

Have another answer? Share your knowledge.