ÔõÑùÉèÖÃCentOSϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ
ÔõÑùÉèÖÃcentosϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ
ÔÚCentOSϵͳÖУ¬ÏµÍ³ÈÕÖ¾¹ØÓÚϵͳµÄÔËÐк͹ÊÕÏÅŲéºÜÊÇÖ÷Òª¡£È»¶ø£¬¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ¿ÉÄܻᵼÖÂDZÔÚµÄÇå¾²ÎÊÌ⡣ΪÁË°ü¹ÜϵͳµÄÇå¾²ÐÔ£¬ÎÒÃÇÐèÒªÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃcentosϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
½¨ÉèÈÕÖ¾×é
Ê×ÏÈ£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öרÃŵÄÈÕÖ¾×飬ÓÃÓÚÖÎÀíϵͳÈÕÖ¾ÎļþµÄ»á¼ûȨÏÞ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉèÒ»¸öÃûΪloggersµÄÈÕÖ¾×飺
sudo groupadd loggers
µÇ¼ºó¸´ÖÆ
½¨ÉèÈÕ־Ŀ¼
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÈÕ־Ŀ¼£¬²¢½«ÆäËùÓÐÕßÉèÖÃΪrootÓû§£¬²¢½«×éÉèÖÃΪloggers×飺
sudo mkdir /var/log/custom_logs sudo chown root:loggers /var/log/custom_logs
µÇ¼ºó¸´ÖÆ
ÉèÖÃÎļþȨÏÞ
È»ºó£¬ÎÒÃÇÐèÒªÉèÖÃÎļþȨÏÞ£¬ÒÔÈ·±£Ö»ÓÐrootÓû§ºÍloggers×éµÄ³ÉÔ±¿ÉÒÔ¶ÁÈ¡ºÍдÈëϵͳÈÕÖ¾Îļþ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Íê³É´Ë²Ù×÷£º
sudo chmod 640 /var/log/custom_logs
µÇ¼ºó¸´ÖÆ
Ìí¼ÓÓû§µ½ÈÕÖ¾×é
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½«Ï£ÍûÄܹ»»á¼ûÈÕÖ¾ÎļþµÄÓû§Ìí¼Óµ½loggers×é¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÓû§Ìí¼Óµ½×éÖУº
sudo usermod -a -G loggers username
µÇ¼ºó¸´ÖÆ
Ç뽫”username”Ì滻ΪÄúÏ£ÍûÏÞÖƶÔϵͳÈÕÖ¾»á¼ûµÄÓû§µÄÓû§Ãû¡£
ÉèÖÃSELinuxÉÏÏÂÎÄ
ÈôÊÇÄúµÄϵͳÆôÓÃÁËSELinuxÇå¾²»úÖÆ£¬Ôò»¹ÐèÒªÉèÖÃ׼ȷµÄSELinuxÉÏÏÂÎÄÒÔÔÊÐíÑ¡¶¨µÄÓû§×é»á¼ûÈÕÖ¾Îļþ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Íê³É´Ë²Ù×÷£º
sudo chcon -R -t var_log_t /var/log/custom_logs
µÇ¼ºó¸´ÖÆ
²âÊÔȨÏÞ
×îºó£¬ÎÒÃÇ¿ÉÒÔ²âÊÔËù×öµÄ¸ü¸Ä£¬È·±£Óû§Ö»ÄÜ»á¼ûËûÃDZ»ÊÚȨµÄϵͳÈÕÖ¾Îļþ¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî²âÊÔ»á¼ûȨÏÞ£º
sudo -u username cat /var/log/custom_logs/access.log
µÇ¼ºó¸´ÖÆ
Ç뽫”username”Ì滻ΪÄúÏ£Íû²âÊÔµÄÓû§µÄÓû§Ãû£¬²¢½«”/var/log/custom_logs/access.log”Ì滻ΪÏÖʵµÄÈÕÖ¾Îļþ·¾¶¡£
ÈôÊÇÄúÄܹ»»á¼ûÈÕÖ¾Îļþ£¬ÔòÌåÏÖȨÏÞÉèÖÃÀֳɡ£ÈôÊÇ»á¼û±»¾Ü¾ø£¬Ôò¿ÉÄÜÐèÒªÖØмì²éËù×öµÄ¸ü¸ÄÒÔ¼°ÎļþºÍĿ¼µÄȨÏÞ¡£
×ܽá
ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇÀֳɵØÉèÖÃÁËCentOSϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞ¡£Õ⽫ÓÐÖúÓÚÈ·±£ÏµÍ³ÈÕÖ¾ÎļþµÄÇå¾²ÐÔ£¬²¢ïÔÌDZÔÚµÄΣº¦ÒòËØ¡£ÇëÈ·±£½öÔÊÐíÊÚȨÓû§»á¼ûϵͳÈÕÖ¾Îļþ£¬²¢°´ÆÚÉó²éÈÕÖ¾ÒÔÈ·±£ÏµÍ³µÄÇå¾²ÐÔ¡£
ÒÔÉϾÍÊDZ¾ÎĹØÓÚÔõÑùÉèÖÃcentosϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞµÄÏÈÈÝ£¬Ï£Íû¶ÔÄúÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùÉèÖÃCentOSϵͳÒÔÏÞÖÆÓû§¶ÔϵͳÈÕÖ¾µÄ»á¼ûȨÏÞµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡