PHP-FPM 并持续“在信号 11 上退出”

PHP-FPM 并持续“在信号 11 上退出”

我有一台 Hp 网络服务器,配备 Xeon E5504 2ghz 和 8gb ram,以及 freebsd 8.2-p9 amd64,nginx 1.2.1PHP 5.3.14、mysql 5.5.25、apc、memcached 和其他使用 freebsd 端口安装的软件包。(该消息末尾的 conf 文件)

我的问题很简单,我在 /var/log/messages 中发现很多“在信号 11 时退出”,并且当 php-fpm 子进程死亡时,我的网站会出现“502 网关错误”,这真的很无聊,因为我一天中会遇到很多这样的错误,在那个 php-fpm 配置中,我强制将其设置为重度配置,其中 150 个 php-fpm 子进程处于静态模式,并且 pm.max_requests = 10000000,但在我的 php-fpm 日志中,我发现每个子进程都有:

[19-Jul-2012 18:58:14.666913] NOTICE: pid 84563, fpm_children_make(), line
421: [pool www] child 84717 started
[19-Jul-2012 18:58:14.666984] DEBUG: pid 84563, fpm_event_loop(), line 409:
event module triggered 1 events
[19-Jul-2012 18:58:17.403217] DEBUG: pid 84563, fpm_event_loop(), line 409:
event module triggered 2 events
[19-Jul-2012 18:58:17.407442] DEBUG: pid 84563, fpm_got_signal(), line 72:
received SIGCHLD
[19-Jul-2012 18:58:17.407552] WARNING: pid 84563, fpm_children_bury(), line
252: [pool www] child 84563 exited on signal 11 (SIGSEGV) after 39.849444
seconds from start

并在 /var/log/message 中针对相同的 pid:

Jul 19 18:58:14 web1 kernel: pid 84563 (php-fpm), uid 1001: exited on signal 11

为了确保这不是配置文件(php.ini 和 php-fpm.conf)的问题,我使用在档案中找到的原始文件恢复了它,但是没有任何效果,然后我尝试使用 spawn-fcgi,但同样的麻烦!

然后我尝试生成一个运行“gdb /usr/local/sbin/php-fpm“,当孩子退出时”信号 11 退出“php-fpm 主进程退出时显示”信号 5 退出(核心转储)“(只有当我运行它时才会抛出 GDB!),这里是日志和 gdb 回溯结果:

正如您在最后一个链接中看到的,这些是最后一行:

#659 0x0000000801534de0 in ?? () from /lib/libc.so.7
#660 0x0000000000000001 in ?? ()
#661 0x00007fffffffec08 in ?? ()
#662 0x000000000000000f in ?? ()
Cannot access memory at address 0x800000000000

有任何想法吗?

谢谢!

/var/log/消息:

Jul 24 17:58:41 web1 kernel: pid 3887 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:42 web1 kernel: pid 3998 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:42 web1 kernel: pid 3895 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:42 web1 kernel: pid 3892 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:43 web1 kernel: pid 3889 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:43 web1 kernel: pid 3898 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:44 web1 kernel: pid 3886 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:44 web1 kernel: pid 3999 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:45 web1 kernel: pid 3896 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:45 web1 kernel: pid 4000 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:45 web1 kernel: pid 3893 (php-fpm), uid 1001: exited on signal 11
Jul 24 17:58:55 web1 kernel: pid 3885 (php-fpm), uid 0: exited on signal 5 (core dumped)

php.ini(与原始文件仅有区别)

[PHP]
memory_limit = 128M

apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.mmap_file_mask=/tmp/apc/apc.XXXXXX

error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
display_errors = On
display_startup_errors = On
track_errors = On
html_errors = On

upload_max_filesize = 4M

[Date]
date.timezone = Europe/Rome

[browscap]
browscap = /home/serverweb/etc/php/browscap.ini

php-fpm.conf(与原始文件仅有区别)

[global]
error_log = /home/serverweb/log/php-fpm/error.log
log_level = debug

emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s

process.max = 0

[www]
user = web
group = web

listen = 127.0.0.1:9999
listen.allowed_clients = 127.0.0.1

pm = static
pm.max_children = 16

pm.max_requests = 10000000

slowlog = /home/serverweb/log/php-fpm/$pool.log.slow

答案1

PHP 5.3.14 具有一个严重的错误这会导致 php-fpm 出现段错误。此问题已在 5.3.15 和 5.4.5 中修复。

答案2

如果在较新版本的 PHP 中仍然出现此问题,请尝试运行:

$ dmesg | grep segfault | tail -10
php-fpm[327]: segfault at 834ac30 ip 000000000834ac30 sp 00007ffc112d1b78 error 14 in libnss_nis-2.23.so[7fe02b461000+b000]
php-fpm[329]: segfault at 834ac30 ip 000000000834ac30 sp 00007ffc112d1b78 error 14
php-fpm[331]: segfault at 834ac30 ip 000000000834ac30 sp 00007ffc112d2278 error 14 in libnss_nis-2.23.so[7fe02b461000+b000]

在行末你可以看到崩溃发生在哪个库中,例如

error 14 in libnss_nis-2.23.so

因此,您可以尝试升级该库,例如按照以下命令:

$ locate libnss_nis-2.23.so
/lib/x86_64-linux-gnu/libnss_nis-2.23.so
$ dpkg -S /lib/x86_64-linux-gnu/libnss_nis-2.23.so

然后根据受影响的库所属情况,尝试升级该库。如果这无济于事,请尝试搜索或报告相关错误。

有关newrelic-X.so,请参阅:PHP 代理段错误


请注意,PHP 5.6 及以下版本不再受支持。请参阅:PHP 支持的版本页面。例如,PHP 5.6 分支支持将持续到 2017 年 1 月 19 日,因此建议将 PHP 升级到最新的稳定分支。

或者,当您无法升级版本时,启用和调查带有回溯列表的核心转储可以为您指明崩溃根源的正确方向。

相关内容