×ðÁú¿­Ê±

LinuxÏÂÈÕÖ¾ÆÊÎöÓëÒì³£¼ì²âÒªÁìºÍÕ½ÂÔ

linuxÏÂÈÕÖ¾ÆÊÎöÓëÒì³£¼ì²âÒªÁìºÍÕ½ÂÔ

СÐò£º

Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤ £¬ÖÖÖÖϵͳºÍÓ¦ÓóÌÐòµÄÈÕÖ¾±¬·¢Á¿Ò²Ô½À´Ô½´ó¡£¶Ô´ó×ÚÈÕÖ¾¾ÙÐÐÓÐÓõÄÆÊÎöºÍÒì³£¼ì²â³ÉΪÁË°ü¹ÜϵͳÕý³£ÔËÐк͹ÊÕÏÕï¶ÏµÄÖ÷Òª»·½Ú¡£ÔÚLinux²Ù×÷ϵͳÖÐ £¬ÓÐÐí¶àÓÅÒìµÄÈÕÖ¾ÆÊÎöºÍÒì³£¼ì²â¹¤¾ß £¬±¾ÎĽ«ÏÈÈÝһЩ³£ÓõÄÒªÁìºÍÕ½ÂÔ £¬²¢ÌṩÏà¹Ø´úÂëʾÀý¡£

Ò»¡¢ÈÕÖ¾ÆÊÎöÒªÁìºÍÕ½ÂÔ

ʹÓÃgrepÏÂÁî

grepÊÇLinuxÖзǾ­³£ÓõÄÏÂÁîÐй¤¾ß £¬ÓÃÓÚËÑË÷Ö¸¶¨µÄ×Ö·û´®¡£ÔÚÈÕÖ¾ÆÊÎöÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃgrepÏÂÁîÀ´²éÕÒÌض¨Òªº¦´Ê £¬ÒÔ±ãɸѡ³öÎÒÃǸÐÐËȤµÄÈÕÖ¾ÐÅÏ¢¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÕÒ³ö·ºÆð¹ÊÕϵÄÈÕÖ¾£º

grep “error” logfile

ʹÓÃawkÏÂÁî

awkÊÇÒ»ÖÖÇ¿Ê¢µÄÎı¾´¦Öóͷ£¹¤¾ß £¬ÔÚÈÕÖ¾ÆÊÎöÖпÉÒÔÓÃÀ´ÌáÈ¡ºÍ¹ýÂËÈÕÖ¾ÐÅÏ¢¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Í³¼ÆÈÕÖ¾Öвî±ðÓû§µÄ»á¼û´ÎÊý£º

awk ‘{print $1}’ logfile | sort | uniq -c

ʹÓÃsedÏÂÁî

sedÊÇÒ»ÖÖÁ÷ʽÎı¾±à¼­Æ÷ £¬Ò²¿ÉÒÔÓÃÓÚÈÕÖ¾ÆÊÎö¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´É¾³ýÈÕÖ¾ÖеÄʱ¼ä´Á£º

sed ‘s/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}//g’ logfile

ʹÓÃlogrotate¹¤¾ß

logrotateÊÇLinuxÖÐ×Ô´øµÄÈÕÖ¾ÂÖת¹¤¾ß £¬¿ÉÒÔÓÃÓÚÖÎÀíÈÕÖ¾ÎļþµÄ¾ÞϸºÍÊýÄ¿¡£ÎÒÃÇ¿ÉÒÔÉèÖÃlogrotateʹÆä°´ÆÚ¶ÔÈÕÖ¾Îļþ¾ÙÐÐÂÖת £¬´Ó¶ø¼á³ÖÈÕÖ¾ÎļþµÄ¿É¶ÁÐԺͿÉÖÎÀíÐÔ¡£

¶þ¡¢Òì³£¼ì²âÒªÁìºÍÕ½ÂÔ

»ùÓÚ¹æÔòµÄÒì³£¼ì²â

»ùÓÚ¹æÔòµÄÒì³£¼ì²âÊÇÒ»ÖÖ³£¼ûµÄÒªÁì £¬Í¨¹ý½ç˵һϵÁйæÔòÀ´¼ì²âÈÕÖ¾ÖеÄÒì³£ÇéÐΡ£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔ½ç˵¹æÔò £¬µ±ÈÕÖ¾ÖзºÆðij¸öÒªº¦´Êʱ £¬´¥·¢¾¯±¨¡£¿ÉÒÔʹÓù¤¾ßÈçfail2banÀ´ÊµÏÖ»ùÓÚ¹æÔòµÄÒì³£¼ì²â¡£

»ùÓÚͳ¼ÆµÄÒì³£¼ì²â

»ùÓÚͳ¼ÆµÄÒì³£¼ì²âÊÇʹÓÃͳ¼ÆѧԭÀíÀ´¼ì²âÈÕÖ¾ÖеÄÒì³£ÇéÐΡ£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÅÌËãÈÕÖ¾ÖÐij¸öÊÂÎñµÄƽ¾ùÖµºÍ±ê×¼²î £¬µ±Ä³¸öÊÂÎñµÄÖµÁè¼Ýƽ¾ùÖµ¼ÓÉÏÈý±¶±ê×¼²îʱ £¬¾ÍÅжÏΪÒì³£¡£¿ÉÒÔʹÓù¤¾ßÈçELK£¨Elasticsearch, Logstash, Kibana£©À´¾ÙÐлùÓÚͳ¼ÆµÄÒì³£¼ì²â¡£

»ùÓÚ»úеѧϰµÄÒì³£¼ì²â

»ùÓÚ»úеѧϰµÄÒì³£¼ì²âÊÇʹÓûúеѧϰËã·¨À´ÑµÁ·Ä£×Ó £¬²¢Æ¾Ö¤Ä£×ÓÀ´ÅжÏÈÕÖ¾ÖеÄÒì³£ÇéÐΡ£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓûúеѧϰģ×ÓÀ´Õ¹ÍûÈÕÖ¾ÖпÉÄÜ·ºÆðµÄÒì³£ÊÂÎñ¡£¿ÉÒÔʹÓù¤¾ßÈçTensorFlow¡¢Scikit-learnµÈÀ´¾ÙÐлùÓÚ»úеѧϰµÄÒì³£¼ì²â¡£

´úÂëʾÀý£º

ÒÔÏÂÊÇÒ»¸öʹÓÃgrepÏÂÁîºÍshell¾ç±¾¾ÙÐÐÈÕÖ¾ÆÊÎöµÄ´úÂëʾÀý£º

#!/bin/bash

logfile="access.log"
keyword="error"

grep $keyword $logfile | while read -r line
do
    echo "Found error in line: $line"
done

µÇ¼ºó¸´ÖÆ

ÒÔÉϾ籾»áËÑË÷ÈÕÖ¾ÎļþÖаüÀ¨¹ýʧҪº¦×ÖµÄÐÐ £¬²¢Êä³öÕÒµ½µÄ¹ýʧÐÅÏ¢¡£

½áÂÛ£º

ÈÕÖ¾ÆÊÎöºÍÒì³£¼ì²âÔÚLinuxϵͳÖкÜÊÇÖ÷Òª £¬Äܹ»×ÊÖúÎÒÃÇʵʱ·¢Ã÷ϵͳ¹ÊÕϺÍÒì³£ÇéÐΡ£±¾ÎÄÏÈÈÝÁËһЩ³£ÓõÄÒªÁìºÍÕ½ÂÔ £¬²¢ÌṩÁËÏà¹ØµÄ´úÂëʾÀý¡£Í¨¹ýºÏÀíʹÓÃÕâЩ¹¤¾ßºÍÒªÁì £¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÆÊÎöºÍ¼ì²âÈÕÖ¾ £¬°ü¹ÜϵͳµÄÕý³£ÔËÐС£

ÒÔÉϾÍÊÇLinuxÏÂÈÕÖ¾ÆÊÎöÓëÒì³£¼ì²âÒªÁìºÍÕ½ÂÔµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿