ç®æ¬¡
ãã¡ã€ã«ã·ã¹ãã ãžã§ãã®äžŠåå
çŸåšã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ããŒãã¹ã±ãžã¥ãŒã«ãèŠããšãåãªãããŒã¢ã³ã®èµ·åãããå€ãã®åæãã€ã³ãã衚瀺ãããŸããFSã«é¢é£ä»ããããŠããã¿ã¹ã¯ã¯ãããŠã³ããFSã®ãšã©ãŒã®ãã§ãã¯ïŒfsckïŒãåŒçšã«æãæéãããããŸãã çŸåšãããŒãäžã«ã / etc / fstabã§æå®ããããã¹ãŠã®ãã£ã¹ã¯ãããã€ã¹ããªãŒã«è¡šç€ºããããŸã§åŸ æ©ããŠããããšã©ãŒã®ãã§ãã¯ãããŠã³ããããã³ã¯ã©ãŒã¿ã®é©çšãè¡ãããŸãïŒãã¡ãããªã³ã«ãªã£ãŠããªãéãïŒã ãã®ãã¹ãŠã®åŸãããã«å ãžé²ãããšãã§ããå®éã«ãµãŒãã¹ã®ããŠã³ããŒããéå§ãããŸãã
ãã®ããã»ã¹ãæ¹åã§ããŸããïŒ ã§ããããšãããããŸããã Harold Hoyerã¯ãç±ç·ããautofsã䜿çšããŠããã»ã¹ãæ¹åãããšããã¢ã€ãã¢ãæãã€ããŸããã
connectïŒïŒã®åŒã³åºããå¥ã®ãµãŒãã¹ã«é¢å¿ãããããšãã宣èšãããã®ãšåæ§ã«ã openïŒïŒ ïŒãŸãã¯å¥ã®åæ§ã®åŒã³åºãïŒã®åŒã³åºããããã¡ã€ã«ãŸãã¯ãã¡ã€ã«ã·ã¹ãã ã«é¢å¿ãããããšã宣èšããŸãã ãã®ããã䞊ååãæ¹åããã«ã¯ãæ¢ããŠãããã¡ã€ã«ã·ã¹ãã ããŸã ããŠã³ããããŠããªãå Žåã«ã®ã¿ããããã®ã¢ããªã±ãŒã·ã§ã³ãåŸ æ©ãããå¿ èŠããããŸãã ãããè¡ãã«ã¯ãããŠã³ããã€ã³ãautofs ïŒåœã®ããŠã³ããã€ã³ãïŒãæ¥ç¶ããéåžžã®OSããŒãäžã«å®éã®FSãfsckãŠãŒãã£ãªãã£ã«ããæŽåæ§ãã§ãã¯ã«åæ Œãããšãå®éã®ç£èŠãã€ã³ãã«çœ®ãæããŸãã å®éã®FSããŸã ããŠã³ããããŠããªãéãFSãžã®ã¢ã¯ã»ã¹è©Šè¡ã¯ã«ãŒãã«ã«ãã£ãŠãã¥ãŒã«å ¥ããããã¢ã¯ã»ã¹è©Šè¡ã¯ãããã¯ãããŸãããã¢ãã¬ã¹æå®ãããå¯äžã®ããŒã¢ã³ã«å¯ŸããŠã®ã¿ã§ãã ãããã£ãŠããã¹ãŠã®FSã䜿çšå¯èœã«ãªããã£ãšåã«ããŒã¢ã³ãå®è¡ã§ããåæã«ãã¡ã€ã«ã¢ã¯ã»ã¹ã倱ãããšãªããOSã®ããŒãããã»ã¹ãæ倧éã«äžŠååã§ããŸãã
FSã¿ã¹ã¯ã®äžŠååã¯ããã¹ãŠã®ãµãŒãã¹ïŒããŒã¢ã³ïŒãšãã¹ãŠã®ãã€ããªãé 眮ãããŠããããŠã³ããã€ã³ã-/ïŒFSã«ãŒãïŒã«ã¯æå³ããããŸããã ããã«ãããããããéåžžã¯ãã倧ãããæå·åããããšãã§ãããªã¢ãŒããã·ã³ããããŠã³ããããããšããããOSããŒãäžã«ããŒã¢ã³ãã¢ã¯ã»ã¹ããããšã¯ã»ãšãã©ãªãããŠã³ããã€ã³ã/ homeã«ãããOSã®ããŒãé床ãå€§å¹ ã«äžããããšãã§ããŸãã procfsãsysfsãªã©ã®ä»®æ³FSãautofsãä»ããŠããŠã³ããããã¹ãã§ã¯ãªãããšãæãåºãå¿ èŠã¯ãããããªãã§ãããã
äžéšã®èªè ãã autofsãinitããã»ã¹ã«çµ±åãããšãã決å®ãå°ããè匱ããŸãã¯å¥åŠã«ããæããããããããããã«ãŒãçãªåŽé¢ãšåŒã°ããå Žåã§ããç§ã«ãšã£ãŠé©ãããšã§ã¯ãããŸããã ããã«ããããããã圌ãšå€ãã®ããšãããã®ã§ãç§ã¯çŸåšã®å Žæã®autofsããšãŠãæ°åãè¯ããšèšãããšãã§ããŸãã autofsã䜿çšãããšãå®éã®FSãããã«æäŸããã«ç£èŠãã€ã³ããäœæã§ããŸãã å®éãã¢ã¯ã»ã¹ã¯å»¶æãããŠããŸãã ã¢ããªã±ãŒã·ã§ã³ãautofs FSã«ã¢ã¯ã»ã¹ããããšããŠãå®éã®FSã«çœ®ãæããã®ã«æéããããå Žåãã¢ããªã±ãŒã·ã§ã³ã¯äžæãããã¹ãªãŒãã§ããªãŒãºããŸããã€ãŸãã Ctrl + Cãªã©ã䜿çšããŠç°¡åã«ãã£ã³ã»ã«ã§ããŸãã ãŸããã¢ããªã±ãŒã·ã§ã³ã®å®è¡äžã®ä»»æã®æç¹ã§ãå®éã®FSãïŒ fsckã®å€±æã«ããïŒæ£ããããŠã³ãã§ããªãå Žåã autofsã«å®éã®ãšã©ãŒã³ãŒãïŒ ENOENTãªã© ïŒãè¿ãããã«èŠæ±ã§ããããšã«æ³šæããŠãã ããã ã ãã...ç§ã¯ãåæåã·ã¹ãã ãžã®autofsã®çµ±åãæåã¯æãã«èŠãããããããŸããããç§ãã¡ã®å®éšçãªã³ãŒãã¯ãåœç¶ã®ããšãªãããå®éã«ã¢ã€ãã¢ãé©ãã»ã©ããŸãåäœããªãããšã瀺ãããšæããŸãæ£ããçç±ã®ããã
ãŸããautofsã¢ãã¿ãŒãã€ã³ãã¯ããããããã€ã¬ã¯ããããã³ã° ïŒç¿»èš³è ã®æ³šæïŒ ããã§ã®è¡šç€ºã¿ã€ãã«é¢ããæ å ±ïŒã§ããå¿ èŠãããããšã«æ³šæããŠãã ããã
æåã®ãŠãŒã¶ãŒPIDãå°ããä¿ã€
MacOSã®ããŒãããžãã¯ããåŠã¹ããã1ã€ã®è¯ãç¹ã¯ãã·ã§ã«ã¹ã¯ãªããïŒç¿»èš³è ã®ã¡ã¢ïŒã·ã§ã«ãã·ã§ã«ïŒã¯æªã§ãããšããããšã§ãã ã·ã§ã«ã¯ãé«éãã§ãããã·ã§ã«ã¯äœéã§ãã ã·ã§ã«ã¹ã¯ãªããã§ã¯ãäœãäœã§ãããããã°ããææ¡ã§ããŸãããå®è¡é床ã«ã¯å€ãã®ããšãæãŸããŸãã åŸæ¥ã®sysvinitããŒãã·ã¹ãã ã¯ãã·ã§ã«ã¹ã¯ãªãããäžå¿ã«ã¢ãã«åãããŠããŸãã / bin / bashãŸãã¯ä»ã®ã·ã§ã«ïŒã·ã§ã«ã¹ã¯ãªããã®å®è¡ãé«éåããããã«æžãããå¯èœæ§ãé«ãïŒã§ãã£ãŠããæçµçã«ã¯é ããªãéåœã«ãããŸãã ç§ã®ãã·ã³ã§ã¯ã/ etc / init.dã®ã¹ã¯ãªãããgrepã 77ååŒã³åºããŸãã awkã¯92åã cut -23ããã³sed -74ã§åŒã³åºãããŸãããããã®ã³ãã³ãïŒãŸãã¯ãã®ä»ïŒãåŒã³åºããããã³ã«ãæ°ããããã»ã¹ãçæãããé¢é£ããã©ã€ãã©ãªãæ€çŽ¢ããã i18nãªã©ãæ§æãããŸãã äºçŽ°ãªæååæäœãããå°ãè€éãªæäœããŸãã«ããå®è¡ãããªãå Žåã§ããèªã¿èŸŒã¿ããã»ã¹ã¯äžæãããŸãã ãã¡ãããããã¯ãã¹ãŠéåžžã«ãã£ããå®è¡ãããŸãã ããããã·ã§ã«ä»¥å€ã®èšèªã§ã¯ãã®ãããªããšã¯ã§ããŸããã ããã«ãäžã§è¿°ã¹ãããã«ãã·ã§ã«ã¹ã¯ãªããã¯éåžžã«ãå£ããããããã®ã§ããç°å¢å€æ°ãã远跡ãå¶åŸ¡ãå°é£ãªãã®ä»ã®é¡äŒŒã®ãã®ããåäœãå€æŽããŸãã
ããŒãããã»ã¹äžã®ã·ã§ã«ã¹ã¯ãªããã®è² è·ãåãé€ããŸãããã ãããè¡ãåã«ãæåã«ããããå®éã«äœã«äœ¿çšãããŠããããææ¡ããå¿ èŠããããŸãã ã»ãšãã©ã®ã¹ã¯ãªããã¯ããµãŒãã¹ã®èµ·åãšåæ¢ã«ãã»ã©æéãããããCã§æžãçŽãããåå¥ã®å®è¡å¯èœãã¡ã€ã«ãšããŠæžãçŽããããµãŒãã¹èªäœïŒããŒã¢ã³ïŒå ã§è»¢éããããããŒãã·ã¹ãã èªäœã«å®è£ ããå¿ èŠããããŸãã
è¿ãå°æ¥ãã·ã§ã«ã¹ã¯ãªããã®è² æ ãå®å šã«åãé€ãããšãã§ããããã«ã¯èŠããŸããã ããããCã«æžãæããã«ã¯æéãããããŸããå Žåã«ãã£ãŠã¯ããã®ã¢ã¯ãã£ããã£ã«ãŸã£ããæå³ããªããã·ã§ã«ã¹ã¯ãªãããéåžžã«äŸ¿å©ãªå ŽåããããŸãã ããããäžè¬çã«ã¯ã以åãããå¿ èŠæ§ãšéåšæ§ãäœãããããšãã§ããŸãã
OSããŒãããã»ã¹ã§ã®ã·ã§ã«ã¹ã¯ãªããã®äŸµè¥²æ§ã枬å®ããããã®é©åãªã¡ããªãã¯ã¯ãOSãå®å šã«ããŒãããåŸã«éå§ã§ããæåã®ããã»ã¹ã®PIDçªå·ã§ãã èµ·åããŠãã°ã€ã³ããã¿ãŒããã«ãéããŠecho $$ãšå ¥åããŸãã Linuxãã·ã³ã§ãããè©ŠããŠãçµæãMacOSãšæ¯èŒããŠãã ããïŒ ïŒãã³ããçµæã¯æ¬¡ã®ããã«ãªããŸãïŒLinux PID-1823; MacOS PID-154ããã¹ããã·ã³ã§æž¬å®ããŸãããïŒ
ããã»ã¹è¿œè·¡
ãµãŒãã¹ãèµ·åããã³ç®¡çããã·ã¹ãã ã®äž»èŠã³ã³ããŒãã³ãã¯ãçè·åž«ãããã»ã¹ã§ããå¿ èŠããããŸãã圌ã¯ãµãŒãã¹ãç£èŠããå¿ èŠããããŸãã åæ¢ããããµãŒãã¹ãåèµ·åããŸãã ãµãŒãã¹ããèœã¡ããå Žåã管çè ãå°æ¥ããããèŠãããšãã§ããããã«ãã¯ã©ãã·ã¥ã«é¢ãããã¹ãŠã®å¿ èŠãªæ å ±ãåéããããããè¿ãã®ã©ããã«ä¿ç®¡ãããšãšãã«ããã®ãããªã¯ã©ãã·ã¥ãã³ãåéã·ã¹ãã ã«ååšããæ å ±ãšã®ã¯ãã¹ãªã³ã¯ãæ§ç¯ããå¿ èŠããããŸãabrtãšåæ§ã«ã syslogãªã©ã®ãã°ãµãŒãã¹ãç£æ»ã·ã¹ãã ã§ãåæ§ã§ã ã
ãªãã¶ãŒãããã»ã¹ïŒãçè·åž«ãïŒã¯ããµãŒãã¹ãå®å šã«åæ¢ããããšãã§ããªããã°ãªããŸããïŒçŽïŒç¿»èš³è ïŒãµãŒãã¹ããã»ã¹ãšãã®ãã¹ãŠã®åããã»ã¹ãæå³ããŸãïŒã ããã¯äºçŽ°ãªäœæ¥ã®ããã«æãããããããŸããããå®éã«ã¯èŠãããããããã«è€éã§ãã äŒçµ±çã«ãUnixã§ã¯ãèªèº«ã2ååå²ããããã»ã¹ã¯ã芪ããã»ã¹ã«ããèªèº«ã®èŠ³å¯ãåãé€ãããšãã§ããæåã®èŠªã¯ãåå«ãå®éã«äœæããæ°ããããã»ã¹ãšã®æ¥ç¶ãèªèããŸããã ããšãã°ãçŸåšã®ç¶æ³ã§ã¯ãApacheãµãŒãã¹ãåæ¢ããŠããèªåèªèº«ã2ååå²ãããããããããªãïŒäžæ£ãªïŒCGIã¹ã¯ãªããã¯åæ¢ããŸããã ããã«ãååãšç®çãããããŸã§ãCGIã¹ã¯ãªãããnaughtyããšApacheã®éã«æ¥ç¶ã確ç«ããæ©äŒãããããŸããã
ã§ã¯ãããã»ã¹ã远跡ããŠãçè·åž«ããåãé€ãããšãã§ãããæ°çŸäžååå²ããå Žåã«1ã€ã®ãšã³ãã£ãã£ãšããŠå¶åŸ¡ã§ããããã«ããã«ã¯ã©ãããã°ããã§ããããã
ããŸããŸãªäººã ããã®åé¡ã«å¯ŸããããŸããŸãªãœãªã¥ãŒã·ã§ã³ãæäŸããŠããŸãã ãã®èšäºã®ãã¬ãŒã ã¯ãŒã¯å ã§è©³ãã説æããã€ããã¯ãããŸããããå°ãªããšããœãªã¥ãŒã·ã§ã³ã¯ptraceãŸãã¯netlinkã³ãã¯ã¿ãŒïŒã·ã¹ãã å ã®ããã»ã¹ãforkïŒïŒãŸãã¯exitãåŒã³åºããã³ã«netlinkã¡ãã»ãŒãžãåä¿¡ã§ããã«ãŒãã«ã€ã³ã¿ãŒãã§ã€ã¹ïŒã«åºã¥ããŠãããšèšããŸãäžéšã®äººã ã¯ãããå°çšã«å®è£ ããŸããããå€ãã®äººãbyããŠã¹ã±ãŒã©ãã«ã§ãªããœãªã¥ãŒã·ã§ã³ãšããŠæ¹å€ãããŠããŸãã
ã§ã¯ãããã§äœãã§ããã§ããããïŒ ããŠãæè¿ã Control Groups ïŒå¥åãcgroupsãïŒãã«ãŒãã«ã«ç»å ŽããŸããã äžè¬ã«ããããã䜿çšããŠããã»ã¹ã°ã«ãŒãã®éå±€ãäœæã§ããŸãã éå±€ã¯ä»®æ³ãã¡ã€ã«ã·ã¹ãã ã«çŽæ¥æ圱ããããããç°¡åã«ã¢ã¯ã»ã¹ã§ããŸãã ã°ã«ãŒãåã¯ãä»®æ³FSå ã®ãã£ã¬ã¯ããªã®ååã§ãã ããã»ã¹ãããããã®ã°ã«ãŒãã«å±ããŠããå Žåã forkïŒïŒåŒã³åºãã§äœæããããã¹ãŠã®åå«ïŒåããã»ã¹ïŒãåãã°ã«ãŒãã«å±ããŸãã ããã»ã¹ã«ç¹æš©ïŒã«ãŒããªã©ïŒã¯ãªãããcgroup FSãžã®ã¢ã¯ã»ã¹æš©ãããå Žåããã®ã°ã«ãŒãããé¢è±ã§ããŸããã åœåãã³ã³ããç®çã§cgroupãã«ãŒãã«ã«è¿œå ãããŸãããç¹å®ã®ã«ãŒãã«ãµãã·ã¹ãã ã¯ãCPUãŸãã¯ã¡ã¢ãªäœ¿çšéã®å¶éãªã©ããªãœãŒã¹ãŸãã¯ç¹å®ã®ã°ã«ãŒãã«å¶éãå ããå ŽåããããŸãã åŸæ¥ãå¶éã®å¶éïŒ setrlimitïŒïŒã§å®è£ ãããŠããïŒã¯ãåããã»ã¹ã«å¯ŸããŠïŒäž»ã«ïŒèšå®ãããŠããŸããã äžæ¹ã cgroupsã䜿çšãããšãããã»ã¹ã®ã°ã«ãŒãå šäœã«å¶éãèšå®ã§ããŸãã cgroups㯠ãã³ã³ããã®çŽæ¥çãªè²¬ä»»ã®ç¯å²å€ã§å¶éãèšå®ããããã«ã䜿çšãããŸãã ããšãã°ã cgroupsã䜿çšããŠãApacheãšãã®ãã¹ãŠã®åããã»ã¹ã䜿çšããã¡ã¢ãªãŸãã¯CPUã®æ倧éãèšå®ã§ããŸãã ãããªããšãCGIã¹ã¯ãªããã®åäœããããããªãããã®ã°ã«ãŒããsetrlimitïŒïŒã§å ¬éãããŸãŸã«ã§ããªããªããåã«forkïŒïŒãå床åŒã³åºãã ãã§æžã¿ãŸãã
ã³ã³ãããšãªãœãŒã¹ã®å¶éã®èšå®ã«å ããŠãcgroupã¯ããã»ã¹ïŒãµãŒãã¹ïŒã远跡ããããŒã«ãšããŠãéåžžã«äŸ¿å©ã§ããcgroupã®ã¡ã³ããŒã·ããã¯ããšã¹ã±ãŒãã§ããªããã¹ãŠã®åããã»ã¹ã«å®å šã«ç¶æ¿ãããŸãã éç¥ã·ã¹ãã ãååšããå®è¡äžã®cgroupã空ã®å Žåã芪ããã»ã¹ã«éç¥ãããŸãã ãã¡ã€ã«/ proc / $ PID / cgroupãèªã¿åããšãããã»ã¹ã®cgroupã確èªã§ããŸãã ãããã£ãŠã cgroupsã¯ããã»ã¹ã®èåŸã«ãããçè·åž«ãã®åœ¹å²ã«éåžžã«é©ããŠããŸãã çŽæ¥è¿œè·¡ã
ããã»ã¹ã©ã³ã¿ã€ã ã®å¶åŸ¡
åªããçè·åž«ã¯ããµãŒãã¹ããã€ãã©ã®ããã«éå§ãŸãã¯åæ¢ãããããŸãã¯çªç¶èœã¡ããšããç£èŠããã³å¶åŸ¡ããã ãã§ãªãããµãŒãã¹ãå®è¡ããããã®æå°éã®åªããå®å šãªç°å¢ãæäŸããå¿ èŠããããŸãã
å¿ãä¿è·ãããšããããšã¯ããªãœãŒã¹å¶é-setrlimit ããŠãŒã¶ãŒ/ã°ã«ãŒãèå¥åããŸãã¯ç°å¢å€æ°ã®ãããã¯ãªã©ã®æçœãªããã»ã¹ãã©ã¡ãŒã¿ãŒãèšå®ããããšãæå³ããŸãããããã ãã§ã¯ãããŸããã Linuxã«ãŒãã«ã¯ããŠãŒã¶ãŒãšç®¡çè ã«ããã»ã¹ã®é©åãªã¬ãã«ã®å¶åŸ¡ãæäŸããŸãã ããã»ã¹ããšã«ãCPUãšIOã®ã¹ã±ãžã¥ãŒã©ãŒãã©ã¡ãŒã¿ãŒãCPUãžã®ã¢ãã©ã¯ã·ã§ã³ããããŠãã¡ããcgroupç°å¢ã«è¿œå ã®å¶éãªã©ãèšå®ã§ããŸãã
äŸãšããŠã IOPRIO_CLASS_IDLEãæå®ããŠioprio_setïŒïŒãåŒã³åºããšãã·ã¹ãã ã®å¯Ÿè©±æ§ã«å¯Ÿããupdatedb LocateãŠãŒãã£ãªãã£ã®åœ±é¿ãæå°éã«æããããšãã§ããŸãã
ããã«ãèªã¿åãå°çšã®ç£èŠãã€ã³ãã«åºã¥ããŠè¿œå ã®èªã¿åãå°çšãã¡ã€ã«ã¬ã€ã€ãŒãããŠã³ãããïŒãã€ã³ãããŠã³ãïŒãªã©ãç¹å®ã®é«ã¬ãã«ã®ç£èŠããŒã«ã圹ç«ã¡ãŸãã ãããã£ãŠãç¹å®ã®ããŒã¢ã³ïŒãµãŒãã¹ïŒãèµ·åããŠãFSã®ãã¹ãŠïŒãŸãã¯äžéšïŒãèªã¿åãå°çšã¢ãŒãã§è¡šç€ºãããããã«ããããšãã§ããŸãããããã£ãŠãæžã蟌ã¿è©Šè¡ããšã«EROFSãšã©ãŒãè¿ãããŸãã ãã®ããã«ããŠã貧匱ãªSELinuxãšåãæ¹æ³ã§ãããŒã¢ã³ãã§ããããšã§éé¢ã§ããŸãïŒãã ãããã®æ¹æ³ã¯SELinuxã«ä»£ãããã®ã§ã¯ãããŸãããSELiãªã©ã®æªãã¢ã€ãã¢ã¯äœ¿çšããªãã§ãã ãã...ïŒã
ãããŠæåŸã«ã ãã®ã³ã°ã¯ããµãŒãã¹å®è¡ã®éèŠãªéšåã§ããçæ³çã«ã¯ããµãŒãã¹ã«ãã£ãŠçæããããã¹ãŠã®åºåããã°ã«èšé²ããå¿ èŠããããŸãã ãããã£ãŠãããŒãã·ã¹ãã ã¯ãããŠã³ããŒãã®æåããéå§ããããŒã¢ã³ã«ãã®ã³ã°ãµãŒãã¹ãæäŸããæšæºåºåãšãšã©ãŒåºåãsyslogã«æ·»ä»ããããå Žåã«ãã£ãŠã¯/ dev / kmsgã«æ·»ä»ããå¿ èŠããããŸããããã¯å€ãã®å Žåã syslog ïŒçµã¿èŸŒã¿ã·ã¹ãã ã«é¢ä¿ãã人ã¯ããªãã¹ã³ïŒïŒãç¹ã«ã«ãŒãã«ãã°ãããã¡ãéåžžã«å€§ããèšå®ãããŠããå Žåã
ç¶ç¶ããã«ã¯...