patternMinor
Prevent mysql process being killed by OOM killer
Viewed 0 times
killerpreventprocessoombeingmysqlkilled
Problem
I need to protect mysql process so that it won't be killed when system runs out of memory, we have a bunch of adhoc job run on the server from time to time, so I would prefer the adhoc jobs being killed rather than mysql.
I know I can adjust the oom_score_adj, by setting it to -1000, I can exclude it from OOM killer's consideration. But I am not sure if I need to restart the mysql process for new oom_score_adj to take effect? Does adjust the oom_score_adj for a running process still takes effect?
I was following this post and nobody else mentioned about restarting the server for new oom_score_adj to take effect:
https://blog.rimuhosting.com/2015/12/11/dont-let-the-oom-killer-stop-mysql/
Another dumb question is that I can't seem to write to the oom_score_adj file, always getting the permission denied. The oom_score_adj is not owned by root, I have tried a couple of options but keep getting the permission issue:
Appreciated for any help!
I know I can adjust the oom_score_adj, by setting it to -1000, I can exclude it from OOM killer's consideration. But I am not sure if I need to restart the mysql process for new oom_score_adj to take effect? Does adjust the oom_score_adj for a running process still takes effect?
I was following this post and nobody else mentioned about restarting the server for new oom_score_adj to take effect:
https://blog.rimuhosting.com/2015/12/11/dont-let-the-oom-killer-stop-mysql/
Another dumb question is that I can't seem to write to the oom_score_adj file, always getting the permission denied. The oom_score_adj is not owned by root, I have tried a couple of options but keep getting the permission issue:
echo "echo '-100' > /proc/5653/oom_score_adj" | sudo -u {file_owner} shAppreciated for any help!
Solution
RHEL7 uses systemd.
Using the OOMScoreAdjust as follows:
Note: I'm not sure of the exact service name
Add the following text:
restart with:
Check by looking at the score:
Using the OOMScoreAdjust as follows:
sudo systemctl edit mysqld.serviceNote: I'm not sure of the exact service name
Add the following text:
[Service]
OOMScoreAdjust=-1000restart with:
systemctl restart mysqld.serviceCheck by looking at the score:
cat /proc/$(pidof mysqld)/oom_score_adjCode Snippets
sudo systemctl edit mysqld.service[Service]
OOMScoreAdjust=-1000systemctl restart mysqld.servicecat /proc/$(pidof mysqld)/oom_score_adjContext
StackExchange Database Administrators Q#256631, answer score: 9
Revisions (0)
No revisions yet.