Nginx 상용 로그 분할 방법

3626 단어
   :
nginx cronolog        ,      ,       NGINX    。

1.nginx    
 access_log access_log /data/access_log_pipe main;
2.         
mkfifo /www/log/access_log_pipe
3.  cronolog:
nohup cat /data/access_log_pipe | /usr/local/sbin/cronolog /data/log/domain.access_%Y%m%d%H%M.log &
4.  Nginx
/usr/local/nginx/sbin/nginx

  :
cronolog   nginx     
    cronolog  ,     
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
 make
make install
   :

              ,      ,          
log_dir="/var/log/nginx"
date_dir=`date +%Y/%m/%d/%H`
/bin/mkdir -p ${log_dir}/${date_dir} > /dev/null 2>&1
/bin/mv ${log_dir}/access.log   ${log_dir}/${date_dir}/access.log
kill -USR1 `cat /opt/nginx/logs/nginx.pid`

   :
  logrotate nginx    
logrotate               ,        /etc/logrotate.d/ ,        ,      ,    ,      .
vi /etc/logrotate.d/nginx  

    /usr/local/nginx/logs/www.willko.cn.log /usr/local/nginx/logs/nginx_error.log {
    notifempty
    daily
    sharedscripts
    postrotate
    /bin/kill -USR1 `/bin/cat /usr/local/nginx/nginx.pid`
    endscript
    } 

         ,
notifempty            
daily       
postrotate           
  ,        ,  nginx.log.1-n
   :

 Jmeter         ,     :   200,  150,  http  ,  nginx    ,  30000 ,  326 ,    5   ,    :

   2868 access_201112182030.log
   7777 access_201112182031.log
   7626 access_201112182032.log
   7873 access_201112182033.log
   3530 access_201112182034.log
  29674 total

              。

다음으로 전송:https://www.cnblogs.com/duyinqiang/p/5696385.html

좋은 웹페이지 즐겨찾기