创建大的.zip文件时PHP中止 [英] PHP Aborting when creating large .zip file

查看:83
本文介绍了创建大的.zip文件时PHP中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ZipArchive()在CentOS 5.6和PHP 5.2.12上运行的php脚本,成功创建了超过1.6Gb的.zip文件,但没有为2GB或更大的较大存档创建文件-PHP中止,没有明显的错误. PHP错误日志或stderr中没有任何内容.该脚本是在cmd行执行的,而不是交互执行的.

My php script running on CentOS 5.6 and PHP 5.2.12 using ZipArchive() and successfully creates .zip files over 1.6Gb but not for a larger archive of 2GB or larger - PHP aborts with no apparent error. Nothing in the PHP error log or stderr. The script is being executed at the cmd line and not interactively.

该脚本运行了大约8分钟,临时存档增长,并且在检查文件大小时,最后一个清单显示tmp文件的大小为2120011776,然后tmp文件消失了,PHP脚本通过逻辑落入并在执行之后执行了代码存档创建.

The script runs for about 8min and the temp archive grows and while checking the filesize, the last listing showed the tmp file was 2120011776 in size and then the tmp file disappears and the PHP script falls thru the logic and executes the code after the archive create.

出于某种原因,top显示CPU仍处于95%的状态,并且正在创建一个新的tmp存档文件-还要再等5分钟以上,然后静默停止并留下未完成的tmp存档文件.在此测试中-预期文件少于4000个.

For some reason top shows the CPU still at 95% and is creating a new tmp archive file - it does this for say another 5+ min and silently stops and leaves the un-completed tmp archive file. In this test - there was less then 4000 expected files.

上述脚本可以很好地创建较小的存档文件.

The script as noted works just fine creating smaller archive files.

在几组不同的大型源数据上进行了测试-大型文件的结果相同.

Tested on several different sets of large source data - same result for large files.

此问题听起来与以下问题类似: PHP的zipArchive类的大小限制?

This issue sounds similar to this question: Size limit on PHP's zipArchive class?

我认为ls -l命令可能返回2K块的计数,因此2120011776将接近4GB,但该大小以字节为单位-xxxx.zip.tmpxx文件的大小.

I thought maybe the ls -l command was returning a count of 2K blocks and thus 2120011776 would be close to 4GB but that size is in bytes - the size of the xxxx.zip.tmpxx file.

谢谢!

推荐答案

可能有很多事情.我假设您有足够的可用磁盘空间来处理该过程.正如其他人提到的那样,通过编辑php.ini文件或在代码本身中使用ini_set()函数,可能会解决一些问题.

It could be many things. I'm assuming that you have enough free disk space to handle the process. As others have mentioned, there could be some problems fixed either by editing your php.ini file or using the ini_set() function in the code itself.

您的计算机有多少内存?如果它耗尽了您的实际内存,则在一定大小后会定期中止,这是有道理的.因此,请在脚本执行之前检查可用内存使用情况,并在脚本执行时对其进行监视.

How much memory does your machine have? If it exhausts your actual memory, then it makes sense that it would abort regularly after a certain size. So, check the free memory usage before the script and monitor it as the script executes.

第三个选项可能基于文件系统本身.我在CentOS上没有太多经验,但是某些文件系统不允许文件超过2 GB.尽管从产品页面,看来CentOS上的大多数系统都可以处理它.

A third option could be based on the file system itself. I don't have much experience with CentOS, but some file systems do not allow files over 2 gb. Although, from the product page, it seems like most systems on CentOS can handle it.

第四个选项似乎是最有前途的,如果您查看上面链接的产品页面,则会出现另一个可能的罪魁祸首是最大x86每个进程虚拟地址空间",大约为3gb. x86_64约为2tb,因此请检查处理器的类型.

A fourth option, which seems to be the most promising, appears if you look at the product page linked above, another possible culprit is "Maximum x86 per-process virtual address space," which is approximately 3gb. x86_64 is about 2tb, so check the type of processor.

再次,似乎第四个选择是罪魁祸首.

Again, it seems like the fourth option is the culprit.

这篇关于创建大的.zip文件时PHP中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆