CentOSÉϴwebЧÀÍÆ÷Ðè×¢ÖصĴÅÅÌ¿Õ¼äÖÎÀí
centosÉϴwebЧÀÍÆ÷Ðè×¢ÖصĴÅÅÌ¿Õ¼äÖÎÀí
ÔڴwebЧÀÍÆ÷µÄÀú³ÌÖУ¬´ÅÅÌ¿Õ¼äÖÎÀíÊÇÒ»¸öÖ÷ÒªµÄ·½Ã棬ËüÖ±½ÓÓ°Ï쵽ЧÀÍÆ÷µÄÐÔÄܺÍÎȹÌÐÔ¡£±¾ÎĽ«ÌÖÂÛһЩÔÚCentOSϵͳÉϴwebЧÀÍÆ÷ʱÐèҪעÖصĴÅÅÌ¿Õ¼äÖÎÀíÕ½ÂÔ£¬²¢ÌṩһЩ´úÂëʾÀýÀ´ËµÃ÷¡£
·ÖÅÉÊʵ±µÄ´ÅÅÌ¿Õ¼ä
ÔÚÑ¡ÔñЧÀÍÆ÷µÄ´ÅÅ̾ÞϸºÍ·ÖÇø¼Æ»®Ê±£¬ÐèҪ˼Á¿µ½Ô¤¼ÆµÄÍøÕ¾»á¼ûÁ¿¡¢Êý¾Ý´æ´¢ÐèÇóºÍÔ¤ËãÏÞÖÆ¡£Ò»Ñùƽ³£À´Ëµ£¬ÖÁÉÙÓ¦°ü¹ÜÓÐ×ã¹»µÄ¿ÉÓôÅÅÌ¿Õ¼äÀ´´æ´¢ÍøÕ¾µÄ¾²Ì¬×ÊÔ´¡¢Êý¾Ý¿âÎļþºÍÈÕÖ¾ÎļþµÈ¡£
ÒÔÏÂÊÇÒ»¸öʾÀýµÄ´ÅÅÌ·ÖÇø¼Æ»®£º
/boot£º 200MB
/£º 20GB
/var£º 30GB
/usr£º 20GB
/home£º Ê£Óà¿ÉÓÿռä
°´ÆÚÕûÀíÎÞÓõÄÎļþ
ÔÚwebЧÀÍÆ÷ÉÏ£¬»á±¬·¢´ó×ÚµÄÔÝʱÎļþ¡¢ÈÕÖ¾Îļþ»ººÍ´æÎļþµÈ¡£°´ÆÚÕûÀíÕâЩÎÞÓõÄÎļþ£¬¿ÉÒÔÊÍ·Å´ÅÅ̿ռ䲢Ìá¸ßЧÀÍÆ÷µÄÐÔÄÜ¡£
ÏÂÃæÊÇÒ»¸öʾÀýµÄ°´ÆÚÕûÀí¾ç±¾£º
#!/bin/bash # ÕûÀíApacheÈÕÖ¾Îļþ rm -rf /var/log/httpd/* # ÕûÀíNginxÈÕÖ¾Îļþ rm -rf /var/log/nginx/* # ÕûÀíϵͳÈÕÖ¾Îļþ rm -rf /var/log/messages rm -rf /var/log/secure # ÕûÀíÔÝʱÎļþ rm -rf /tmp/* # ÕûÀíMySQLÈÕÖ¾Îļþ rm -rf /var/log/mysql/*
µÇ¼ºó¸´ÖÆ
¿ÉÒÔ½«ÉÏÊö¾ç±¾ÉúÑÄΪclean.sh£¬²¢Ê¹ÓÃcron׼ʱִÐУ¬ÀýÈçÌìÌìµÄÆÆÏþ£º
00 00 * * * root /path/to/clean.sh
µÇ¼ºó¸´ÖÆ
ʹÓôÅÅÌÅä¶î
ΪÁ˱ÜÃâij¸öÓû§»òij¸öÍøÕ¾Õ¼Óùý¶àµÄ´ÅÅ̿ռ䣬¿ÉÒÔʹÓôÅÅÌÅä¶îÀ´ÏÞÖÆÿ¸öÓû§»òÿ¸öÍøÕ¾µÄʹÓÿռ䡣
ÒÔÏÂÊÇÒ»¸öʾÀýµÄ´ÅÅÌÅä¶îÉèÖãº
# ×°ÖôÅÅÌÅä¶î¹¤¾ß yum install quota -y # ÆôÓôÅÅÌÅä¶î quotacheck -avug # ΪÓû§ÉèÖôÅÅÌÅä¶î edquota -u username # ΪĿ¼ÉèÖôÅÅÌÅä¶î edquota -g groupname
µÇ¼ºó¸´ÖÆ
¼à¿Ø´ÅÅÌ¿Õ¼äʹÓÃÇéÐÎ
ΪÁËʵʱ·¢Ã÷´ÅÅÌ¿Õ¼äʹÓÃÁ¿¹ý¸ßµÄÇéÐΣ¬¿ÉÒÔʹÓüà¿Ø¹¤¾ßÀ´°´ÆÚ¼ì²é´ÅÅÌ¿Õ¼äʹÓÃÇéÐΣ¬²¢·¢Ë;¯±¨¡£
ÒÔÏÂÊÇÒ»¸öʾÀýµÄ´ÅÅÌ¿Õ¼ä¼à¿Ø¾ç±¾£º
#!/bin/bash # »ñÈ¡´ÅÅÌ¿Õ¼äʹÓÃÂÊ usage=$(df -h | grep /dev/sda1 | awk '{print $5}' | sed 's/%//') # ½ÏÁ¿Ê¹ÓÃÂÊÊÇ·ñÁè¼Ý90% if [ $usage -gt 90 ]; then # ·¢Ë;¯±¨Óʼþ echo "´ÅÅÌ¿Õ¼äʹÓÃÂÊÒÑÁè¼Ý90%£¬ÇëʵʱÕûÀí´ÅÅ̿ռ䣡" | mail -s "´ÅÅ̿ռ侯±¨" admin@example.com fi
µÇ¼ºó¸´ÖÆ
¿ÉÒÔ½«ÉÏÊö¾ç±¾ÉúÑÄΪmonitor.sh£¬²¢Ê¹ÓÃcron׼ʱִÐУ¬ÀýÈçÿСʱ£º
0 * * * * root /path/to/monitor.sh
µÇ¼ºó¸´ÖÆ
´ÅÅÌ¿Õ¼äÖÎÀí¹ØÓÚwebЧÀÍÆ÷µÄÎȹÌÐÔºÍÐÔÄÜÖÁ¹ØÖ÷Òª¡£Í¨¹ýºÏÀí·ÖÅÉ´ÅÅ̿ռ䡢°´ÆÚÕûÀíÎÞÓÃÎļþ¡¢Ê¹ÓôÅÅÌÅä¶î²¢¼à¿Ø´ÅÅÌ¿Õ¼äʹÓÃÇéÐΣ¬¿ÉÒÔÓÐÓõØÖÎÀí´ÅÅ̿ռ䣬Ìá¸ßЧÀÍÆ÷µÄÔËÐÐЧÂÊ¡£ÒÔÉÏÌṩÁËһЩÔÚCentOSϵͳÉϴwebЧÀÍÆ÷ʱÐèҪעÖصĴÅÅÌ¿Õ¼äÖÎÀíÕ½ÂÔ£¬²¢ÌṩÁËÏìÓ¦µÄ´úÂëʾÀý¹©²Î¿¼¡£
ÒÔÉϾÍÊÇCentOSÉϴwebЧÀÍÆ÷Ðè×¢ÖصĴÅÅÌ¿Õ¼äÖÎÀíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡