日志-php-fpm慢日志查询

项目用php开发,在生产运行的过程中,应该一段时间监测下php脚本运行状态,哪些php进程速度太慢,有哪些错误日志。
问:如何来查看检测比较慢的php脚本呢?
答:查看php-fpm慢日志。

1.先查找到配置文件存放地址
find / -name php-fpm.conf


vi /usr/servers/php/etc/php-fpm.conf


打开看看你的慢日志是否开启,或者开启的慢日志存放在哪里。
对应的地址都换成你自己的即可。

2.如果没有开启慢日志查询,先开启

默认的 request_slowlog_timeout 是0,php的慢脚本日志是关闭的,因此设置为大于0的n,表示执行时间超过n的脚本将记录进入slowlog里。
然后监测到网站存在问题的时候查看下slowlog即可发现慢脚本,对脚本进行检查处理即可。

request_slowlog_timeout 和 slowlog需要同时设置,
开启request_slowlog_timeout的同时需要开启 slowlog,
慢日志路径需要手动创建

去掉request_slowlog_timeout 、slowlog的前缀分号';'
设置request_slowlog_timeout =1;
:wq    //保存退出创建慢日志目录
mkdir -p /var/logdata/php-fpm/php-fpm-slowlog.log
killall php-fpm/usr/servers/php/sbin/php-fpm //重启php-fpm


3.找到慢日志存放地址





4.观察慢日志信息

tailf /var/logdata/php-fpm/php-fpm-slowlog.log



开启后,如果有脚本执行超过指定的时间,就会在指定的日志文件中写入类似如下的信息:
[19-Dec-2016 16:54:49] [pool www] pid 18575
script_filename = /home/web/htdocs/sandbox_canglong/test/tt.php
[0x0000000003a00dc8] curl_exec() /home/web/htdocs/sandbox_canglong/test/tt.php:2
[0x0000000003a00cd0] exfilter_curl_get() /home/web/htdocs/sandbox_canglong/test/tt.php:6


日志说明:
script_filename 是入口文件
curl_exec() : 说明是执行这个方法的时候超过执行时间的。
exfilter_curl_get() :说明调用curl_exec()的方法是exfilter_curl_get() 。
每行冒号后面的数字是行号。


开启后,在错误日志文件中也有相关记录。如下:
[19-Dec-2016 15:55:37] WARNING: [pool www] child 18575, script '/home/web/htdocs/sandbox_canglong/test/tt.php' (request: "GET /test/tt.php") executing too slow (1.006222 sec), logging
[19-Dec-2016 15:55:37] NOTICE: child 18575 stopped for tracing
[19-Dec-2016 15:55:37] NOTICE: about to trace 18575
[19-Dec-2016 15:55:37] NOTICE: finished trace of 18575

本文地址:http://blog.csdn.net/ty_hf/article/details/55504172

发布了112 篇原创文章 · 获赞 147 · 访问量 97万+
展开阅读全文

php-fpm日志和网站的错误日志,求解读!!错误日志不断增加

06-16

php-fpm日志和网站的错误日志响应时间一一对应,能否看出到底是什么错误?网上搜索的那些配置增加响应时间,增加并发等等配置都试过了,都没用,错误日志还是不断的增加。 php-fpm日志 > [16-Jun-2018 08:09:45] WARNING: [pool www] child 14280 exited on signal 7 (SIGBUS) after 11372.904946 seconds from start [16-Jun-2018 08:09:45] NOTICE: [pool www] child 16012 started [16-Jun-2018 08:13:21] WARNING: [pool www] child 15011 exited on signal 7 (SIGBUS) after 6306.948734 seconds from start [16-Jun-2018 08:13:21] NOTICE: [pool www] child 16042 started [16-Jun-2018 08:13:40] WARNING: [pool www] child 15360 exited on signal 7 (SIGBUS) after 3978.144375 seconds from start [16-Jun-2018 08:13:40] NOTICE: [pool www] child 16046 started [16-Jun-2018 08:15:16] WARNING: [pool www] child 15200 exited on signal 7 (SIGBUS) after 5120.345545 seconds from start [16-Jun-2018 08:15:16] NOTICE: [pool www] child 16056 started [16-Jun-2018 08:16:23] WARNING: [pool www] child 15234 exited on signal 7 (SIGBUS) after 4959.731228 seconds from start [16-Jun-2018 08:16:23] NOTICE: [pool www] child 16067 started [16-Jun-2018 08:16:43] WARNING: [pool www] child 15695 exited on signal 7 (SIGBUS) after 1742.269976 seconds from start [16-Jun-2018 08:16:43] NOTICE: [pool www] child 16070 started 网站的错误日志 > 2018/06/16 08:09:45 [error]21214#0: *4091115 recv() failed (104: Connection reset by peer) while reading response header from upstream 2018/06/16 08:13:21 [error]21214#0: *4092932 recv() failed (104: Connection reset by peer) while reading response header from upstream 2018/06/16 08:13:40 [error]21218#0: *4102425 recv() failed (104: Connection reset by peer) while reading response header from upstream 2018/06/16 08:15:16 [error]21221#0: *4108422 recv() failed (104: Connection reset by peer) while reading response header from upstream 2018/06/16 08:16:23 [error]21221#0: *4109464 recv() failed (104: Connection reset by peer) while reading response header from upstream 2018/06/16 08:16:43 [error]21214#0: *4152318 recv() failed (104: Connection reset by peer) while reading response header from upstream 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览