Mysql is being stopped by OOM

SYSTEM INFORMATION
OS type and version Ubuntu 24.04
Virtualmin version 7.40.0

I am running some WP sites on a VPS. I’ve been using the same host for 5 years without issue. They had an issue with their servers so I ended up getting a different server. I had to reinstall the OS and use my backups to restore. I previously had 20.04 but installed 24.04. Not sure if this was a good idea. Now I get OOM mysql crashes and the problem is mysql doesn’t restart but if I log ssh and do a systemctl start mysql it starts no problems.

I just installed releem to see if that would help optimize my settings but it kept my same settings so I will probably get an OOM crash within 24 hours. I don’t understand why it doesn’t restart mysql as the log says failed to start retrying 9..10..11. I am not sure if I should reinstall the OS and start over. I don’t know if I should have stayed with 20.04. Any suggestions?

How much physical and virtual memory do you have? There are reports that some hosts oversell their serves so you don’t get what you think you are.

@host:~# free -m
total used free shared buff/cache available
Mem: 1459 621 289 211 548 479
Swap: 1535 1095 440

Thanks for the help. Here is what free -m shows. I just don’t understand why it doesn’t restart.

I am wondering if my.cnf parameters are not set properly even though releem returned the same results.

max_connections = 50 ### Previous value : 50
key_buffer_size = 8388608 ### Previous value : 8388608
max_heap_table_size = 16777216 ### Previous value : 16777216
tmp_table_size = 16777216 ### Previous value : 16777216
innodb_buffer_pool_size = 134217728 ### Previous value : 134217728
innodb_redo_log_capacity = 104857600 ### Previous value : 104857600
innodb_max_dirty_pages_pct = 90.000000 ### Previous value : 90.000000
thread_stack = 1048576 ### Previous value : 1048576
innodb_buffer_pool_instances = 1 ### Previous value : 1
innodb_buffer_pool_chunk_size = 134217728 ### Previous value : 134217728

What could that possibly solve?

You’ll need to either reduce memory usage, or add more memory. Adding swap can get you out of immediate trouble, but if your database or other frequently used services are being swapped out, performance will be miserable.

Definitely not. It would be crazy to launch a new server on an EOL operating system.

The first step is figuring out what’s using all the memory. Look at top or htop sorted by memory to get a bird’s eye view of memory usage.

I don’t know anything about releem, but if you cranked up memory usage of MySQL, by increasing buffers and caches, and you don’t have a lot of memory, that would be a bad idea.

I would recommend you revert to the default MySQL configuration and proceed from there. If you don’t understand the variables you’re tweaking and how they impact memory usage of MySQL you should not tweak them, even if an “AI” told you to.

Also, are you really using MySQL? The default in Virtualmin is Mariadb. You’re certainly welcome to switch if you need to. Just want to make sure we’re all talking about the same thing.

I run top and I don’t see anything abnormal. The highest usage is mysql and the highest it ever goes is 21% at least while I am looking at top.

I just don’t understand why systemd doesn’t restart mysql yet I can do it manually.

That’s configurable. But, you shouldn’t.

Restarting a database that is being killed over and over by the OOM killer is a recipe for data loss.

Solve your memory problem. Don’t solve the “systemd won’t restart MySQL” problem.

Looking at converting free -m to something I can understand shows you have very little memory. Please try free -h so I can make sure I’m doing the conversion correctly.

The converter I’m using says you have about 1.5G of memory?

           total        used        free      shared  buff/cache   available

Mem: 1.4Gi 706Mi 178Mi 281Mi 574Mi 323Mi
Swap: 1.5Gi 1.0Gi 524Mi

Yeah, this is a tiny system to be running a cranked up MySQL configuration. This is barely enough memory for running a basic web hosting system.

1 Like

You shouldn’t be increasing MySQL buffer/cache sizes when you have so little memory (and that’s very little memory for all the services on a hosting system).

1 Like

I’ve been running the same websites for 5 years with zero issues on the same amount of resources and then when they changed servers now problems.

We have a guide for running Virtualmin on low memory systems, though it’s maybe a bit old and hasn’t been updated recently…but, probably still relevant. 1.5 GB is enough to run everything except ClamAV, but just enough…it’s not leaving a lot of extra room.

Operating systems get bigger. Ubuntu 24.04 uses more memory than 20.04, though not by a huge amount.

But, I suspect if you just configure MySQL with the default packaged configuration and don’t try to run ClamAV, you’ll be fine.

Even worse when you are trying to run multiple WP sites, probably with their own separate tables and demand on the one local DB.
as the system grows and the user base expands you need more resources.

I don’t run mail so I’ve never used clam or spamassain.

I don’t allow users to register nor post for any of the WP sites. I’ve probably done a few more posts on each site but nothing major.

I just made these changes. I will see how it goes.

If you performed a full installation of Virtualmin, you would have both installed, though ClamAV wouldn’t be enabled unless you did so in the setup wizard (I think). And, it’s fine to have it installed, as long as it isn’t being used and clamd isn’t running.

You should still make sure you don’t have any services running that you don’t need. As I mentioned 24.04 is expected to be a little bigger, but not a lot bigger, so you shouldn’t see memory usage explode…so maybe you’ve got some extra stuff running that you’d previously disabled or was not running by default on your prior system.

this is sounding more and more like a development system even installing 5 WP sites uses quite a bit of space not to mention the other demda on the system

… and what was the “issue” with their servers ?

OOM related perchance? has to be quite serious to warrant a change in provider.