网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 休闲娱乐 > 闲话灌水
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

闲话灌水 追逐时尚话题,共度开心时刻,体会生活点滴,分享精彩人生。

Reply
 
Thread Tools Display Modes
  #1   IP: 122.195.220.101
Old 2014-01-16, 04:26 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default Magento运行一段时间后的垃圾文件清理

今天一大早到公司,发现一个运行着的很久没去理会的Magento站出现了读写log日志文件错误的问题。
warning: fopen(log/20120507agent.log) [function.fopen]:fail to open....
warning: fwrite(): supplied argument is not a valid stream....
warning:fclose():supplied argument is not a valid stream....
进入cp,一看,原来是空间超出了。magento本来的话已经是算一个大巨头咯,运行速度迟缓。然后设置运行不当的话,就会造成很多的垃圾文件,严重影响速度。
先解决上面那个问题吧,首先是清空了下var目录下的缓存,然后log目录下的日志文件,由于平时疏忽管理,很少理会这个站点,这边的话就清空了1G多的空间,然后就是数据库咯,从cp面板登录phpmyadmin ,找到数据库,找到表
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_info
log_visitor_online
report_event
将这些表的数据清空,跑了有1个G了,好吧,我承认造成这种局面的问题,完全是由于疏忽造成的,一年多压根也没有说登录网站的空间面板过。这种情况完全也是可以避免发生的。

解决了上述问题,我们要怎么样可以避免呢?有经常登录空间的话,完全可以再早期就发现,避免出现网站打不开的状态。我们可以通过网站的后台设置,让magneto自动的删除一些日志文件,避免空间越用越大。
设置magento自动清空log方法如下。
1) 登录你的magento后台进入 System -> Configuration
2) 在左栏进入 Advanced -> System
3) 打开 Log Cleaning
4) 设置 “save log, days” 到一个数值, 这个的单位是天,我觉得几天清空一次就好了
5) 设置激活自动清空log设置
如下图为设置每天自动清空我的magento数据库log。这里清理的时间段还是比较少人访问的时候,可以节省服务器的开销,然后是可以避免前台在线客户的一些数据产生异常。

图1 中表示的意思,log保存时间为:7天,开启自动清理缓存:是,清理开始时间:0时,清理的频率:一周

这样就可以避免空间浪费和提高了那么点运行速度了。




==============================================================
随着网站访问量的增加,Magento数据库也越来越大了,甚至有几十个G,直接后果:1.影响网站和数据库性能;2.备份/恢复数据库花费的时间增加了;3.占用磁盘空间。
Magento数据库迅速膨胀,主要是由于一些日志数据的剧增,可以通过Magento自身的cron定时清理日志。另外一种又快又好的办法是执行SQL清理,如下:
truncate dataflow_batch_export;
truncate dataflow_batch_import;
truncate log_customer;
truncate log_quote;
truncate log_summary;
truncate log_summary_type;

truncate log_url;
truncate log_url_info;
truncate log_visitor;
truncate log_visitor_info;
truncate log_visitor_online;

truncate report_viewed_product_index;
truncate report_compared_product_index;
truncate report_event;

set foreign_key_checks = 0;
truncate index_process_event;
truncate index_event;
set foreign_key_checks = 1;
Attached Images
File Type: jpg 084909et8dvd9vzx28zp8h.jpg (422 KB, 1 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 06:11 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.