尊龙凯时人生就是博

ÔõÑùʵÏÖNginxµÄÈÕÖ¾ÇиîÉèÖÃ

ÔõÑùʵÏÖNginxµÄÈÕÖ¾ÇиîÉèÖà £¬ÐèÒªÏêϸ´úÂëʾÀý

NginxÊÇÒ»¿îºÜÊÇÊܽӴýµÄ¸ßÐÔÄÜWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬ÆÕ±éÓÃÓÚ¹¹½¨ºÍÔËÐÐÏÖ´úÓ¦ÓóÌÐò¡£×÷ΪһÃûÔËά¹¤³Ìʦ £¬ÎÒÃǾ­³£ÐèÒªÉèÖÃNginxЧÀÍÆ÷µÄÈÕÖ¾ÇиЧ £¬ÒÔ±ã¶ÔЧÀÍÆ÷µÄÈÕÖ¾¾ÙÐа´ÆÚÇиî £¬±ÜÃâÈÕÖ¾Îļþ¹ý´óÓ°ÏìЧÀÍÆ÷µÄÐÔÄÜ¡£ÏÂÃ潫ÏÈÈÝÔõÑùʵÏÖNginxµÄÈÕÖ¾ÇиîÉèÖà £¬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£

Ò»¡¢ÎªÊ²Ã´ÐèÒªÉèÖÃÈÕÖ¾Çиî

NginxЧÀÍÆ÷ĬÈϽ«ËùÓеĻá¼ûÈÕÖ¾ºÍ¹ýʧÈÕ־дÈëͳһ¸öÎļþÖÐ £¬Ëæ×Å»á¼ûÁ¿µÄÔöÌí £¬ÈÕÖ¾Îļþ»áÖð½¥±äµÃÖØ´ó £¬²»µ«Õ¼Óôó×ڵĴÅÅÌ¿Õ¼ä £¬²¢ÇÒÔÚ²éÕÒÌض¨µÄÈÕÖ¾ÐÅϢʱЧÂÊÒ²»á½µµÍ¡£ÎªÏàʶ¾öÕâ¸öÎÊÌâ £¬ÎÒÃÇÐèÒª¶ÔNginxµÄÈÕÖ¾¾ÙÐа´ÆÚµÄÇиî £¬½«ÈÕÖ¾Îļþƾ֤һ¶¨µÄ¾Þϸ»òʱ¼ä¾àÀë¾ÙÐÐÇиî £¬²¢½«¾ÉµÄÈÕÖ¾Îļþ¾ÙÐй鵵»òɾ³ý £¬´Ó¶ø¼á³ÖЧÀÍÆ÷µÄÐÔÄܺͿÉÖÎÀíÐÔ¡£

¶þ¡¢ÔõÑùÉèÖÃNginxµÄÈÕÖ¾Çиî

×°ÖÃlogrotate¹¤¾ß

logrotateÊÇÒ»¿î³£ÓõÄÈÕÖ¾Çи¾ß £¬¿ÉÒÔÓÃÓÚ¶ÔÖÖÖÖÈÕÖ¾Îļþ¾ÙÐÐ×Ô¶¯Çи¹éµµºÍɾ³ý¡£Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃlogrotate¹¤¾ß¡£ÈôÊÇÄãµÄЧÀÍÆ÷ʹÓõÄÊÇDebian/Ubuntuϵͳ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt-get install logrotate

µÇ¼ºó¸´ÖÆ

ÈôÊÇÄãµÄЧÀÍÆ÷ʹÓõÄÊÇCentOS/RHELϵͳ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo yum install logrotate

µÇ¼ºó¸´ÖÆ

½¨ÉèÈÕÖ¾ÇиîÉèÖÃÎļþ

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öNginxÈÕÖ¾ÇиîµÄÉèÖÃÎļþ £¬ÒÔ½ç˵Çиî¹æÔòºÍÒªÖ´ÐеIJÙ×÷¡£Í¨³£ÇéÐÎÏ £¬NginxµÄÈÕÖ¾ÎļþλÓÚ/var/log/nginx/Ŀ¼Ï £¬ÎÒÃÇ¿ÉÒÔÔÚ¸ÃĿ¼Ï½¨ÉèÒ»¸öÃûΪnginx.logrotateµÄÎļþ £¬²¢±à¼­ÈçÏÂÉèÖãº

/var/log/nginx/*.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
    create 0644 nginx nginx
    sharedscripts
    postrotate
        /usr/sbin/nginx -s reopen
    endscript
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÖÐ £¬¸÷¸ö²ÎÊýµÄ¼ÄÒåÈçÏ£º

daily£ºÆ¾Ö¤ÌìÌìµÄʱ¼ä¾àÀë¾ÙÐÐÇи

missingok£ºÈôÊÇÈÕÖ¾Îļþ²»±£´æ £¬Ôò²»±¨´í£»

rotate 7£º±£´æ×î½ü7¸öÇиîºóµÄÈÕÖ¾Îļþ £¬¾ÉµÄÈÕÖ¾Îļþ»á±»É¾³ý£»

compress£º¶ÔÇиîºóµÄÈÕÖ¾Îļþ¾ÙÐÐѹËõ£»

delaycompress£ºÑÓ³ÙѹËõ £¬¼´ÔÚÏÂÒ»´ÎÇиîʱÔÙ¾ÙÐÐѹËõ£»

notifempty£ºÈôÊÇÇиîºóµÄÈÕÖ¾ÎļþΪ¿Õ £¬Ôò²»Ö´ÐÐÈκβÙ×÷£»

create 0644 nginx nginx£º½¨ÉèеÄÈÕÖ¾Îļþʱ £¬ÉèÖÃȨÏÞΪ0644 £¬ËùÓÐÕߺÍ×éΪnginx£»

sharedscripts£ºÔÚÖ´ÐÐÇиî¾ç±¾Ö®Ç°Ö»Ö´ÐÐÒ»´Î¾ç±¾£»

postrotateºÍendscript£ºÔÚÇиîÍê³ÉºóÖ´Ðеľ籾 £¬½«NginxЧÀÍÖØÊÓз­¿ªÈÕÖ¾Îļþ¡£

²âÊÔÈÕÖ¾ÇиîÉèÖÃ

Íê³ÉÉèÖÃÎļþµÄ±àдºó £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¾ÙÐÐÈÕÖ¾ÇиîµÄ²âÊÔ£º

sudo logrotate -f /etc/logrotate.d/nginx.logrotate

µÇ¼ºó¸´ÖÆ

Ö´ÐÐÉÏÊöÏÂÁîºó £¬logrotate½«»áƾ֤ÉèÖÃÎļþµÄ¹æÔò¶ÔNginxµÄÈÕÖ¾Îļþ¾ÙÐÐÇиî¡£Äã¿ÉÒÔͨ¹ýlsÏÂÁîÉó²é/var/log/nginx/Ŀ¼ÏµÄÈÕÖ¾Îļþ £¬¿´ÊÇ·ñƾ֤¹æÔò¾ÙÐÐÁËÇиîºÍѹËõ¡£

ÉèÖÃlogrotateµÄ׼ʱʹÃü

ΪÁËʵÏÖ×Ô¶¯µÄÈÕÖ¾ÇиЧ £¬ÎÒÃÇÐèÒª½«logrotateµÄÖ´ÐÐʹÃü¼ÓÈ뵽ϵͳµÄ׼ʱʹÃüÖС£¿ÉÒԱ༭/etc/crontabÎļþ £¬Ìí¼ÓÈçÏÂÒ»ÐУº

0 0 * * * root /usr/sbin/logrotate -f /etc/logrotate.d/nginx.logrotate

µÇ¼ºó¸´ÖÆ

ÕâÑù £¬ÌìÌìµÄÎçÒ¹Áãµã£¨0Сʱ £¬0·ÖÖÓ£©Ê± £¬logrotate½«»áÖ´ÐÐÒ»Ô½ÈÕÖ¾Çиî²Ù×÷¡£

×ܽá

ÉèÖÃNginxµÄÈÕÖ¾ÇиЧÊǺÜÊÇÓÐÐëÒªµÄ £¬Ëü¿ÉÒÔ¼á³ÖЧÀÍÆ÷µÄÐÔÄܺͿÉÖÎÀíÐÔ¡£Í¨¹ý×°ÖÃlogrotate¹¤¾ß £¬½¨ÉèÈÕÖ¾ÇиîÉèÖÃÎļþ £¬²¢ÉèÖÃ׼ʱʹÃü £¬¾Í¿ÉÒÔʵÏÖ×Ô¶¯µÄÈÕÖ¾ÇиЧ¡£Ï£Íû±¾ÎÄÌṩµÄÏêϸ´úÂëʾÀýÄܹ»×ÊÖúÄãʵÏÖNginxµÄÈÕÖ¾ÇиîÉèÖá£

ÒÔÉϾÍÊÇÔõÑùʵÏÖNginxµÄÈÕÖ¾ÇиîÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

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

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

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