ÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´£¿
ÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´£¿
÷è÷ë²Ù×÷ϵͳÊÇÓÉÖйú×ÔÖ÷¿ª·¢µÄÒ»¿î»ùÓÚLinuxµÄ²Ù×÷ϵͳ£¬ÆÕ±éÓ¦ÓÃÓÚÕþ¸®¡¢ÆóÊÂÒµµ¥Î»ÒÔ¼°Ð¡ÎÒ˽ÈËÓû§¡£ÔÚʹÓÃ÷è÷ë²Ù×÷ϵͳµÄÀú³ÌÖУ¬¿ÉÄÜ»áÓöµ½Ò»Ð©ÏµÍ³¹ÊÕÏ£¬ÈôÊÇÄܹ»ÊìÁ·µØ¾ÙÐÐÅŲéºÍÐÞ¸´£¬¹ØÓÚÌá¸ß²Ù×÷ϵͳµÄÎȹÌÐÔºÍÐÔÄܺÜÊÇÖ÷Òª¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´µÄ»ù±¾ÒªÁìºÍ³£Óù¤¾ß£¬²¢¸½ÉÏһЩ´úÂëʾÀý¡£
Ò»¡¢»ù±¾ÅŲéÒªÁì
Éó²éϵͳÈÕÖ¾£º
ϵͳÈÕÖ¾ÊǼͼ²Ù×÷ϵͳÔËÐÐÇéÐεÄÖ÷Òª¹¤¾ß£¬Í¨¹ýÉó²éϵͳÈÕÖ¾¿ÉÒÔÏàʶϵͳ¹ÊÕϵÄÔµ¹ÊÔÓÉ¡£ÔÚ÷è÷ë²Ù×÷ϵͳÖУ¬ÏµÍ³ÈÕÖ¾Ö÷Òª´æ´¢ÔÚ/var/logĿ¼Ï£¬³£¼ûµÄϵͳÈÕÖ¾°üÀ¨/var/log/messagesºÍ/var/log/syslog¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éϵͳÈÕÖ¾£º
cat /var/log/messages cat /var/log/syslog
µÇ¼ºó¸´ÖÆ
¼ì²éÀú³Ì״̬£º
Àú³ÌÊDzÙ×÷ϵͳÖÐÕýÔÚÔËÐеijÌÐòµÄʵÀý£¬Àú³ÌµÄÒ쳣״̬¿ÉÄܻᵼÖÂϵͳ¹ÊÕÏ¡£Í¨¹ýpsÏÂÁî¿ÉÒÔÉó²éϵͳÖÐÕýÔÚÔËÐеÄÀú³Ì£¬³£ÓõÄpsÏÂÁî°üÀ¨£º
ps -ef # Éó²éËùÓÐÀú³Ì ps -ef | grep "Àú³ÌÃû" # Éó²éÖ¸¶¨Àú³Ì
µÇ¼ºó¸´ÖÆ
¼ì²éϵͳ¸ºÔØ£º
ϵͳ¸ºÔØÌåÏÖϵͳĿ½ñµÄÊÂÇéÁ¿£¬¹ý¸ßµÄ¸ºÔØ¿ÉÄܻᵼÖÂϵͳÏìÓ¦»ºÂýÉõÖÁÍ߽⡣¿ÉÒÔʹÓÃuptimeÏÂÁîÉó²éϵͳ¸ºÔØÇéÐΣº
uptime
µÇ¼ºó¸´ÖÆ
¼ì²éÍøÂçÅþÁ¬£º
ÍøÂçÅþÁ¬ÊÇ÷è÷ë²Ù×÷ϵͳÖг£¼ûµÄ¹ÊÕϵãÖ®Ò»£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²éÍøÂçÅþÁ¬×´Ì¬£º
ifconfig # Éó²éÍøÂç½Ó¿ÚÐÅÏ¢ ping ipµØµã # ²âÊÔÍøÂçÅþÁ¬
µÇ¼ºó¸´ÖÆ
¶þ¡¢³£ÓùÊÕÏÅŲ鹤¾ß
topÏÂÁ
topÏÂÁî¿ÉÒÔʵʱ¼àÊÓϵͳµÄÔËÐÐ״̬£¬°üÀ¨CPUʹÓÃÂÊ¡¢ÄÚ´æÕ¼ÓÃÂÊ¡¢Àú³ÌÊýÄ¿µÈ¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖúÍʹÓÃtopÏÂÁ
sudo apt-get install top # ×°ÖÃtopÏÂÁî top # Ö´ÐÐtopÏÂÁî
µÇ¼ºó¸´ÖÆ
dmesgÏÂÁ
dmesgÏÂÁî¿ÉÒÔÉó²éÄÚºËÆô¶¯ÐÅÏ¢ºÍ×°±¸Çý¶¯³ÌÐòÊä³öµÄÐÅÏ¢¡£Í¨¹ýÉó²édmesgÏÂÁîÊä³öµÄÐÅÏ¢£¬¿ÉÒÔÏàʶϵͳÖзºÆðµÄÓ²¼þ¹ÊÕÏ¡¢Çý¶¯³ÌÐòÎÊÌâµÈ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²édmesgÏÂÁîÊä³öµÄÐÅÏ¢£º
dmesg
µÇ¼ºó¸´ÖÆ
lsofÏÂÁ
lsofÏÂÁî¿ÉÒÔÉó²éÖ¸¶¨Îļþ»òÀú³ÌÏà¹ØµÄÐÅÏ¢£¬°üÀ¨Àú³ÌID£¨PID£©¡¢·¿ªÎļþµÄ·½·¨ºÍÀàÐ͵ȡ£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²élsofÏÂÁîÊä³öµÄÐÅÏ¢£º
lsof # Éó²éϵͳ·¿ªµÄÎļþ lsof -i tcp:¶Ë¿ÚºÅ # Éó²éÖ¸¶¨¶Ë¿ÚµÄÐÅÏ¢
µÇ¼ºó¸´ÖÆ
straceÏÂÁ
straceÏÂÁî¿ÉÒÔ¸ú×ٺͼÍÈÎÃü»§¿Õ¼äÀú³ÌÓëÄÚºËÖ®¼äµÄ½»»¥Àú³Ì£¬ÌṩÁ˶ÔÀú³ÌϵͳŲÓúÍÐźÅת´ïµÄÏêϸÆÊÎö¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°ÖúÍʹÓÃstraceÏÂÁ
sudo apt-get install strace # ×°ÖÃstraceÏÂÁî strace ³ÌÐòÃû # Ö´ÐÐstraceÏÂÁî
µÇ¼ºó¸´ÖÆ
Èý¡¢³£¼û¹ÊÕÏ°¸Àý¼°ÐÞ¸´ÒªÁì
ÎÞ·¨Æô¶¯ÏµÍ³£º
ÈôÊÇ÷è÷ë²Ù×÷ϵͳÎÞ·¨Æô¶¯£¬¿ÉÒÔʵÑé½øÈëϵͳ»Ö¸´Ä£Ê½£¬ÐÞ¸´ÏµÍ³Ö¸µ¼Ïà¹ØµÄÎÊÌâ¡£ÏêϸҪÁìΪ£¬ÔÚϵͳÆô¶¯Ê±°´ÏÂShift¼ü£¬½øÈëGRUBÖ¸µ¼²Ëµ¥£¬Ñ¡Ôñ»Ö¸´Ä£Ê½£¬½øÈëÏÂÁîÐнçÃ棬ͨ¹ýÒÔÏÂÏÂÁîÐÞ¸´Ö¸µ¼£º
grub-install /dev/sda # ÐÞ¸´Ö¸µ¼ update-grub # ¸üÐÂÖ¸µ¼²Ëµ¥
µÇ¼ºó¸´ÖÆ
ÄÚ´æ×ß©£º
ÄÚ´æ×ß©ÊÇÖ¸³ÌÐòÔÚÔËÐÐÀú³ÌÖÐδÄÜ׼ȷÊÍ·ÅÒÑ·ÖÅɵÄÄÚ´æ¿Õ¼ä£¬µ¼ÖÂϵͳÄÚ´æÕ¼ÓÃÒ»Ö±ÔöÌí£¬×îÖÕµ¼ÖÂϵͳÍ߽⡣¿ÉÒÔʹÓÃtopÏÂÁîÉó²éϵͳÖÐÕ¼ÓÃÄÚ´æ½Ï¶àµÄÀú³Ì£¬Í¨¹ýkillÏÂÁîÖÕÖ¹Òì³£Àú³Ì£¬Êͷű»Õ¼ÓõÄÄڴ棺
top # Éó²éÀú³ÌÄÚ´æÕ¼ÓÃÇéÐÎ kill Àú³ÌID # ÖÕÖ¹Ö¸¶¨Àú³Ì
µÇ¼ºó¸´ÖÆ
Îļþϵͳ¹ýʧ£º
Îļþϵͳ¹ýʧ¿ÉÄܵ¼ÖÂÎļþ¶ÁдÒì³£¡¢ÏµÍ³Æô¶¯Ê§°ÜµÈÎÊÌâ¡£¿ÉÒÔͨ¹ý¼ì²éÎļþϵͳ²¢ÐÞ¸´¹ýʧÀ´½â¾öÎÊÌâ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²éºÍÐÞ¸´Îļþϵͳ£º
fsck /dev/sda1 # ¼ì²é²¢ÐÞ¸´/dev/sda1Îļþϵͳ
µÇ¼ºó¸´ÖÆ
ËÄ¡¢×ܽá
÷è÷ë²Ù×÷ϵͳ×÷Ϊһ¿îÎȹ̿ɿ¿µÄ²Ù×÷ϵͳ£¬ÔÚϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´·½ÃæÌṩÁ˶àÖÖ¹¤¾ßºÍÒªÁ졣ͨ¹ýÉó²éϵͳÈÕÖ¾¡¢¼ì²éÀú³Ì״̬¡¢Éó²éϵͳ¸ºÔغÍÍøÂçÅþÁ¬µÈ»ù±¾ÅŲéÒªÁ죬¿ÉÒÔÆðÔ´ÕÒµ½¹ÊÕϵÄÔµ¹ÊÔÓÉ¡£Í¬Ê±£¬½èÖútopÏÂÁî¡¢dmesgÏÂÁî¡¢lsofÏÂÁîºÍstraceÏÂÁîµÈ³£ÓùÊÕÏÅŲ鹤¾ß£¬¿ÉÒÔ¸üÉîÈëµØÆÊÎöÏ¢Õù¾öϵͳ¹ÊÕÏ¡£Í¬Ê±£¬Æ¾Ö¤Ïêϸ¹ÊÕÏ°¸Àý£¬½ÓÄÉÏìÓ¦µÄÐÞ¸´ÒªÁ죬ÈçÐÞ¸´Ö¸µ¼¡¢ÖÕÖ¹Òì³£Àú³ÌºÍÐÞ¸´ÎļþϵͳµÈ¡£Í¨¹ýÕÆÎÕÕâЩÅŲéºÍÐÞ¸´ÒªÁ죬¿ÉÒÔÌá¸ß÷è÷ë²Ù×÷ϵͳµÄÎȹÌÐÔºÍÐÔÄÜ£¬ÎªÓû§Ìṩ¸üºÃµÄʹÓÃÌåÑé¡£
£¨ÎÄÕÂ×ÖÊý£º938×Ö£©
ÒÔÉϾÍÊÇÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡