PHP-FPM8.0 致命错误共享内存不足!

PHP-FPM8.0 致命错误共享内存不足!

我在 VBox6.1 和 Ubnutu Server 20.04 中运行 LAMP。

原因
今天早上,我删除了我的 vdi(光盘和共享文件夹)的所有附件,然后按照建议使用了vboxmanage--compact的 vdi。(压缩可能是问题的原因,也可能是错误的 php 更新。)

问题
无论如何,在重新连接共享文件夹并重新启动 vdi 后,我看到的是

● php8.0-fpm.service loaded failed failed The PHP 8.0 FastCGI Process Manager
...
Starting The PHP 8.0 FastCGI Process Manager...
php-fpm8.0[5192]: [15-Jan-2023 07:41:57] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'apcu.so' (tried: /usr/lib/php/20200930/apcu.so (/usr/lib/php/20200930/apcu.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/apcu.so.so (/usr/lib/php/20200930/apcu.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-fpm8.0[5192]: [15-Jan-2023 07:41:57] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20200930/redis.so (/usr/lib/php/20200930/redis.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/redis.so.so (/usr/lib/php/20200930/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-fpm8.0[5192]: Sun Jan 15 07:41:57 2023 (5192): Fatal Error Insufficient shared memory!
php8.0-fpm.service: Main process exited, code=exited, status=254/n/a
php8.0-fpm.service: Failed with result 'exit-code'.
ystemd[1]: Failed to start The PHP 8.0 FastCGI Process Manager.
....

故障排除
我发现错误的 php 更新导致 apcu 和 redis 失效,因此我运行:apt install --reinstall php8.0-apcu && apt install --reinstall php8.0-redis这解决了我的问题的两个部分。

但是,我目前遇到这个错误:

● php8.0-fpm.service loaded failed failed The PHP 8.0 FastCGI Process Manager
...
Starting The PHP 8.0 FastCGI Process Manager...
php-fpm8.0[4226]: Sun Jan 15 08:39:51 2023 (4226): Fatal Error Insufficient shared memory!
php8.0-fpm.service: Main process exited, code=exited, status=254/n/a
php8.0-fpm.service: Failed with result 'exit-code'.
Failed to start The PHP 8.0 FastCGI Process Manager.
...

有用的信息

  • php-fpm 的所有其他版本均正常运行
  • 尝试重新安装 php8.0-fpm 结果出现同样的问题
  • 我的共享内存没有限制:
  • # sysctl -a | grep kernel.shm
    kernel.shm_next_id = -1
    kernel.shm_rmid_forced = 0
    kernel.shmall = 18446744073692774399
    kernel.shmmax = 18446744073692774399
    kernel.shmmni = 4096
    
  • 我从 LiveCD 启动并运行e2fsck -cfyv /dev/mapper/vgubuntu-vg(无错误)
  • php8.0 php.ini 确认共享内存配置正确:
    root@test:~# php8.0 -i | grep -i sysvshm
    /etc/php/8.0/cli/conf.d/20-sysvshm.ini,
    sysvshm
    sysvshm support => enabled
    root@test:~# php8.0 -i | grep -i sysvsem
    /etc/php/8.0/cli/conf.d/20-sysvsem.ini,
    sysvsem
    sysvsem support => enabled
    root@test:~# php8.0 -i | grep -i sysvmsg
    /etc/php/8.0/cli/conf.d/20-sysvmsg.ini,
    sysvmsg
    sysvmsg support => enabled
    root@test:~# php8.0 -i | grep -i shmop
    /etc/php/8.0/cli/conf.d/20-shmop.ini,
    shmop
    shmop support => enabled
    

我还考虑过也许另一个应用程序正在消耗所有的共享内存并导致 php8.0-fpm 失败......不是案子:

# ipcs -m --human

------ Shared Memory Segments --------
key        shmid      owner      perms      size       nattch     status      
0x64000630 4          root       600          1.1M     4                     

因此,目前我感到很困惑。

相关内容