access_log 的buffer设置多大,看官网说是不能超过原子写入磁盘的大小。这个值在Linux里边是没有变量或者环境变量来设置的。
The access_log directive sets the path, format and buffer size for the access log file. Using "off" as the only parameter clears allaccess_log directives for the current level. If the format is not indicated, it defaults to"combined". The size of buffer must not exceed the size of the atomic record for writing into the disk file. This size is not limited for FreeBSD 3.0-6.0.
为啥有这个限制呢,看一下其代码
n = ngx_write_fd(file->fd, buffer->start, len);
#endif
if (n == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
ngx_write_fd_n " to \"%s\" failed",
file->name.data);
} else if ((size_t) n != len) {
ngx_log_error(NGX_LOG_ALERT, log, 0,
ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz",
file->name.data, n, len);
}
发现他写不完整不会while里边循环写,直接丢弃和报错了。
这个atomtic write size到底多少,压测试试,设置access_log buffer=4096k, 结果一直写到1G还没有报错。
其它相关信息:
huanglq@hadoop99 conf]$ grep PIPE_BUF /usr/include/linux/limits.h
#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */
PIPE_BUF 是指pipe的buf,而不是文件的,所以不是该值
另外磁盘buf是8Msudo hdparm -i /dev/sda
/dev/sda:
Model=ST3250318AS , FwRev=CC37 , SerialNo= 6VY3FTLF
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=8192kB
再将日志改成8.3M,超过磁盘的buffsize,写了1.5G还是没有报错