是否有任何推荐的方法来处理日益增长的日志文件。我的日志文件是41 gig,主数据文件是77 gig。我只发现删除旧数据的清除任务之一已经失败超过2个月。
如何将日志文件的大小减少到正常状态?
答案 0 :(得分:1)
这是因为尚未到达有效的检查点。您的备份策略取决于几个因素,但是您无法收缩的大型日志文件的原因是数据库必须处于一致状态。
尚未告知它何时可以清理日志文件,因此请将您的大型日志文件视为尚未完全提交到磁盘的潜在更改。
Log File: Factors that delay log transaction - Docs.Microsoft.com
您也可以从文档中查看Manage the Size of the Transaction Log File。
答案 1 :(得分:-1)
我缩小了日志文件并且工作正常。请参阅我在下面使用的代码:
/* Use the database */
USE [GiantLogs]
GO
/* Check the name and size of the transaction log file*/
/* The log is fileid=2, and usage says "log only" */
/* Bonus: make sure you do NOT have more than one log file, that does not help performance */
exec sp_helpfile;
GO
/* Shrink the log file */
/* The file size is stated in megabytes*/
DBCC SHRINKFILE (GiantLogs_log, 2048);
GO
/* Check if it worked. It won't always do what you want if the database is active */
/* You may need to wait for a log backup or more activity to get the log to shrink */
exec sp_helpfile;
GO