PHP failed to ptrace(PEEKDATA) pid 1918: Input/output error (5)或者 increase pm.st
今天网站出现负载很大,cpu占用率超高,网站延迟很大,前台出现此错误信息:
[19-Sep-201623:30:38]WARNING:[poolwww]child31954,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.407095sec),logging[19-Sep-201623:30:38]WARNING:[poolwww]child31943,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.062648sec),logging[19-Sep-201623:30:38]WARNING:[poolwww]child31941,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.666022sec),logging[19-Sep-201623:30:38]WARNING:[poolwww]child30382,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.021010sec),logging[19-Sep-201623:30:38]WARNING:[poolwww]child29797,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.554333sec),logging[19-Sep-201623:39:27]WARNING:[poolwww]seemsbusy(youmayneedtoincreasepm.start_servers,orpm.min/max_spare_servers),spawning8children,thereare2idle,and68totalchildren[19-Sep-201623:40:58]WARNING:[poolwww]seemsbusy(youmayneedtoincreasepm.start_servers,orpm.min/max_spare_servers),spawning8children,thereare0idle,and81totalchildren[19-Sep-201623:40:59]WARNING:[poolwww]seemsbusy(youmayneedtoincreasepm.start_servers,orpm.min/max_spare_servers),spawning16children,thereare3idle,and86totalchildren[19-Sep-201623:41:00]WARNING:[poolwww]seemsbusy(youmayneedtoincreasepm.start_servers,orpm.min/max_spare_servers),spawning32children,thereare2idle,and88totalchildren[19-Sep-201623:41:01]WARNING:[poolwww]seemsbusy(youmayneedtoincreasepm.start_servers,orpm.min/max_spare_servers),spawning32children,thereare0idle,and91totalchildren
从信息看,应该是php进程较少:
经过查看发现进程确实很少,解决如下:
修改配置文件增加进程
vim/usr/local/php/etc/php-fpm.inipm=dynamic#动态模式pm.max_children=512#静态开启的进程数pm.start_servers=128#动态模式的起始进程数pm.min_spare_servers=128#动态模式最小进程数pm.max_spare_servers=512#动态模式最大进程数
数值设置,参考自己的实际硬件配置,可以参考 内存/20M 来计算。
重新加载进程
/etc/init.d/php-fpmreload
等待了一点时间发现又报错:
[19-Sep-201623:30:20]WARNING:[poolwww]child7782,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.224150sec),logging[19-Sep-201623:30:08]ERROR:failedtoptrace(PEEKDATA)pid7663:Input/outputerror(5)[19-Sep-201623:30:20]WARNING:[poolwww]child31952,script'/var/www/html/casino.21pink.com/public/index.php'(request:"POST/index.php")executingtooslow(2.045803sec),logging[19-Sep-201623:30:20]ERROR:failedtoptrace(PEEKDATA)pid31952:Input/outputerror(5)
查找资料如下:
It usrears you have request_slowlog_timeout enabled. This normally takes any request longer than N seconds, logs that it was taking a long time, then logs a stack trace of the script so you can see what it was doing that was taking so long.
In your case, the stack trace (to determine what the script is doing) is failing. If you're running out of processes, it is because either:
After php-fpm stops the process to trace it, the process fails to resume because of the error tracing it
The process is resuming but continues to run forever.
My first guess would be to disable request_slowlog_timeout. Since it's not working right, it may be doing more harm than good. If this doesn't fix the issue of running out of processes, then set the php.ini max_execution_time to something that will kill the script for sure.
大概说是设置了slowlog和php的最大执行时间。
解决:
禁止slowlog
vimphp-fpm.conf;request_slowlog_timeout=10s;slowlog=/usr/local/log/php-fpm/ckl-slow.log
修改最大执行时间:
vimphp.inimax_execution_time=60
重启进程:
/etc/init.d/php-fpmreload
等待一段时间,发现一切正常。
查看TCP连接相关:
[root@GreenZonewebapp2php-fpm.d]#ss-sTotal:323(kernel675)TCP:4538(estab12,closed4518,orphaned0,synrecv0,timewait4518/0),ports0TransportTotalIPIPv6*675--RAW000UDP541TCP20191INET25232FRAG000
同时发现系统TIMEWAIT 较多,所以优化了一些内核相关参数
#vim/etc/sysctl.conf进行内核的相关优化#sysct-pbash:sysct:commandnotfound[root@sapietc]#sysctl-pnet.ipv4.ip_forward=0net.ipv4.conf.default.rp_filter=1net.ipv4.conf.default.accept_source_route=0net.ipv4.tcp_max_tw_buckets=6000net.ipv4.ip_local_port_range=102465000net.ipv4.tcp_tw_recycle=1net.ipv4.tcp_tw_reuse=1net.ipv4.tcp_syncookies=1net.ipv4.tcp_max_orphans=262144net.ipv4.tcp_keepalive_time=1200net.ipv4.tcp_keepalive_intvl=30net.ipv4.tcp_keepalive_probes=3net.ipv4.tcp_synack_retries=1net.ipv4.tcp_syn_retries=2net.ipv4.tcp_max_orphans=262144net.ipv4.tcp_max_syn_backlog=262144net.ipv4.tcp_timestamps=0net.core.rmem_max=16777216net.core.wmem_max=16777216net.ipv4.tcp_rmem=4096873804194304net.ipv4.tcp_wmem=4096163844194304net.core.wmem_default=8388608net.core.rmem_default=8388608net.core.rmem_max=16777216net.core.wmem_max=16777216net.core.somaxconn=262144kernel.sysrq=0kernel.core_uses_pid=1kernel.msgmnb=65536kernel.msgmax=65536kernel.shmmax=68719476736kernel.shmall=4294967296vm.swappiness=0fs.file-max=409600
过一阵再查看:
#ss-sTotal:281(kernel362)TCP:520(estab22,closed493,orphaned0,synrecv0,timewait493/0),ports475TransportTotalIPIPv6*362--RAW000UDP110TCP27270INET28280FRAG000
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。