ãã ããRed Hat Enterprise Linux 6ã®cgroupã¯ãä»æ¥ã§ãå€ãã®æ©èœãåããŠããŸããããã«ã€ããŠã¯ãä»æ¥èª¬æããŸãã
Red Hat Enterprise Linux 6ã®cgroupsæ©èœããå®å šã«å®éã®ã€ãã³ãã«åºã¥ãã1ã€ã®çŽç²ã«ä»®æ³çãªäŸã䜿çšããŠèŠãŠã¿ãŸãããã ããããæå§ãã«ã¯ãäŒçµ±çã«ãå°ããªäœè«ã§ãã
ITã»ãã¥ãªãã£ã«ã¯ä»ã»ã©å€ãã®åé¡ã¯ãããŸããã§ããã ä»æ¥ããã¹ãŠã®ã³ã³ãã¥ãŒã¿ãŒãšé»è©±ããããã¯ãŒã¯ã«æ¥ç¶ãããŠããã ãã§ãªããå·èµåº«ãæé€æ©ããã®ä»ã®ããŸããŸãªãã®ãæ¥ç¶ãããŠãããããé©ãããšã§ã¯ãããŸããããããã¯ãŒã¯ã®è åšã®ç¯å²ã¯åçŽã«åºå€§ã§ãã ãããŠããããã®è åšãšã®æŠãã¯ãååãšããŠããã¹ãŠã®é¢ã§ããã«å§ãŸããŸãã ã»ãã¥ãªãã£ãããã®ã¯ã€ãã¯ã€ã³ã¹ããŒã«ïŒ ã¯ããééããªãïŒ ã·ã¹ãã ã»ãã¥ãªãã£ã®åŒ·å-ãã¡ã€ã¢ãŠã©ãŒã«ãSELinuxãã¹ããŒãèªèšŒãããã ãã§ããïŒ ãã¡ããïŒ Linuxãã·ã³äžã®ãŠã€ã«ã¹å¯Ÿçã¹ãã£ããŒïŒ ããŠããªããšèšãã...
Linuxãã·ã³ã§ã¯ãã¢ã³ããŠã€ã«ã¹ã¹ãã£ããŒãè¯ãããã害ãåãŒãããšããããŸãã ãã ããã»ãã¥ãªãã£ã¬ãŒãã«ã¯ç¬èªã®çç±ããããå€ãã®å Žåãæè¡çãªèŠ³ç¹ããå¥å šæ§ãå®éã«èæ ®ããããšãªããå®æçã«ãŠã€ã«ã¹å¯Ÿçã¹ãã£ã³ãå®è¡ããå¿ èŠããããŸãã ãããŠãããã¯ææ ¢ããªããã°ãªããªãçŸå®ã§ãããé ããæ©ãããã»ãŒãã¹ãŠã®ITå°é家ãçŽé¢ããŸãã
2çªç®ã®ãã€ã³ãã¯ãRed Hat Enterprise Linux 7ã¯ãã¡ãããã¡ãã·ã§ããã«ã§ãå é²çã§ã¯ãŒã«ã§ãããå€ãã®äººãããŸã ã«Red Hat Enterprise Linux 6ã䜿çšããŠãããæåŠããªããšèããŠããããšã§ãã å®éãããã人ã ãRed Hatãéžæããçç±ã§ã-äœå¹ŽãåãããŒãžã§ã³ã䜿çšã§ããææ°ã®ããããã¢ããããŒãããµããŒãããã¹ãŠå ¥æã§ããŸãã
äŸã«æ»ããŸããã... Jerryãšããååã®ç·ããããšæ³åããŠãã ããã Jerryã¯å€§èŠæš¡ãªãªãã£ã¹ã§åããŠãããRed Hat Enterprise Linux 6ãµãŒããŒã®è²¬ä»»è ã§ããããã®åäœã«å®å šã«æºè¶³ããŠãããæ°ããåé¡ããã³ãã¯å¿ èŠãããŸããã
ãããããã®åŸãã»ãã¥ãªãã£éšéã®ã¹ã¿ããã¯ãèªåã®ãã¹ãŠã®ãµãŒããŒã§ScanITãšåŒã°ãããã®ã1ã€çœ®ãå¿ èŠããããšå€æããŸããã ãããŠããã®ããšã¯å®æçã«ãã£ã¹ã¯ãã¡ã¢ãªã§ãŠã€ã«ã¹ããã®ä»ã®ãã«ãŠã§ã¢ããã§ãã¯ãããããå®å šãªã«ãŒãã¢ã¯ã»ã¹ãå¿ èŠã§ãã
ãžã§ãªãŒã¯ããæ¯ãã€ããã®ã¿ãŒã眮ããScanITããã¹ããã·ã³ã«çœ®ããŸãã ããã«ãããå€æããŸããïŒ
- ãŠã€ã«ã¹å¯Ÿçã¹ãã£ã³ãå®è¡ãããšãscanitïŒããã¯ããã»ã¹ãéå§ããã¹ã¯ãªããã§ãïŒãå°éã§ãããã¹ãŠã®ããã»ããµãŒæéã䜿ãæãããŸãã ãããŠããã®oã¯ãã¹ããã·ã³ã®åäœã«éåžžã«æªã圱é¿ãäžããŸã-ãžã§ãªãŒãsshã§å°éã§ããªãã£ãå Žåã
- ããã«ãscanitããã»ã¹ã¯æã ã¡ã¢ãªãé£ãã€ã¶ããŸãã ãã®çµæã OOM Killerãèµ·åããscanitèªäœä»¥å€ã®ããã»ã¹ã匷å¶çµäºãå§ããŸãã
äžè¬ã«ãããã§äœããããå¿ èŠããããŸãã
ãžã§ãªãŒã¯ã®ã¿ãŒãæã«åããã°ã¬ã€ããã«ãããã匟ããªããèãå§ããŸãã Red Hat Enterprise Linux 7ã®åãcgroupãããããããã§åœ¹ç«ã€å¯èœæ§ãããããšã圌ã¯ããã«æãã€ããŸãããAlexãšããååã®å人ã圌ã«è³ããã¹ãããŸããã ãžã§ãªãŒã¯åã³ã®ã¿ãŒã匟ãã Red Hat Enterprise Linux 6ã§ã¢ã¬ãã¯ã¹ã®ããã¯ãèªãããšã«åãããããŸãã 圌ãæåã«å¿ èŠãšããã®ã¯libcgroupã§ããããšãããããŸããã
ãã¹ããã·ã³ã«ã¯libcgroupããªããããJerryã¯ã€ã³ã¹ããŒã«ãéå§ããŸãã
ããã«ãJerryã«ã¯ãæ°žç¶çãªïŒæ°žç¶çãªïŒcgroupã®äœæ¥ã«å¿ èŠãª2ã€ã®ãµãŒãã¹ãå«ãŸããŠããŸãã
- cgconfig-cgroupããªãŒãæäœããããã®å€å°ã·ã³ãã«ãªã€ã³ã¿ãŒãã§ãŒã¹ãæäŸããŸãã Jerryã¯ç¢ºãã«cgroupãæåã§ããŠã³ãããã³æ§æã§ããŸãããæéãç¯çŽã§ããã®ã¯ãªãã§ããïŒ
- cgred-ããã¯cgroupã«ãŒã«ãšã³ãžã³ã§ããããã»ã¹ãéå§ããããšããã®ãµãŒãã¹ã¯æå®ãããã«ãŒã«ã«åŸã£ãŠ1ã€ãŸãã¯å¥ã®cgroupã«ããã»ã¹ãé 眮ããŸãã
ããããã¹ãŠãã€ã³ã¹ããŒã«ããŠæ§æãããšããžã§ãªãŒã¯æçµçã«åé¡èªäœã«çŽæ¥é²ãããšãã§ããŸãã ãã¹ãŠãæ éã«æ€èšããåŸã圌ã¯æ¬¡ã®æ±ºå®ãäžããŸãã
- scanitãšãã®åããã»ã¹ã¯ãCPUãªãœãŒã¹ã®20ïŒ ä»¥äžãæ¶è²»ããå¿ èŠããããŸãã å®éãããã«å°ãªã-ãã«ãã³ã¢ãã·ã³äžã§ãã£ãŠãã1ã€ã®ããã»ããµã³ã¢ã®ãªãœãŒã¹ã®20ïŒ ä»¥äžã§ãã cgroupã§ã¯ãããã¯CPUã¯ã©ãŒã¿ã䜿çšããŠè¡ãããŸãã
- ã¡ã¢ãªã«é¢ããŠã¯ãscanitãšãã®åããã»ã¹ã¯512 MBãè¶ ããã·ã¹ãã ã¡ã¢ãªãæ¶è²»ããŸããã ãããããã®å¢çãè¶ããŠããå Žåãã·ã¹ãã ã¯ä»ã®ããã»ã¹ã§ã¯ãªãããããã匷å¶çµäºããŸãã
äœããã¹ãããèšãå¿ èŠã¯ãããŸããïŒ
Jerryã¯2ã»ããã®æ§æãã¡ã€ã«ãåŠçããå¿ èŠããããŸãã
- /etc/cgconfig.conf-libcgroupã®ã€ã³ã¹ããŒã«æã«èªåçã«çæãããŸãã
- /etc/cgrules.conf-cgredãcgroupsã°ã«ãŒãããšã«å®è¡äžã®ããã»ã¹ããœãŒãããã«ãŒã«ã»ããã®ã«ãŒã«ã®ã»ãããå«ãŸããŠããŸãã
ããã©ã«ãã®cgconfig.confãã¡ã€ã«ã¯æ¬¡ã®ããã«ãªããŸãã
ãžã§ãªãŒã¯åœŒã«å¿ èŠãªç·šéãçŽæ¥è¡ãããšãã§ããŸããããããããã€ã³æ§æãã¡ã€ã«ã䜿çšããæ¹ãè¯ãã§ãããã ã©ã®ããã«æ©èœããŸããïŒ ïŒEngãDrop-in-dropïŒã.confæ¡åŒµåãæã€ãã¡ã€ã«ã«/etc/cgconfig.dãã©ã«ããŒã«çœ®ããšãã·ã¹ãã ã¯ãããåŠçããæ§æã«é©åãªå€æŽãå ããŸãã ããã¯äŸ¿å©ã§ããããŸããŸãªã¿ã¹ã¯ã®ããããã€ã³ãäœæããæé©ãªããŒã«ã䜿çšããŠæ§æã«è¿œå ãŸãã¯åé€ã§ããããã§ãïŒAnsibleãããã¯ãŸã Red Hatããã°ã§ãïŒã
Jerryã¯æåã«CPUã®ããããã€ã³ãã¡ã€ã«ãäœæããŸãã
ããã«ãããã®ãšããããã©ã®ããã«æ©èœãããã調ã¹ãŸãã
groupããŒã¯ãŒãã¯ãæ°ããcgroupã®ååïŒãã®äŸã§ã¯scanitïŒãèšå®ããã ãã§ãã äžæ¬åŒ§å ã§ã䜿çšããcgroupã³ã³ãããŒã«ãæå®ããŸãã ããã§ãcpu.cfs_period_usãšcpu.cfs_quota_usã¯ãRed Hat Enterprise Linux 6ã§ããã©ã«ãã§äœ¿çšãããã«ãŒãã«ã¹ã±ãžã¥ãŒã©ã§ããCompletely Fair Schedulerã§å¯Ÿå¿ããå¶éãèšå®ã§ããŸããRedHat Enterprise LinuxãªãœãŒã¹ç®¡çã¬ã€ãã§ãããã«ã€ããŠæžããããã®ãèŠãŠã¿ãŸããã6 ïŒ
èšãæããã°ããžã§ãªãŒã¯ããããã€ã³ã§æ¬¡ã®ããã«æžããŠããŸãããscanitãšããååã®cgroupã«é¢é£ããåããã»ã¹ã«ã€ããŠãå²ãåœãŠãããCPUãªãœãŒã¹ã®éã1ç§éã«1åãã§ãã¯ããŸãã ãã®ã°ã«ãŒãå ã®ãã¹ãŠã®ããã»ã¹ã®åèšããã»ããµæéã200,000ããªç§ãè¶ ããå Žåããããã®ããã»ã¹ãžã®ããã»ããµæéã®æäŸãå®å šã«åæ¢ããŸãã ã€ãŸããscanit cgroup-groupå ã®ãã¹ãŠã®ããã»ã¹ãšãã®åããã»ã¹ããåèšã§ããã»ããµãŒæéã®20ïŒ ä»¥äžã«å²ãåœãŠãããšã§ãã
cgconfigãåèµ·åãããšããµãŒããŒã¯æ§æãæŽæ°ããŸãããã¡ã€ã«ã·ã¹ãã ã«ã¢ã¯ã»ã¹ãããšãscanitãCPUã³ã³ãããŒã©ãŒãã£ã¬ã¯ããªã«é 眮ãããŠããããšãããããŸãã
ãã¡ããããã¯è¯ãããšã§ãããããã§ãscanitèªäœããã®cgroupã«ããã·ã¥ããå¿ èŠããããŸãã Crgedã¯ããã§åœ¹ç«ã¡ãŸããããã©ã«ãã§ã¯æ¬¡ã®ããã«ãªããŸãã
ãã®ãã¡ã€ã«ã®äœ¿çšã¯å€ããå°ãªããç°¡åã§ãã ãã ããããã§ã¯ããããã€ã³ã¡ã«ããºã ããµããŒããããŠããªããããcgrules.confãã¡ã€ã«ãçŽæ¥ç·šéããå¿ èŠããããŸãã ããã»ã¹ãææãããŠãŒã¶ãŒãŸãã¯ã°ã«ãŒããããã³ç¹å®ã®ïŒå¿ èŠã«å¿ããŠïŒããã»ã¹ã®ååãããã³ã«ã¹ã¿ã ã³ã³ãããŒã©ãŒãšcgroupå®å ã°ã«ãŒãã瀺ããŸãã
ãã®äŸã§ã¯ãå®éã®ãŠã€ã«ã¹å¯Ÿçã¹ãã£ããŒscanitã®ä»£ããã«ãscanitãšãåŒã°ããã¹ã¯ãªããã䜿çšããŸãããå®éã«ã¯è² è·ããšãã¥ã¬ãŒãããã ãã§ãã cgroupããªãå Žåããã¹ãŠæ¬¡ã®ããã«ãªããŸãã
CPUã¯ãäž»ã«ãŠãŒã¶ãŒã¹ããŒã¹ãšå°ãã®ã·ã¹ãã ã«ãã£ãŠå®å šã«å æãããŸãã
ãžã§ãªãŒã¯ã²ããã²ã£ãããŸãã viãèµ·åãã1æ¬ã®äººå·®ãæã䜿çšããŠãããã€ãã®å€æŽãè¡ããcgredããŒã¢ã³ãåèµ·åããŸãã
次ã«ãæåã§scanitãèµ·åããŸã...ïŒ
ãããŠ-也æ¯ïŒ åå©
ã芧ã®ãšãããè² è·ãšãã¥ã¬ãŒãããã»ã¹ïŒscanitã®åããã»ã¹ïŒã¯ãäž»ã«ãŠãŒã¶ãŒã¹ããŒã¹ãšã·ã¹ãã ã§å°ããã€ãåèš20ïŒ ã®CPUãªãœãŒã¹ãæ¶è²»ããŸãã ãããã£ãŠããã®ããŸããŸããã¢ã³ããŠã€ã«ã¹ã¯ããã¯ââãå®å šãªçæ°ã«è»ãããŒãããŸããã
次ã¯äœãèŠããŠããŸããïŒ
æåã«åã³ããžã§ãªãŒã¯åœŒã®èšæ¶ãã»ãšãã©å¿ããŠããŸããã ããããããã§ã圌ã¯èšæ¶ããviãåèµ·åããŠæ§æãã¡ã€ã«ãä¿®æ£ããŸãã
ããã§ãã¡ã¢ãªã«é¢ãã2ã€ã®èšå®ãè¿œå ããŸãã
- Memory.limit_in_bytes-æ倧 scanit cgroupå ã®ãã¹ãŠã®ããã»ã¹ã䜿çšã§ããRAMã®éã ãããŠãã¹ã¯ããã¹ããŒã¹ãèæ ®ã«å ¥ããã«ã Jerryã¯256 MBã«å¶éããŠããŸã
- Memory.memsw.limit_in_bytes-æ倧 åèšã§ãscanit cgroup-groupå ã®ãã¹ãŠã®ããã»ã¹ã«å²ãåœãŠãããšãã§ããRAMããªã¥ãŒã ãšã¹ã¯ãããã¡ã€ã«å ã®ã¹ããŒã¹ã ãã®ãããå€ãè¶ ãããšãããã»ã¹ã¯OOMãã©ãŒã«ãã£ãŠåŒ·å¶çµäºãããŸãã Jerryã¯512 MBã«èšå®ããŸãã
ãã°ãïŒ äœãæªãã®ïŒ
Jerryã¯äžéšãèŠãŠãscanitåããã»ã¹ããŸã å®è¡ãããŠããããšã確èªããŸãã ãã®cgroupã¯çŸåšäœ¿çšäžã§ãããããJerryã¯ãµãŒãã¹ãéå§ã§ããŸããã ãããã£ãŠãåããã»ã¹ãæåã§åŒ·å¶çµäºãããã®ãããªãµãŒãã¹ãåèµ·åããŸãã
cgred.confãå°ãç·šéããŸãã
確èªããããã«ãJerryã¯è€æ°ã®scanitã¿ã¹ã¯ãäžåºŠã«å®è¡ããOOMãã©ãŒã確å®ã«æ©èœããããã«ããŸãã
ãã®åŸãJerryã¯ã·ã¹ãã ãã°ãèŠãŠæºè¶³ããŠããªãããŸããscanitã¯ãå 責ã䌎ãéã®ã¡ã¢ãªãæ®ãããšãã§ããªããªããŸããã
cgroupsã®èšäºã·ãªãŒãºãããããäœã§ããããRed Hat Enterprise Linux 7ã§ã®äœ¿çšæ¹æ³ãRed Hat Enterprise Linux 6ã§ã®äœææ¹æ³ãç°å¢ã§ã®äœ¿çšæ¹æ³ã®ç解ã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã