Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
HowtoAvoidMySQLServiceBeingKilledbyOutofMemory(OOM)KilleronLinux(DocID1548124.1)
InthisDocument
Goal
Solution
References
APPLIESTO:
MySQLServerVersion5.0andlater
Informationinthisdocumentappliestoanyplatform.
GOAL
HowtoavoidMySQLgettingkilledbytheOutofMemory(OOM)killeronLinux.
Exampleofissue:
Mysqldrestartsperiodicallybymysqld_safebutnoerrorsinmysqlerrorlogjustmessagethatmysqld_saferestartedmysqld.CausedbyLinuxOutMemoryKillerkillingmysqld
process.
Canbeverifiedbytheexaminingsystemlogs.Entrieslikebelow:
shell$egrepi"err|fail|fault|mysql|kill"/var/log/*
"var/log/messages20170108:Jan721:55:30ktskkernel:Outofmemory:Killprocess1904(mysqld)score39orsacrificechild
/var/log/messages20170108:Jan721:55:30ktskkernel:Killedprocess1904(mysqld)totalvm:2855024kB,anonrss:449640kB,filerss:0kB
/var/log/messages20170108:Jan721:55:58ktskkernel:httpdinvokedoomkiller:gfp_mask=0x200da,order=0,oom_score_adj=0"
SOLUTION
Stepsthatcanbetakentohelpavoidorstopmysqldfrombeingkilledduetolowmemoryare:
1.IncreasetheamountofphysicalRAMinsidetheserver.
2.Addswapspaceifthatisnotinuse(notthebestsolution!).
3.TurnofftheOOMkillerinthesysctlconfiguration.
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=fevga8j04_386&id=1548124.1 1/2
6/5/2017 Document1548124.1
4.IfyouwantOOMfunctionality,butdon'twantittoaffectMySQL,thenlookatsettingaspecialvalueof17forthemysqldprocessinthe/proc/`pidofmysqld`/oom_adj
setting.
5.IftheserverisnotdedicatedtoMySQL,lookatmovingotherservicesoffthemachinetootherareas.
6.Monitorthememoryusagein/proc/meminfo,free,and/proc/buddytomakesurethatmemoryisbeingusedeffectively.
7.Watchtoseeifthereareanymemoryleakshappeninginanyofthesoftwarecurrentlyonthesystem.
8.Useawrapperscriptfrommysqld_safetosetcustomperprocessattributes.
Theuseof/proc/PID/oom_adjisdeprecatedsince2.6.36versionoftheLinuxkernel.Itisstillabletouse17todisabletheOOMkillerforthatprocesstomaintainbackward
compatibility.Thenewermethodistoset/proc/PID/oom_score_adjtobe1000whichmeansthattheadjustedbadnessscorefortheMySQLtaskwillbe0andtheOOMkiller
willneverkillthatprocess.
REFERENCES
NOTE:452000.1Linux:OutofMemory(OOM)Killer
NOTE:1593811.1HowtouseaWrapperScripttosetCustomPerProcessAttributesforMySQLServer
http://www.oracle.com/technetwork/articles/serversstoragedev/oomkiller1911807.html
Didn'tfindwhatyouarelookingfor?
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=fevga8j04_386&id=1548124.1 2/2