The online nginx log does not cause the curse of cutting

Source: Internet
Author: User
Tags nginx reverse proxy

Condition: Nginx Reverse proxy Server in LNMP environment, some websites cannot access, restart server ok

After getting permission to install Zabbix monitoring, load OK,

IO Alarms:

Disk I/O is overloaded on xss152

Use the command tool to view the status of Io, top down 78%wa ....... .....

[[email protected] /]#  iostat -x 1 10 avg-cpu:  %user    %nice %system %iowait  %steal   %idle            0.27    0.00    0.59    21.81    0.00   77.33Device:          rrqm/s   wrqm/s     r/s      w/s   rsec/s   wsec/s avgrq-sz avgqu-sz    await  svctm  %utilsda                9.58   152.95  128.06   63.60   1136.57  1732.58    14.97    12.19   63.58    4.44  85.00dm-0              0.00      0.00  137.10  216.57  1130.05  1732.58      8.09    25.40   71.82   2.40   84.99dm-1              0.00      0.00    0.08    0.00      0.65     0.00     7.67     0.00     2.45   2.23   0.02dm-2               0.00     0.00     0.06    0.00     0.51     0.00      8.00     0.00    2.65   2.39   0.02 

The%util has long been up to 99% ......

View the status of the server itself, found in the Nginx log directory, logs without cutting, accumulated year-round has reached a terrible size

-rw-r--r--1 Nobody root 4959870331 May 11:38 access.log.1[[email protected] logs]# du-sh37g

So, write the Nginx log cut first, and then force the execution once.

[Email protected] logrotate.d]# vim/etc/logrotate.d/nginx/usr/local/nginx/logs/*log{daily rotate 7 compress Notifempty nocompress postrotate/bin/kill-usr1 ' cat/usr/local/nginx/logs/nginx.pid ' 2>/dev/null | | Trueendscript}

Enforce once, and then view the IO situation.

logrotate -f /etc/logrotate.d/nginx[email protected] logrotate.d]#  iostat  -x 1 10 avg-cpu:  %user   %nice %system %iowait  % steal   %idle           0.27     0.00    0.58   20.70    0.00    78.45avg-cpu:  %user   %nice %system %iowait  %steal    %idle           0.25     0.00    0.75    0.00    0.00    99.00Device:         rrqm/s   wrqm/s      r/s     w/s   rsec/s   wsec/s  avgrq-sz avgqu-sz   await  svctm  %utilsda                0.00     3.00    0.00     2.00     0.00    40.00     20.00     0.02    9.00   5.00    1.00dm-0              0.00      0.00    0.00    5.00      0.00    40.00     8.00     0.05     9.60   2.00   1.00dm-1               0.00     0.00     0.00    0.00     0.00     0.00      0.00     0.00    0.00   0.00    0.00dm-2              0.00      0.00    0.00    0.00      0.00     0.00     0.00     0.00     0.00   0.00   0.00dm-3               0.00     0.00     0.00    5.00     0.00    40.00      8.00     0.05    9.60    2.00   1.00

Top Down

[Email protected] logrotate.d]# toptop-11:57:35 up 2:20, 3 users, Load average:0.00, 0.00, 0.26tasks:142 Total, 1 running, 141 sleeping, 0 stopped, 0 zombiecpu (s): 0.1%us, 0.3%sy, 0.0%ni, 99.3%id, 0.3%wa, 0.0%hi, 0.1%si, 0. 0%stmem:3917212k Total, 3762456k used, 154756k free, 2144812k buffersswap:8388600k total, 0k used, 838860 0k free, 774492k cached

0.3%wa Zabbix Alarm is lifted. It's done!!



The server was built in 2014, the previous administrator wrote the nginx cutting script, but no later due to the Nginx site additions, not added to the script, causing Nginx log has not been cut.

This article is from the "bottom 20,000" blog, please be sure to keep this source http://huwei555.blog.51cto.com/1347480/1774673

The online nginx log does not cause the curse of cutting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.