简体   繁体   English

即使更改为完全恢复,事务日志仍保持60GB的大小

[英]Transaction Log remains 60GB size, even after changing to Full Recovery

Just started with a company and noticed that their database was set to Simple Recovery. 刚从一家公司开始,并注意到他们的数据库设置为“简单恢复”。

I talked to the owner and suggested to convert it to Full Recovery, explained to him the benefit of using a transaction log and backed up every hour. 我与所有者交谈,建议将其转换为完全恢复,并向他解释了使用事务日志并每小时进行备份的好处。 After he agreed I did a full DB backup prior to conversion. 在他同意之后,我在转换之前做了完整的数据库备份。 Then scheduled hourly backup for the Transaction log file and Full Nightly backup for the Data File. 然后,计划对事务日志文件进行每小时一次的备份,对数据文件进行每日一次完整的备份。

It was my impression that once the hourly backup started running, the size of the transaction log (60GB) would shrink. 我的印象是,一旦每小时备份开始运行,事务日志的大小(60GB)就会缩小。 It's been more than a month but the size of the transaction log is still the same. 已经有一个多月了,但是事务日志的大小仍然相同。

Is it okay to run DBCC ShrinkDB against the Log file without detaching and attaching the database? 是否可以在不分离和附加数据库的情况下针对日志文件运行DBCC ShrinkDB

I have the impression that once the hourly backup started running the size of the Tlog, 60GB will start to shrink. 我的印象是,一旦每小时备份开始运行Tlog的大小,则60GB将开始减少。 It's been more than a month but the size of the Tlog is still the same. 已经过去了一个多月,但Tlog的大小仍然相同。

Log file will not shrink automatically 日志文件不会自动缩小

Is it okay to run DBCC ShrinkDB against the Tlog 是否可以对Tlog运行DBCC ShrinkDB

Don't shrink log file,unless you are in shortage of space.Reason behind this is, file growth operations are expensive 除非空间不足,否则不要收缩日志文件。原因是文件增长操作非常昂贵

you can see below command to view free space in log file 您可以看到以下命令以查看日志文件中的可用空间

dbcc sqlperf('logspace')

The log backups that you're taking will help to keep the log file from growing, but the log file won't shrink on its own. 您正在执行的日志备份将有助于防止日志文件增长,但是日志文件不会自动收缩。 Internally, the log file is segmented into virtual log files (VLFs) and are used in (more or less) a cyclical manner. 在内部,日志文件被分段为虚拟日志文件(VLF),并且(或多或少)以循环方式使用。 While you're running your work load, transactions are being recorded into these VLFs. 在运行工作负载时,交易记录在这些VLF中。 When the log backup runs, it will read from any VLF that had transactions since the last log backup, write those transactions to disk, and then clear the VLF and mark it as available for reuse. 运行日志备份时,它将从上次日志备份以来读取所有具有事务的VLF,将这些事务写入磁盘,然后清除VLF并将其标记为可重复使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM