2022-10-31 10:53:28 - 米境通跨境电商
随着Magento网站访问量的增加,Magento数据库也越来越大了,甚至有几个G,直接后果:
1.影响网站和数据库性能;
2.备份/恢复数据库花费的时间增加了;
3.占用磁盘空间;
4.出现一些设置产品不显示的问题
Magento数据库迅速膨胀,主要是由于一些日志数据的剧增,可以通过Magento自身的cron定时清理日志。
另外一种又快又好的办法是执行SQL清理(请先备份下数据库,以免出错),如下:
truncatedataflow_batch_export;
truncatedataflow_batch_import;
truncatelog_customer;
truncatelog_quote;
truncatelog_summary;
truncatelog_summary_type;
truncatelog_url;
truncatelog_url_info;
truncatelog_visitor;
truncatelog_visitor_info;
truncatelog_visitor_online;
truncatereport_viewed_product_index;
truncatereport_compared_product_index;
truncatereport_event;
setforeign_key_checks=0;
truncateindex_process_event;
truncateindex_event;
setforeign_key_checks=1;
解决了上述问题,我们要怎么样可以避免数据库日志的增加呢?
我们可以设置magento自动清空log,方法如下:
1)登录你的magento后台进入System->Configuration
2)在左栏进入Advanced->System
3)打开LogCleaning
4)设置“savelog,days”到一个数值,这个的单位是天,我觉得几天清空一次就好了
5)设置激活自动清空log设置
如下图为设置每天自动清空我的magento数据库log。这里清理的时间段还是比较少人访问的时候,可以节省服务器的开销,然后是可以避免前台在线客户的一些数据产生异常。