A couple of weeks ago mysql/mariadb crashed in the middle of the night… then again a few evenings later, then again, and again, now going down once or twice every day.
Why?
Looking at the logs without a lot of understanding, it looks like it might be going down and restarting(?) itself regularly, lots of crashed tables… due to the db crashing, or causing the crash?
I ran a mysql general log and have the last request before the last crash as a wp plugin hitting the db -
10100 QuerySELECT option_value FROM wp_options WHERE option_name = 'mepr_vat_
enabled' LIMIT 1
/usr/libexec/mysqld, Version: 5.5.47-MariaDB-log (MariaDB Server). started with:
Tcp port: 0 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
.
Would that mean that plugin (mepr is memberpress plugin) caused the problem, or it just happened then? And is that “started with” in there mysql trying to reboot itself?
I do get a lot of these in the mariadb.log, is this normal? I don’t know the ips -
150325 4:04:14 [Warning] IP address '61.240.144.67' could not be resolved: Name or service not known
150326 7:02:23 [Warning] IP address '118.123.119.169' could not be resolved: Name or service not known
150326 7:02:23 [Warning] IP address '118.123.119.169' could not be resolved: Name or service not known
150326 7:44:15 [Warning] IP address '222.186.21.194' could not be resolved: Name or service not known
150326 7:44:15 [Warning] IP address '222.186.21.194' could not be resolved: Name or service not known
150326 15:56:53 [Warning] IP address '222.186.15.208' could not be resolved: Name or service not known
150326 15:56:53 [Warning] IP address '222.186.15.208' could not be resolved: Name or service not known
Well, just to check a common issue we see – 8GB is normally plenty of RAM, but can you run the command “dmesg | tail -50”, and just make sure you don’t see any references to oomkiller, or processes being killed off due to lack of resources?
The notices you’re seeing regarding the IP addresses definitely shouldn’t be causing it to crash.
That said, is MySQL available to the outside world? It’s normally only listening on localhost, if it’s available to the outside world and doesn’t need to be, you may want to block that off to ensure that it’s not being hammered by bots.
ah… oom meaning ‘out of memory’… makes sense… at the end of dmesg | tail -50, I get:
[ 8241.695406] Out of memory: Kill process 15574 (mysqld) score 38 or sacrifice child
[ 8241.696498] Killed process 15574 (mysqld) total-vm:2989492kB, anon-rss:310968kB, file-rss:0kB
[ 8245.492515] hrtimer: interrupt took 5691894 ns
in my virtualmin MySQL server options, I find:
MySQL server listening address
is set at “any”. I only have mysql for my own sites on my own server, so that should be set to ‘localhost’ if I am understanding you correctly?
Doesn’t look like it’s being hammered by other ips though, so I’m not sure if that’s the problem. Should I give mysql more memory to use?
Currently the rest of the settings on the MySQL server options page are at their default settings.
Query cache size in bytes Default 32
Maximum packet size Default 1
MyISAM sort buffer size Default 64
just wonder why it’s suddenly running out of memory though when it’s been fine for the last year, I’m not getting any big surges in traffic right now…
Thanks for your awesome assistance Eric. When no one else has a clue you are always there! I volunteer on a help forum myself - I know how time consuming it can be to help others!
Your server is being attacked, only allow localhost to connect to Maria/MySql. One failed login that was not terminated stays in memory. Since brute force attacks can range from 1000 attacks per 10 minutes, resources starts to dwindle. MariaDB/MySql also have a maximum concurrent connection causing your database to fail.
…and would that be the ‘MySQL server listening address’ setting, or something else? I don’t seem to be able to set ‘MySQL server listening address’ to “localhost”.
Can you paste the contents of your /etc/my.cnf file?
Also, you may be seeing RAM issues, but maybe we should try setting it to localhost first. If you’re seeing memory issues, we can tell MySQL to use up less RAM.
Can do… but where do I set it to listen only to localhost? In the “MySQL server listening address”, it does not accept “localhost”. Do I enter my server’s ip? Or am I in the wrong setting?
Load is back down to a normal range for several minutes now, continuing to monitor.
If this was an attack, its the second one the last ten days for me. The first one was a standard ddos attack that lasted several days. Had to leave cloudflare in “under attack” mode for several days until it let up.