ÔõÑùʹÓÃLinux¾ÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´
ÔõÑùʹÓÃlinux¾ÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´
µ¼ÓÔÚʹÓÃLinuxϵͳʱ£¬ÎÒÃdz£³£»áÓöµ½ÖÖÖÖ¹ÊÕϺÍÎÊÌâ¡£±¾ÎĽ«ÏÈÈÝһЩ³£¼ûµÄϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´ÒªÁ죬×ÊÖú¶ÁÕ߸üºÃµØ½â¾öÖÖÖÖϵͳÎÊÌâ¡£
Ò»¡¢³£¼ûµÄϵͳ¹ÊÕÏÅŲéÒªÁì
Éó²éϵͳÈÕÖ¾£ºÏµÍ³ÈÕÖ¾ÊǼͼϵͳÔËÐÐÇéÐεÄÖ÷Òª¹¤¾ß£¬Ëü°üÀ¨ÁËÖÖÖÖϵͳÊÂÎñµÄÏêϸÐÅÏ¢¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”sudo tail -f /var/log/messages”À´ÊµÊ±Éó²éϵͳÈÕÖ¾£¬´Ó¶øÏàʶϵͳµÄÔËÐÐ״̬¡£
¼ì²éÀú³Ì״̬£ºÓÐʱϵͳ·ºÆð¹ÊÕÏÊÇÓÉÓÚÀú³Ì¹ÒÆð»òÍß½âÒýÆðµÄ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”top”»ò”htop”À´Éó²éϵͳÖÐÕýÔÚÔËÐеÄÀú³Ì£¬Í¨¹ýÉó²éÀú³ÌµÄCPUÕ¼ÓúÍÄÚ´æʹÓÃÇéÐÎÀ´ÅÅÅÌÎÊÌâ¡£
¼ì²éϵͳ×ÊÔ´£ºÏµÍ³×ÊÔ´µÄʹÓÃÇéÐÎÒ²»áÓ°ÏìϵͳµÄÐÔÄÜ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”free -h”À´Éó²éϵͳµÄÄÚ´æʹÓÃÇéÐΣ¬Ê¹ÓÃÏÂÁî”df -h”À´Éó²éϵͳµÄ´ÅÅÌ¿Õ¼äʹÓÃÇéÐΣ¬²¢Í¨¹ýÑŹۺÍÒ׶ÁµÄÊä³ö£¬ÕÒµ½¿ÉÄܵ¼ÖÂϵͳ¹ÊÕϵÄÔµ¹ÊÔÓÉ¡£
Éó²éÍøÂçÅþÁ¬£ºÍøÂçÎÊÌâÒ²Êdz£¼ûµÄϵͳ¹ÊÕÏÔµ¹ÊÔÓÉÖ®Ò»¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”netstat -nat”À´Éó²éϵͳĿ½ñµÄÍøÂçÅþÁ¬×´Ì¬£¬²¢Í¨¹ýÉó²éÅþÁ¬µÄ»îÔ¾ÐÔºÍIPµØµãÀ´ÅŲéÍøÂç¹ÊÕÏ¡£
¶þ¡¢³£¼ûµÄϵͳ¹ÊÕÏÐÞ¸´ÒªÁì
Ç¿ÖƹرÕÀú³Ì£ºµ±Ò»¸öÀú³ÌÎÞÏìÓ¦»òÕßÒýÆðϵͳ¸ºÔعý¸ßʱ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”kill -9 Àú³ÌID”À´Ç¿ÖƹرոÃÀú³Ì¡£Çë×¢ÖØ£¬ÕâÊÇ×îºóµÄÊֶΣ¬Ó¦¸ÃÈ·±£¹Ø±ÕµÄÀú³ÌûÓÐÖ÷ÒªµÄÊý¾ÝÐèÒªÉúÑÄ¡£
ÖØÆôϵͳ£ºµ±ÏµÍ³·ºÆðÑÏÖعÊÕÏÎÞ·¨½â¾öʱ£¬¿ÉÒÔ˼Á¿ÖØÆôϵͳ¡£Ê¹ÓÃÏÂÁî”sudo reboot”À´ÖØÆôϵͳ¡£ÔÚÖØÆô֮ǰ£¬ÇëÈ·±£ËùÓеÄÖ÷ÒªÊý¾ÝÒѾÉúÑÄ¡£
¼ì²éÎļþϵͳ£ºÓÐʱϵͳ¹ÊÕÏÊÇÓÉÓÚÎļþϵͳ¹ýʧÒýÆðµÄ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”fsck”À´¼ì²éºÍÐÞ¸´Îļþϵͳ¡£ Ïêϸ°ì·¨ÈçÏ£º
a) ʹÓÃÏÂÁî”sudo umount /dev/sdaX”£¨XΪ·ÖÇøºÅ£©À´Ð¶ÔØ´ýÐÞ¸´µÄÎļþϵͳ¡£
b) ʹÓÃÏÂÁî”sudo fsck /dev/sdaX”À´¼ì²éºÍÐÞ¸´Îļþϵͳ¡£Æ¾Ö¤ÆÁÄ»ÉϵÄÌáÐÑ£¬Ñ¡ÔñÏìÓ¦µÄÑ¡Ïî¾ÙÐÐÐÞ¸´¡£
c) ÐÞ¸´Íê³Éºó£¬Ê¹ÓÃÏÂÁî”sudo mount /dev/sdaX”À´ÖØйÒÔØÎļþϵͳ¡£
¸üÐÂϵͳ£ºÓÐʱϵͳ¹ÊÕÏ¿ÉÄÜÊÇÓÉÓÚÈí¼þ°üÓâÆÚ»ò±£´æÎó²îÒýÆðµÄ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁî”sudo apt update”À´¸üÐÂϵͳµÄÈí¼þ°ü£¬Ê¹ÓÃÏÂÁî”sudo apt upgrade”À´Éý¼¶ÏµÍ³¡£Éý¼¶ÏµÍ³»á×°ÖÃ×îеÄÈí¼þ°ü£¬ÐÞ¸´¿ÉÄܱ£´æµÄÎÊÌâ¡£
Èý¡¢Ê¹ÓôúÂëʾÀý¾ÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´
ÒÔÏÂÊÇÒ»¸ö¼òÆӵĴúÂëʾÀý£¬ÓÃÓÚÅŲ鲢ÐÞ¸´ÏµÍ³ÖеÄÀú³ÌÎÊÌ⣺
#!/bin/bash # ¼ì²éϵͳÖеÄÀú³Ì״̬ check_process() { process=$1 if pgrep -x "$process" > /dev/null then echo "Àú³Ì $process ÕýÔÚÔËÐÐ" else echo "Àú³Ì $process δÕÒµ½" echo "ÕýÔÚʵÑéÖØÆô $process ..." start_process "$process" fi } # Æô¶¯Ö¸¶¨Àú³Ì start_process() { process=$1 if sudo service "$process" start then echo "Àú³Ì $process Æô¶¯ÀÖ³É" else echo "Àú³Ì $process Æô¶¯Ê§°Ü" fi } # ¼ì²énginxÀú³Ì check_process "nginx" # ¼ì²éapacheÀú³Ì check_process "apache2"
µÇ¼ºó¸´ÖÆ
ÒÔÉϵĴúÂëʾÀýͨ¹ý¼ì²éÖ¸¶¨Àú³ÌÊÇ·ñÔÚÔËÐУ¬ÈôÊÇδÕÒµ½Àú³Ì£¬ÔòʵÑéÖØÆô¸ÃÀú³Ì¡£¿ÉÒÔƾ֤ÐèÒª¾ÙÐÐÐ޸ĺÍÀ©Õ¹£¬ÓÃÓÚ¼ì²éºÍÐÞ¸´ÆäËûÀú³Ì»òЧÀÍ¡£
×ܽ᣺±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃlinux¾ÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´¡£Í¨¹ýÉó²éϵͳÈÕÖ¾¡¢¼ì²éÀú³Ì״̬¡¢¼ì²éϵͳ×ÊÔ´ºÍÉó²éÍøÂçÅþÁ¬µÈÒªÁ죬¿ÉÒÔÓÐÓõض¨Î»¹ÊÕÏÔµ¹ÊÔÓÉ¡£Í¨¹ýÇ¿ÖƹرÕÀú³Ì¡¢ÖØÆôϵͳ¡¢¼ì²éÎļþϵͳºÍ¸üÐÂϵͳµÈÒªÁ죬¿ÉÒÔ½â¾öÖÖÖÖϵͳ¹ÊÕÏ¡£Í¬Ê±£¬ÎÒÃÇÒ²¸ø³öÁËÒ»¸ö¼òÆӵĴúÂëʾÀý£¬ÒÔ±ã¶ÁÕ߸üºÃµØÃ÷È·ºÍÓ¦ÓÃÕâЩҪÁ졣ϣÍû±¾ÎĶԶÁÕßÔÚLinuxϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´·½ÃæÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃLinux¾ÙÐÐϵͳ¹ÊÕÏÅŲéºÍÐÞ¸´µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡