ã¡ãªã¿ã«ãé害ã®çŽåŸã®æåã®æç¹ã§ãéåžžã«éèŠãªè³ªåã«çãã䟡å€ããããŸãã åé¡ã®åå ããŸã£ãããªãå¯èœæ§ããããŸãã ããããèªåããå ã«é²ãŸãªãããã«ããŸãããã
ãã©ãã«ã·ã¥ãŒãã£ã³ã°ïŒåãšä»
1980幎代ã«ãLinus TorvaldsãLinuxã®æŠå¿µã«çæãããã£ãšåã«Unixã·ã¹ãã 管çè ãšããŠåãå§ãããšãããµãŒããŒã«äœãåé¡ãããã°ãããã¯æ¬åœã®åŸ ã¡äŒãã§ããã ãã®åŸãåé¡ãèŠã€ããããã®ããŒã«ãæ¯èŒçå°ãªãã£ããããé害ãçºçãããµãŒããŒãåã³æ©èœããããã«ã¯ãå€ãã®æéãããããŸããã
ä»ããã¹ãŠã以åãšã¯å®å šã«ç°ãªã£ãŠããŸãã ãã€ãŠãããã·ã¹ãã 管çè ãåé¡ãµãŒããŒã«ã€ããŠéåžžã«çå£ã«è©±ããŠãããŸããïŒãç§ã¯ãããç Žå£ããŠæ°ãããã®ãæã«å ¥ããŸãããã
æã¯ããã¯åœããåã®ããã«èãããŸããããä»æ¥ã§ã¯ãä»®æ³ãã·ã³ãšã³ã³ããã«åºã¥ããŠITã€ã³ãã©ã¹ãã©ã¯ãã£ãæ§ç¯ããããš...çµå±ãå¿ èŠã«å¿ããŠæ°ãããµãŒããŒãå±éããããšã¯ãã¯ã©ãŠãç°å¢ã§ã¯äžè¬çã§ãã
ããã§ã ChefãPuppetãªã©ã®DevOpsããŒã«ãè¿œå ããå¿ èŠããããŸããããã䜿çšãããš ãå€ããµãŒããŒã蚺æããã³ä¿®åŸ©ãããããæ°ãããµãŒããŒãäœæããæ¹ãç°¡åã§ãã ãŸããDocker SwarmãMesosphereãKubernetesãªã©ã®é«ã¬ãã«ããŒã«ã«ã€ããŠèª¬æãããšã管çè ãåé¡ãçºèŠããåã«ãé害ã®ãããµãŒããŒã®æ©èœãèªåçã«åŸ©å ãããŸãã
ãã®æŠå¿µã¯éåžžã«åºãŸã£ãããã ãµãŒããŒã¬ã¹ã³ã³ãã¥ãŒãã£ã³ã°ãšããååãäžããããŸããã ãã®ãããªæ©èœãæäŸãããã©ãããã©ãŒã ã«ã¯ã AWS Lambda ã Iron.io ã Google Cloud Functionsãªã©ããããŸãã
ãã®ã¢ãããŒãã®ãããã§ãã¯ã©ãŠããµãŒãã¹ã¯ãµãŒããŒç®¡çãæ åœããã¹ã±ãŒãªã³ã°ã®åé¡ãä»ã®å€ãã®ã¿ã¹ã¯ã解決ããŠãã¢ããªã±ãŒã·ã§ã³ãå®è¡ããããã«å¿ èŠãªã³ã³ãã¥ãŒãã£ã³ã°ãã¯ãŒãã¯ã©ã€ã¢ã³ãã«æäŸããŸãã
ãµãŒããŒã¬ã¹ã³ã³ãã¥ãŒãã£ã³ã°ãä»®æ³ãã·ã³ãã³ã³ãã-ãããã®æœè±¡åã¬ãã«ã¯ãã¹ãŠãå®ãµãŒããŒããŠãŒã¶ãŒããããããŠããçšåºŠã¯ã·ã¹ãã 管çè ããé ããŸãã ãã ãããããã¯ãã¹ãŠç©çããŒããŠã§ã¢ãšãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã«åºã¥ããŠããŸãã ãããŠããã®ã¬ãã«ã®äœããçªç¶ããŸããããªãå Žåã誰ãããã¹ãŠãæŽçããå¿ èŠããããŸãã ã§ããããä»æ¥ç§ãã¡ã話ããŠããããšã¯ãã®é¢é£æ§ã決ããŠå€±ããªãã®ã§ãã
ããã·ã¹ãã ãªãã¬ãŒã¿ãšã®äŒè©±ãèŠããŠããŸãã ã¯ã©ãã·ã¥åŸã®å¯ŸåŠæ¹æ³ã«ã€ããŠåœŒãèšã£ãã®ã¯ã次ã®ãšããã§ããããµãŒããŒãåã€ã³ã¹ããŒã«ããããšãéã§ãã ã ããç解ããŠããªã-è»ã«äœãèµ·ãã£ãã®ãããããŠãããå°æ¥èµ·ããã®ãé²ãæ¹æ³ã åäžã®é©åãªç®¡çè ããããè¡ãããã§ã¯ãããŸãããã ç§ã¯ããã«åæããŸãã åé¡ã®åå ãçºèŠããããŸã§ãåé¡ã解決ãããšèŠãªãããšã¯ã§ããŸããã
ãããã£ãŠãé害ãçºçãããµãŒããŒã®åã«ããŸãã¯å°ãªããšãåé¡ã®åå ãããã«ãããšèããããŸãã äžç·ã«5ã€ã®ã¹ããããå®è¡ããããšãææ¡ããŸããããããæ€çŽ¢ãéå§ããåé¡ã解決ãã䟡å€ããããŸãã
æåã®ã¹ãããã ããŒããŠã§ã¢ãã§ãã¯
ãŸã第äžã«-ããŒããŠã§ã¢ã確èªããŠãã ããã ç§ã¯ãããäºçŽ°ã§æ代é ãã«èããããããããŸãããããšã«ãã-ãããããŠãã ããã æ€ åããåºãŠããµãŒããŒã©ãã¯ã«ç§»åãããµãŒããŒãéåžžã®æäœã«å¿ èŠãªãã®ãã¹ãŠã«æ£ããæ¥ç¶ãããŠããããšã確èªããŸãã
åé¡ã®åå ãæ€çŽ¢ããŠã±ãŒãã«æ¥ç¶ã«ã€ãªãã£ãåæ°ãã«ãŠã³ãããããšã¯ã§ããŸããã LEDãèŠããšãã€ãŒãµãããã±ãŒãã«ãåŒãæãããŠãããããµãŒããŒã®é»æºããªãã«ãªã£ãŠããããšãæããã«ãªããŸãã
ãã¡ããããã¹ãŠãå€å°ãŸãšãã«èŠããå Žåã¯ããµãŒããŒã«ã¢ã¯ã»ã¹ããã«ãã®ã³ãã³ãã§ã€ãŒãµãããæ¥ç¶ã®ã¹ããŒã¿ã¹ã確èªã§ããŸãã
$ sudo ethtool eth0
圌女ã®çãããã¯ãããšè§£éã§ããå Žåãããã¯èª¿æ»äžã®ã€ã³ã¿ãŒãã§ã€ã¹ããããã¯ãŒã¯äžã§ããŒã¿ã亀æã§ããããšãæå³ããŸãã
ãã ããããã€ã¹ãå人çã«æ€æ»ããæ©äŒãç¡èŠããªãã§ãã ããã ããã¯ãããšãã°ã誰ããéèŠãªã±ãŒãã«ãæããŠããµãŒããŒãŸãã¯ã©ãã¯å šäœã®é»æºãåã£ãããšãç¥ãã®ã«åœ¹ç«ã¡ãŸãã ã¯ããããã¯éæ¹ããªãç°¡åã§ãããã·ã¹ãã é害ã®åå ããŸãã«ããã§ããããšãé©ãã¹ãããšã§ãã
ãã1ã€ã®äžè¬çãªããŒããŠã§ã¢ã®åé¡ã¯èçŒã§ã¯èªèã§ããŸããã ãããã£ãŠãäžè¯ã¡ã¢ãªã¯ããããçš®é¡ã®åé¡ã®åå ã§ãã
ä»®æ³ãã·ã³ãšã³ã³ããã¯ãããã®åé¡ãé ãããšãã§ããŸãããç¹å®ã®ç©çå°çšãµãŒããŒã«é¢é£ããé害ãèªç¶ã«çºçããå Žåã¯ããã®ã¡ã¢ãªã確èªããŠãã ããã
ã¡ã¢ãªãå«ãã³ã³ãã¥ãŒã¿ãŒããŒããŠã§ã¢ã®BIOS / UEFIã¬ããŒãã衚瀺ããã«ã¯ã dmidecodeã³ãã³ãã䜿çšããŸã ã
$ sudo dmidecode --type memory
ããã§ãã¹ãŠãæ£åžžã«èŠããŠããå®éã«ã¯ããã§ã¯ãªããããããŸããã å®éãSMBIOSããŒã¿ã¯åžžã«æ£ç¢ºã§ãããšã¯éããŸããã ãããã£ãŠã
dmidecode
åŸã§ãã¡ã¢ãªãçãããå Žåã¯ã Memtest86ã䜿çšããŸãã ããã¯åªããã¡ã¢ãªãã§ãã«ãŒã§ãããåäœãé ãã§ãã ãµãŒããŒã§å®è¡ããå Žåã¯ããã§ãã¯ãå®äºãããŸã§ããã®ãã·ã³ãä»ã®ç®çã«äœ¿çšã§ããããšãæåŸ ããªãã§ãã ããã
å€ãã®ã¡ã¢ãªã®åé¡ã«çŽé¢ããŠããå Žå-é»æºãäžå®å®ãªå Žæã§ãããèŠãŠããŸãã-Linuxã«ãŒãã«ã¢ãžã¥ãŒã«edac_coreãããŒãããå¿ èŠããããŸãã ãã®ã¢ãžã¥ãŒã«ã¯ã äžè¯ã»ã¯ã·ã§ã³ãæ¢ãããã«ã¡ã¢ãªãåžžã«ãã§ãã¯ããŸã ã ãã®ã¢ãžã¥ãŒã«ãããŠã³ããŒãããã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸãã
$ sudo modprobe edac_core
ãã°ããåŸ ã£ãŠã次ã®ã³ãã³ããå®è¡ããŠäœããèŠãããã©ããã確èªããŸãã
$ sudo grep "[0-9]" /sys/devices/system/edac/mc/mc*/csrow*/ch*_ce_count
ãã®ã³ãã³ãã¯ãã¡ã¢ãªã¢ãžã¥ãŒã«ïŒååã
csrow
å§ãŸãã€ã³ãžã±ãŒã¿ãŒïŒã«ãã£ãŠåé¡ããããšã©ãŒã®æ°ã®æŠèŠã衚瀺ããŸãã ãã®æ å ±ããã¡ã¢ãªãã£ãã«ãã¹ããããã³ã³ããŒãã³ãã®ã·ãªã¢ã«çªå·ã®
dmidecode
ããŒã¿ãšæ¯èŒãããšãäžè¯ã¡ã¢ãªããŒãç¹å®ããã®ã«åœ¹ç«ã¡ãŸãã
ã¹ããã2 åé¡ã®çã®åå ãèŠã€ãã
ãã®ããããµãŒããŒã¯å¥åŠãªåäœãéå§ããŸãããããµãŒããŒããã®ç ã¯ãŸã æ¶ããŠããŸããã ãµãŒããŒããžãã¹ã§ããïŒ åé¡ã解決ããåã«ããŸããã®åå ãæ£ç¢ºã«ç¹å®ããå¿ èŠããããŸãã ããšãã°ããŠãŒã¶ãŒããµãŒããŒã¢ããªã±ãŒã·ã§ã³ã®å¥åŠãã«ã€ããŠèŠæ ãèšãå Žåã¯ããŸãåé¡ã®åå ãã¯ã©ã€ã¢ã³ãã®é害ã§ã¯ãªãããšã確èªããŠãã ããã
ããšãã°ãããå人ããIBM Tivoli Storage Managerã䜿çšããŠäœæ¥ã§ããªããšãŠãŒã¶ãŒãèšã£ãããšãæããŠãããŸããã ãã¡ãããæåã¯ãµãŒããŒããã¹ãŠã®çœªãç¯ããŠããããã«èŠããŸããã ããããæçµçã«ã管çè ã¯åé¡ããµãŒããŒéšåã«ãŸã£ããé¢ä¿ãªãããšãçºèŠããŸããã ãã®çç±ã¯ãWindowsã¯ã©ã€ã¢ã³ã3076895ã®ãããã®å€±æã§ã ã ãããããã®ã»ãã¥ãªãã£æŽæ°ããã°ã©ã ã倱æãããããçºçããããšããµãŒããŒåŽã®åé¡ã®ããã«èŠããŸããã
ãŸãããµãŒããŒèªäœãŸãã¯ãµãŒããŒã¢ããªã±ãŒã·ã§ã³ãåé¡ã®åå ã§ãããã©ãããç解ããå¿ èŠããããŸãã ããšãã°ããµãŒããŒããã°ã©ã ã¯ãã®ãããªãã®ãåäœãããããšãã§ããããŒããŠã§ã¢ã¯å®ç§ãªç¶æ ã«ãããŸãã
æå§ãã«-æãæçœã ã¢ããªã¯æ©èœããŸããïŒ ããã確èªããã«ã¯å€ãã®æ¹æ³ããããŸãã ç§ã®ãæ°ã«å ¥ãã®2ã€ã次ã«ç€ºããŸãã
$ sudo ps -ef | grep apache2 $ sudo netstat -plunt | grep apache2
ããšãã°ãApache WebãµãŒããŒãæ©èœããŠããªãããšãå€æããå Žåã¯ã次ã®ã³ãã³ãã§èµ·åã§ããŸãã
$ sudo service apache2 start
ç°¡åã«èšãã°ããµãŒããŒã蚺æããŠåé¡ã®åå ãæ¢ãåã«ããµãŒããŒã«åé¡ãããã®ãââããããšãäœãä»ã®åé¡ãããã®ãââã調ã¹ãŠãã ããã é害ã®åå ãã©ãã«ããããæ£ç¢ºã«ç解ããå Žåã«ã®ã¿ãé©åãªè³ªåãããŠãäœãèµ·ãã£ãã®ããããã«åæããããšãã§ããŸãã
ããã¯ãäºæããªãè»ã®åè»ãšæ¯èŒã§ããŸãã è»ã¯ãã以äžé²ãŸãªãããšãããã£ãŠããŸããããµãŒãã¹ã«ãã©ãã°ããåã«ãã¿ã³ã¯å ã«ã¬ã¹ããããã©ããã確èªããããšããå§ãããŸãã
ã¹ããã3 topã³ãã³ãã䜿çšãã
ãããã£ãŠããã¹ãŠã®ãã¹ããµãŒããŒã«ã€ãªããããšãå€æããå Žåãã·ã¹ãã ããã§ãã¯ããããã®å¥ã®éèŠãªããŒã«-topã³ãã³ãããããŸãã ãµãŒããŒã®å¹³åè² è·ã®ç¢ºèªãããŒãžã³ã°ãã¡ã€ã«ã®äœ¿çšãããã»ã¹ã䜿çšããã·ã¹ãã ãªãœãŒã¹ã®ç¢ºèªãè¡ãããšãã§ããŸãã ãã®ãŠãŒãã£ãªãã£ã¯ãã·ã¹ãã ã«é¢ããäžè¬æ å ±ã衚瀺ããLinuxãµãŒããŒã§å®è¡äžã®ãã¹ãŠã®ããã»ã¹ã«é¢ããããŒã¿ã衚瀺ããŸãã 以äžã¯ããã®ã³ãã³ãã衚瀺ããããŒã¿ã®è©³çŽ°ãªèª¬æã§ãã ããã§ã¯ããµãŒããŒã®åé¡ãèŠã€ããã®ã«åœ¹ç«ã€å€ãã®æ å ±ãèŠã€ããããšãã§ããŸãã ããã§ã¯ãåé¡é åãèŠã€ããã®ã«åœ¹ç«ã€
top
ãæäœãã䟿å©ãªæ¹æ³ãããã€ã玹ä»ããŸãã
æãã¡ã¢ãªãæ¶è²»ããããã»ã¹ãèŠã€ããã«ã¯ãããŒããŒããã
M
å ¥åããŠãããã»ã¹ã®ãªã¹ãã察話çã«ãœãŒãããå¿ èŠããããŸãã æãCPUãªãœãŒã¹ãæ¶è²»ããã¢ããªã±ãŒã·ã§ã³ãèŠã€ããã«ã¯ã
P
å ¥åããŠãªã¹ãããœãŒãããŸã
P
ã¢ã¯ãã£ããã£æéã§ããã»ã¹ããœãŒãããã«ã¯ãããŒããŒããã
T
ãå ¥åããŸãã ãœãŒãçšã®åãèŠãããããã«ã¯ã
b
æŒããŸãã
ããã«ãããŒã ã察話圢åŒã§è¡šç€ºããããã»ã¹ããŒã¿ã¯ã
O
ãŸãã¯
o
å ¥åããŠãã£ã«ã¿ãªã³ã°ã§ããŸãã 次ã®ããã³ããã衚瀺ããããã£ã«ã¿ãŒãè¿œå ããããæ±ããããŸãã
add filter #1 (ignoring case) as: [!]FLD?VAL
次ã«ããã³ãã¬ãŒããå ¥åããŠãããšãã°ãç¹å®ã®ããã»ã¹ã§ãã£ã«ã¿ãªã³ã°ã§ããŸãã ããšãã°ããã£ã«ã¿ãŒ
COMMAND=apache
ãããã§ãããã°ã©ã ã¯Apacheããã»ã¹ã«é¢ããæ å ±ã®ã¿ã衚瀺ããŸãã
top
ã®ãã1ã€ã®äŸ¿å©ãªæ©èœã¯ãããã»ã¹ã®ãã«ãã¹ãšèµ·ååŒæ°ãåºåããããšã§ãã ãã®ããŒã¿ã衚瀺ããã«ã¯ã
c
ããŒã䜿çšããŸãã
V
æåãå ¥åãããšãåæ§ã®
top
æ©èœãã¢ã¯ãã£ãã«ãªããŸãã ããã»ã¹æ å ±ã®é局衚瀺ã«åãæ¿ããããšãã§ããŸãã
ããã«ã
u
ããŒãŸãã¯
U
ããŒã䜿çšããŠç¹å®ã®ãŠãŒã¶ãŒã®ããã»ã¹ã衚瀺ãããã
i
ããŒãæŒããŠããã»ããµãŒãªãœãŒã¹ãæ¶è²»ããªãããã»ã¹ãé衚瀺ã«ãããã§ããŸãã
top
é·ãéãã·ã¹ãã ã®çŸåšã®ç¶æ³ã衚瀺ããããã®æã人æ°ã®ãã察話åLinuxãŠãŒãã£ãªãã£ã§ããã代æ¿æ段ããããŸãã ããšãã°ãããã°ã©ã htopã«ã¯æ©èœã®æ¡åŒµã»ããããããããã·ã³ãã«ã§äŸ¿å©ãªã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹Ncursesãç°ãªããŸãã
htop
ã䜿çšããå ŽåãããŠã¹ã䜿çšããŠããã»ã¹ã®ãªã¹ããåçŽããã³æ°Žå¹³ã«ã¹ã¯ããŒã«ããŠãå®å šãªãªã¹ããšå®å šãªã³ãã³ãã©ã€ã³ã衚瀺ã§ããŸãã
top
åé¡
top
æããŠããããšã¯æããªãã ããããç§ã¯ãã®ããŒã«ã䜿çšããŠããã§ãããã¯é¢çœãããšæãããã«ãªããããã«ç 究ããããã«ä¿ããŸãã
top
ããã®ããŒã¿ã«åºã¥ããŠãããšãã°ãã©ã®ãã°ãæåã«èŠã䟡å€ãããããããããŸãã
less
ã
grep
tail -f
ã³ãã³ãã®çµã¿åããã䜿çšããŠãã°ã調ã¹ãŸãã
4çªç®ã®ã¹ãããã ãã£ã¹ã¯å®¹éã®ãã§ãã¯
ä»æ¥ã§ãããã©ãã€ãåäœã®æ å ±ããã±ããã«å ¥ããŠæã¡éã¹ããšããµãŒããŒã¯ãŸã£ããæ°ä»ããªããã¡ã«ãã£ã¹ã¯å®¹éã䜿ãæããå¯èœæ§ããããŸãã ãããçºçãããšãéåžžã«å¥åŠãªããšãããããŸãã
ãã£ã¹ã¯å®¹éãåŠçããããã«ãå€ãããããdfã³ãã³ãã圹ã«ç«ã¡ãŸãããã®ã³ãã³ãã®ååã¯ãdisk filesystemãã®ç¥èªã§ãã ãã®å©ããåããŠããã£ã¹ã¯äžã®ç©ºãé åãšäœ¿çšæžã¿é åã®æŠèŠãååŸã§ããŸãã
éåžžã
df
2ã€ã®æ¹æ³ã§äœ¿çšãããŸãã
$ sudo df -h
ããŒããã£ã¹ã¯äžã®ããŒã¿ãèªèã«äŸ¿å©ãªåœ¢åŒã§è¡šç€ºããŸãã ããšãã°ããã©ã€ãã®ããªã¥ãŒã ã«é¢ããæ å ±ã¯ã®ã¬ãã€ãåäœã§è¡šç€ºãããæ£ç¢ºãªãã€ãæ°ã®åœ¢åŒã§ã¯ãããŸããã
$ sudo df -i
䜿çšãããŠããiããŒãã®æ°ãšãã¡ã€ã«ã·ã¹ãã ã«å¯Ÿããå²åã衚瀺ããŸãã
ãã1ã€ã®äŸ¿å©ãª
df â T
ãã©ã°
df â T
ãã¡ã€ã«ã·ã¹ãã ã¹ãã¬ãŒãžã®ã¿ã€ãã«é¢ããããŒã¿ã衚瀺ã§ããŸãã ããšãã°ã
$ sudo df -hT
ãšãã圢åŒã®ã³ãã³ãã¯ã䜿çšãããŠãããã£ã¹ã¯å®¹éãšãã¡ã€ã«ã·ã¹ãã äžã®ããŒã¿ã®äž¡æ¹ã衚瀺ããŸãã
å¥åŠã«æãããå Žåã¯ã Iostatã³ãã³ãã䜿çšããŠããã«æãäžããããšãã§ããŸãã ããã¯ãé«åºŠãªã·ã¹ãã ç£èŠããŒã«ãããã§ããsysstatã®äžéšã§ãã ããã»ããµã«é¢ããæ å ±ãšãããŒãã£ã·ã§ã³ããã³ãããã¯ãŒã¯ãã¡ã€ã«ã·ã¹ãã ã®ãããã¯ã¹ãã¬ãŒãžããã€ã¹ã®I / Oãµãã·ã¹ãã ã®ããŒã¿ã衚瀺ãããŸãã
ããããããã®ã³ãã³ããåŒã³åºãæã䟿å©ãªæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
$ iostat -xz 1
ãã®ã³ãã³ãã¯ãããã€ã¹ã®èªã¿åãããã³æžã蟌ã¿ããŒã¿ã®ããªã¥ãŒã ã«é¢ããæ å ±ã衚瀺ããŸãã ããã«ãå¹³åI / Oæéãããªç§åäœã§è¡šç€ºããŸãã ãã®å€ãé«ãã»ã©ããã©ã€ããèŠæ±ã§éè² è·ã«ãªã£ãŠããããããŒããŠã§ã¢ã®åé¡ã«çŽé¢ããŠããå¯èœæ§ãé«ããªããŸãã ãã£ããäœïŒ ããã§ã
top
ãŠãŒãã£ãªãã£ã䜿çšããŠãMySQLãµãŒããŒïŒãŸãã¯ãã®äžã§å®è¡ãããŠããä»ã®DBMSïŒãããŒããããŠãããã©ããã確èªã§ããŸãã ãã®ãããªã¢ããªã±ãŒã·ã§ã³ãèŠã€ãããªãã£ãå Žåããã£ã¹ã¯ã«äœãåé¡ãããå¯èœæ§ããããŸãã
ãã1ã€ã®éèŠãªææšã¯ã
%util
ã»ã¯ã·ã§ã³ã«ãããããã€ã¹ã®äœ¿çšç¶æ³ã«é¢ããæ å ±ã衚瀺ãããŸãã ãã®ã€ã³ãžã±ãŒã¿ã¯ãããã€ã¹ã®åäœã®åŒ·ãã瀺ããŸãã 60ïŒ ãè¶ ããå€ã¯ããã£ã¹ã¯ãµãã·ã¹ãã ã®ããã©ãŒãã³ã¹ãäœãããšã瀺ããŸãã å€ã100ïŒ ã«è¿ãå Žåãããã¯ãã©ã€ãããã®éçã§åäœããŠããããšãæå³ããŸãã
ãã£ã¹ã¯æ€èšŒãŠãŒãã£ãªãã£ã䜿çšãããšãã¯ãæ£ç¢ºã«åæããŠããããšã«æ³šæããŠãã ããã
ããšãã°ãè€æ°ã®ç©çãã£ã¹ã¯ã§æ§æãããè«çãã©ã€ãã®100ïŒ ã®è² è·ã¯ãã·ã¹ãã ãåžžã«äžéšã®I / OæäœãåŠçããŠããããšãæå³ããã ãã§ãã éèŠãªã®ã¯ãç©çãã£ã¹ã¯ã§äœãèµ·ãããã§ãã ãããã£ãŠãè«çãã©ã€ããåæããŠããå Žåããã£ã¹ã¯ãŠãŒãã£ãªãã£ã¯æçšãªæ å ±ãæäŸããªãããšã«æ³šæããŠãã ããã
ã¹ããã5 ãã°ã確èªãã
ãªã¹ãã®æåŸã«ãéèŠåºŠã§ã¯ãªãé çªã«ã®ã¿ãã°ããã§ãã¯ããŠããŸãã éåžžããããã¯
/var/log
ããŸããŸãªãµãŒãã¹ã®åå¥ã®ãã©ã«ããŒã«ãããŸãã
Linuxã®åå¿è ã«ãšã£ãŠããã°ãã¡ã€ã«ã¯ã²ã©ãããã·ã¥ã®ããã«èŠãããããããŸããã ãããã¯ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãšã¢ããªã±ãŒã·ã§ã³ã®åäœã«é¢ããæ å ±ãèšé²ããããã¹ããã¡ã€ã«ã§ãã ãšã³ããªã«ã¯2çš®é¡ãããŸãã 1ã€ã®ã¬ã³ãŒãã¯ãã·ã¹ãã ãŸãã¯ããã°ã©ã ã§çºçããããšã§ããããšãã°ãåãã©ã³ã¶ã¯ã·ã§ã³ãŸãã¯ããŒã¿ã®ç§»åã§ãã 2çªç®ã¯ãšã©ãŒã¡ãã»ãŒãžã§ãã ãã°ãã¡ã€ã«ã«ã¯äž¡æ¹ãå«ããããšãã§ããŸãã ãããã®ãã¡ã€ã«ã¯åçŽã«å·šå€§ã«ãªãå¯èœæ§ããããŸãã
éåžžããã°ãã¡ã€ã«å ã®ããŒã¿ã¯éåžžã«äžæè°ã«èŠããŸããããããææ¡ããå¿ èŠããããŸãã ããšãã°ã ããã§ã¯ãDigital Oceanãããã®ãããã¯ã玹ä»ããŠããŸãã
ãã°ã確èªããã®ã«åœ¹ç«ã€å€ãã®ããŒã«ããããŸãã ããšãã°ã dmesg ã ãã®ãŠãŒãã£ãªãã£ã¯ãã«ãŒãã«ã¡ãã»ãŒãžã衚瀺ããŸãã éåžžããããã¯å€æ°ããããã次ã®ç°¡åãªã³ãã³ãã©ã€ã³ã¹ã¯ãªããã䜿çšããŠãæåŸã®10ãšã³ããªã衚瀺ããŸãã
$ dmesg | tail
äœãèµ·ãã£ãŠããã®ãããªã¢ã«ã¿ã€ã ã§è¿œè·¡ãããã§ããïŒ åé¡ãæ¢ããŠãããšããç§ã¯ééããªããããå¿ èŠãšããŸãã ãããå®çŸããã«ã¯ã
-f
ããŠ
tail
ã³ãã³ãã䜿çšã
tail
ã 次ã®ããã«ãªããŸãã
$ dmesg | tail -f /var/log/syslog
äžèšã®ã³ãã³ãã¯
syslog
ãã¡ã€ã«ãç£èŠããæ°ããã€ãã³ãã«é¢ããæ å ±ãåãåããšãããããç»é¢ã«è¡šç€ºããŸãã
å¥ã®äŸ¿å©ãªã³ãã³ãã©ã€ã³ã¹ã¯ãªããã次ã«ç€ºããŸãã
$ sudo find /var/log -type f -mtime -1 -exec tail -Fn0 {} +
ãã°ãã¹ãã£ã³ããèããããåé¡ã瀺ããŸãã
systemdãã·ã¹ãã ã§äœ¿çšãããŠããå Žåãéèªãæäœããããã®çµã¿èŸŒã¿ããŒã«Journalctlã䜿çšããå¿ èŠããããŸãã Systemdã¯ã
journald
ããŒã¢ã³ã䜿çšããŠãã®ã³ã°ç®¡çãéäžåããŸãã ä»ã®Linuxãã°ãšã¯ç°ãªãã
journald
ã¯ããã¹ã圢åŒã§ã¯ãªããã€ããªåœ¢åŒã§ããŒã¿ãä¿åããŸãã
ã·ã¹ãã ã®åèµ·ååŸããã°ãä¿æããããã«
journald
ãæ§æãããšäŸ¿å©ã§ãã ãããè¡ãã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸãã
$ sudo mkdir -p /var/log/journal
ãšã³ããªã®æ°žç¶çãªä¿åãæå¹ã«ããã«ã¯ã/
/etc/systemd/journald.conf
ãã¡ã€ã«ãç·šéããŠæ¬¡ãå«ããå¿ èŠããããŸãã
[Journal] Storage=persistent
ãããã®ãã°ã䜿çšããæãäžè¬çãªæ¹æ³ã¯ã次ã®ã³ãã³ãã䜿çšããããšã§ãã
journalctl -b
æåŸã®åèµ·ååŸããã¹ãŠã®ãã°ãšã³ããªã衚瀺ãããŸãã ã·ã¹ãã ããªããŒããããå Žåããã®ã³ãã³ãã䜿çšããåã«äœãèµ·ãã£ãããèŠãããšãã§ããŸãïŒ
$ journalctl -b -1
ããã«ããã以åã®ãµãŒããŒã»ãã·ã§ã³ã§äœæããããã°ãšã³ããªã衚瀺ã§ããŸãã
journalctl
䜿çšæ¹æ³ã«é¢ããæçšãªè³æã以äžã«ç€ºããŸãã
ãã°ã¯éåžžã«å€§ããããããã°ãæ±ãã®ã¯å°é£ã§ãã ãããã£ãŠãã³ãã³ãã©ã€ã³ããŒã«ïŒ
grep
ã
awk
ãªã©ïŒã䜿çšããŠå¯ŸåŠã§ããŸããããã°ã衚瀺ããããã®ç¹å¥ãªããã°ã©ã ã䜿çšãããšäŸ¿å©ã§ãã
ããšãã°ãç§ã¯GraylogãªãŒãã³ãœãŒã¹ãã°ç®¡çã·ã¹ãã ã奜ãã§ãã 圌女ã¯ããŸããŸãªæ å ±ãåéã玢åŒä»ããåæããŸãã ããŒã¿ãæäœããããã®MongoDBãš ããã°ãã¡ã€ã«ãæ€çŽ¢ããããã®Elasticsearchã«åºã¥ããŠããŸãã Graylogã¯ããµãŒããŒã®ç¶æ ç£èŠãç°¡çŽ åããŸãã Graylogã¯ãçµã¿èŸŒã¿ã®LinuxããŒã«ãšæ¯èŒãããšãããã·ã³ãã«ã§äŸ¿å©ã§ãã ããã«ããã®äŸ¿å©ãªæ©èœã®äžã§ããChefãPuppetã Ansibleãªã©ã®å€ãã®DevOpsã·ã¹ãã ã§åäœããæ©èœã«æ³šç®ããããšãã§ããŸãã
ãŸãšã
ãµãŒããŒãšã®é¢ä¿ã«é¢ä¿ãªããæãé·ãæ©èœãããµãŒããŒãšããŠã®ãã¹ããã¯ã«å«ãŸããªãå ŽåããããŸãã ãããããµãŒããŒãå¯èœãªéãå®å®ãããåé¡ã®æ ¹åºã«å°éããŠããããä¿®æ£ããããšã¯äŸ¡å€ã®ããç®æšã§ãã æ¬æ¥ã話ãããããšãããã®ç®æšã®éæã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã
芪æãªãèªè ïŒ ãŸããã¯ã©ãã·ã¥ãããµãŒããŒã§ã¯éåžžäœãããŸããïŒ