Php memory Limit Exceed, while runing Magento 2 Commands - magento

I tried to deploy static content of magento 2 but php memory limit exceed error pops up every time.
Even my cron jobs are not running it giving me the same error in cron.log files.

You can use php -d memory_limit=2G in every command you run as a temporary solution to your problem but for permanent solution you must go for change in your php.ini file max_memory_limit to somewhat according to your requirement for Magento it must be minimum 765MB but you can give 2G for better functionality.

Related

Magento 2 Indexing

We have one Magento 2 project where we configured cron every min. Ideally the site has no change but still all cron jobs running too frequently.
Questions :
How Magento consider to re-run a index even there is no change.
Magento cron running synchronize or parallels way.
How to prevent run indexing if there is no change any lock or anything Magento manage ?
If your indexer is update by schedule.
then only changed data will be reindexed not all.
There is a schedule set for the crons. If you find that the frequency is too short, you can change the frequency of crons in a crontab.xml file.
You need to know the cron's name and its instance.
You can refer following link for configure cron time.
https://amasty.com/blog/configure-magento-cron-job/

Symfony first time slow loading

I have been developing a web page named: directorioelectronico.com and I have specially issues now, I will be very grateful that someone can be help me.
The web page is loading very slow in the first loading (5,000ms - 20,000ms) (latest are speeded normally) I tried to install APC module but my host is shared and the administrator can not install it, so I resize realpath_cache_size to 2M and the performance is now better (4,000 - 16,000 ms) somebody knows how I can perform it much more?
In advance, Thank you very much for you help.
My issue was that my share host haven't APC cache and for symfony2 is mandatory have it for have a good load so I change my host provider and now I have a VPS where I can install APC and now it is very fast.
The first time a Symfony program is run with env=prod, it has to create a significant amount of cached code - parsing the routes, annotations, converting configurations files and preparing CSS and Javascript.
It will always be a lot slower the first time, so that the rest of the time it will be fast. If you can run it before the website goes live (eg, with app/console), then that work can happen offline.
After clear:cache the next call on the application will have to rebuild a number cached files. That can be slow - so why make a site visitor trigger it?
If you're clearing the cache in production, try using the cache:warmup command to pre-build the the cache. It will mean the next visitor won't have to wait while the heavy lifting is done.
Something like this should help:
$ php ./app/console clear:cache --env=prod
$ php ./app/console clear:warmup
More info in the Symfony documentation.
I'd also suggest to enable query and result caches for doctrine (did you install/active apc cache for your php installation?). This might further reduce the loading time. Just have a look here :-)
Also try to use a deployment script to automatically trigger the cache clear/warmup, mentioned above. This way you won't forget to call those.
Do you use assetic for css/js? Then combine those files, minify them via assetic filters
Good candidates for deployment scripts are ansible, capifony or just a simple shell script.

how to set cron job for reindex

How to setup cron job for clear cache and re-indexing in Magento. i don't know how to set the cron for re-index. but i saw some where every day cron runs defaultly in magento. still i am facing re indexing issues in my site. i need to clear cache also.On Magento website here
they said that logcleaning and reindexing is commented out in the code so in which file I can un-comment to setup cron job fo log cleaning and reindexing?
thanks,
murali.
To create the cron job, add the following to your cron file to reindex every day at 6am
0 6 * * * php -f /shell/indexer.php reindexall
Note: If you get an error telling you you’re out of memory similar to:
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 7680 bytes) in …/app/code/core/Mage/Index/Model/Indexer.php on line 163
Try commenting out php_value memory_limit and php_value max_execution_time in your .htaccess file.
I have tested my solution in my cPanel 11.52.2.4. So stay calm and do following:
Navigate to your magento2 admin area. And click over System > Index Management.
From the Actions drop down select Update by schedule and click on submit.
That is it from admin section. Now navigate to the cPanel area and do following-
Login to your cPanel
Under cPanel click on Cron Jobs under Advanced tab group
If you have already created a cron job, you can edit it, or create a new cron job.
Select the frequency to run the cron job, suppose Once per week (0 0 * * 0).
Write the command to re-index the data, as
php-cli /home/username/public_html/sub_folder_if_any/bin/magento indexer:reindex
Save it. As per your schedule frequency, the cron job will run.
If you want lesser frequency, but note that if you put less frequency it will consume the resource.
Note: Make sure you replace <username> with your cPanel user name and /<sub_folder_if_any> as per your magento2 installation directory. If you are not using any sub directory just ignore it
We've the same problem and fixed change Megabytes to Bytes.
instead of set memory_limit 1024M we changed to 1073741824.
Looks like an issue at server... We're hosted at Media Temple using Plesk Panel
Hope you sorted it out sooner.
Regards

Magento - Upgrade website 1.4 to 1.6.1.0 issue

I am upgrading an existing magento website for 1.4 to 1.6.1.0.
I had dumped the existing database,
Copied all the required custom extension in the blank magento version 1.6.1.0
and after running the installation got the following error:
Error in file:
"/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php"
- SQLSTATE[HY000]: General error: 1025 Error on rename of './sales_flat_order' to './#sql2-3af-a7' (errno: 152)
How can I fix this issue?
Upgrading magento is very painful process. I suggest you to import-export data from old to new shop.
I just went through the same heartburn. I found that letting the page try to load until the script got an error or timed out and then trying again eventually worked. The upgrade script will attempt to start where it last stopped.
Before you do that, make a backup of you site and database. If it continually errors in the same spot, restore and try again.
These tips may help improve the odds of a quicker success:
Put the site in maintenance mode (by adding the maintenance.flag file
to the root directory) before starting.
Increase server and php timeouts by a very large amount (3-5minutes).
Cleanup temp and log database tables that you don't care about
(carefully, everybody has different needs here)
I tried several different methods and that is the only thing that worked. It took probably 10 reloads (waiting for a 3min timeout each time). In the end, everything upgraded correctly. No matter what method you choose, if you want to keep your store data, you will have to run the bulky db upgrade scripts that take forever.
I had similar issues when updating from 1.4.2 to latest.
I built a custom maintenance script included in my index.php that only allowes to access my ip. But the update process via shell replaced my index.php so it was accessible for everyone.
That was the cause that the final sql scripts where run by several clients and caused errors like "can't move table" etc. because those steps where already done.
--> Summing it up: Be sure that the site gets called only once, until the upgrade was successful!
The very best way to migrate magento in my opinion, is to import your entire db to an environment that you have your new magento. Then magento will run all scripts and updates and keep your data.
Maybe you find some problems on the upgrade scripts, but it's easier to fix them than fix the problems regarding model/eav's problems on the fly.
I have succeed by doing this on migrate from 1.4.1 to 1.8.1.

magento - index management - Cannot initialize the indexer process

I've just moved my Magento site to a new server and I'm trying to re-index my store using the Index Management.
I check all the boxes and re-index and I get the following:
Cannot initialize the indexer process.
I've looked at resetting the file permissions using the Magento Cleanup tool. But nothing I've tried seems to work.
Has anyone ever come across this before and how did they get past this?
Many thanks
I don't have any idea why you can't do it from the Index Management, but as a temporary solution, I would advise to use indexer.php script from the cmd line:
php /var/www/magento/shell/indexer.php reindexall. You can also run it by the system cron periodically, it should do the trick for a while.
delete files from var/locks and change permission of folder to 755, it will work..if donot have any issue with Dataseb files

Resources