运维之道 | Nginx日志切割实战

本文介绍了Nginx日志管理的实战经验,包括使用Apache Benchmark进行压力测试,手动和企业级自动日志切割的详细步骤,以及如何设置cron任务定期执行日志切割,确保日志文件的大小管理和方便查询。
摘要由CSDN通过智能技术生成

Nginx日志切割实战

一、Apache Benchmark(ab) 压力测试工具

[root@localhost nginx]# yum install -y httpd-tools
ab压力测试工具的使用
  • 模拟并发请求1次,总共请求10000次
  • 命令模板:
    ab -c 1 -n 10000 待测试网站(建议完整路径)/
1、使用du -sh *命令查看日志文本大小
[root@localhost nginx]# du -sh *
64K     access.log
84K     error.log
2、使用ab压力测试工具扩大日志文本大小
[root@localhost nginx]# ab -c 100 -n 10000 http://192.168.146.133/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.146.133 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.8.1
Server Hostname:        192.168.146.133
Server Port:            80

Document Path:          /
Document Length:        612 bytes

Concurrency Level:      100
Time taken for tests:   1.425 seconds
Complete requests
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值