zoukankan      html  css  js  c++  java
  • nginx日志缓存open_log_file_cache

    nginx日志缓存,提升磁盘性能

    将多个日志进行积累,达到一定量级后写入到磁盘,可以减少磁盘旋转,从而降低磁盘i/o,提升nginx能效

    语法:

     access_log path 
     access_log [存储路径] [buff=大小] [gzip=压缩级别] [flush=time 刷新时间]
     
    max: 最大字节数量。
    inactive:设置时间 默认是10s
    min_uses:日志写入指定次数后压缩
    valid:设置检查频率,默认60s
    off:禁用缓存
     
    1. 全局定义  log_format 日志格式
     log_format aaa '$remote_addr - $remote_user [$time_local]'
                        '"$request" $status $body_bytes_sent'
                        '"$http_referer" "$http_user_agent"';
    
    2. http server配置 
     access_log /application/nginx/logs/access_81.log aaa buffer=64k flush=1m;
     open_log_file_cache max=1000 inactive=20s valid=1m min_uses=1s;
    
    ##解释:
    buffer=64k   #日志文件缓存在内存中的大小
    flush=1m     #内存中日志存留一分钟
    max=1000     #文件描述符
    inactive=20s  #日志文件在缓存中没有被使用就会被取消   
    valid=1m     #默认 1m 或 60s  两个单位都可以使用
    min_uses=1   #在存活时间内日志被写入几次才会记录到缓存
    
    3. 重启nginx
    

    官方文档:

    http://nginx.org/en/docs/http/ngx_http_log_module.html#open_log_file_cache

  • 相关阅读:
    2020-03-1811:29:37springboot与任务
    2020-03-17 20:18:50springboot整合rabbitmq
    2020.03.17 springboot缓存相关
    前端JS面试
    npm 常用指令
    ES8新特性
    ES7新特性
    ES6新特性
    SpringBoot
    SpringBoot
  • 原文地址:https://www.cnblogs.com/superlinux/p/12720151.html
Copyright © 2011-2022 走看看