php app/console doctrine:database:import returns OutOfMemory



我正在尝试通过教义命令导入一个postgresql dmp文件。它会抛出 OutOfMemoryException,尽管在导入之前清理了应用程序/缓存目录。关于我如何解决这个问题的任何想法?

$ rm -rf app/cache/*
$ ll app/cache
total 0
$ php app/console doctrine:database:import zen_prod_20180625091104.dmp -vvv
Processing file '/home/xxxxxx/Documents/Projets/zen2/zen_prod_20180625091104.dmp'... 
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in /home/btraband/Documents/Projets/zen2/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php on line 1098
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in /home/btraband/Documents/Projets/zen2/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php on line 1098

[SymfonyComponentDebugExceptionOutOfMemoryException]                     
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes)                                                                 

Exception trace:
() at /home/xxxxxx/Documents/Projets/zen2/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:1098
doctrine:database:import [--connection [CONNECTION]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <command> <file> (<file>)...
$ ll zen_prod_20180625091104.dmp 
-rw-r--r-- 1 xxxxxx xxxxxx 28M 25 juin  09:11 zen_prod_20180625091104.dmp

在下面找到有关我的配置的一些信息:

$ php app/console --version
Symfony version 2.8.39 - app/dev/debug
$ composer show | grep -i -e doctrine
doctrine/annotations                 v1.6.0  Docblock Annotations Parser
doctrine/cache                       v1.7.1  Caching library offering an ...
doctrine/collections                 v1.5.0  Collections Abstraction library
doctrine/common                      v2.8.1  Common Library for Doctrine ...
doctrine/dbal                        v2.6.3  Database Abstraction Layer
doctrine/doctrine-bundle             1.6.7   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.3.3   Symfony Bundle for Doctrine ...
doctrine/doctrine-migrations-bundle  v1.3.1  Symfony DoctrineMigrationsBu...
doctrine/inflector                   v1.3.0  Common String Manipulations ...
doctrine/instantiator                1.1.0   A small, lightweight utility...
doctrine/lexer                       v1.0.1  Base library for a lexer tha...
doctrine/migrations                  v1.2.2  Database Schema migrations u...
doctrine/orm                         v2.5.14 Object-Relational-Mapper for...
gedmo/doctrine-extensions            v2.4.35 Doctrine2 behavioral extensions
$ psql --version
psql (PostgreSQL) 9.6.9

尝试在 php 中增加memory_limit.ini

您可以尝试增加单个命令的内存大小,例如导入可以使用的非常大的数据库:

php -d memory_limit=10240M bin/console doctrine:database:import import.sql

最新更新