SQLServer 2005&08镜像导致日志文件LDF过大的问题解决

镜像是一个很好的灾难恢复手段,配置简单,切换快速。网上教如何配置的文章很多,这里介绍下如何处理LDF过大导致磁盘撑爆的情况。

首先要明确的是镜像不能清日志的, 镜像是的工作跟日志是有关联的。常用的.清空日志DUMP TRANSACTION 'db_name' WITH NO_LOG;和截断事务日志BACKUP LOG 'db_name' WITH NO_LOG;都是无效的。

1建立多个日志文件,以免单个日志文件撑爆

2根据日志的增长情况,经常备份日志 BACKUP LOG DB_Name to disk = 'X:\DB_Name_Log.log'

3 收缩日志 DBCC SHRINKFILE (Log_Name),但是这个几乎没用。不过经过备份后,日志文件内部已经截断了,及时备份可以截断活动日志,让日志文件内标内记非活动的虚文件可重复使用.

查询日志的使用情况以及在被那些应用占用

dbcc sqlperf(logspace)

go

Database Name                                                                                                                    Log Size (MB) Log Space Used (%) Status

--------------------------------------------------------------------------------------------------------------

DB_Name      77404.91      9.809758           0

select name, recovery_model_desc, log_reuse_wait,log_reuse_wait_desc from sys.databases

name     recovery_model_desc  log_reuse_wait log_reuse_wait_desc

--------------------------------------------------------------------------------------------------------------

master   SIMPLE                                                       0              NOTHING
tempdb                                                                                                                           SIMPLE                                                       1              CHECKPOINT
model                                                                                                                            FULL                                                         0              NOTHING

msdb                                                                                                                             SIMPLE                                                       1              CHECKPOINT

DB_Name                      FULL                             5              DATABASE_MIRRORING

Backup            FULL                  4              ACTIVE_TRANSACTION

--EOF--

作者:Buro#79xxd出处:http://www.cnblogs.com/buro79xxd/文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

原文:http://www.cnblogs.com/buro79xxd/archive/2011/03/15/1984970.html

你可能感兴趣的:(SQLServer 2005&08镜像导致日志文件LDF过大的问题解决)