简体   繁体   English

SQL SERVER事务日志已满

[英]SQL SERVER Transaction log full

How to free Transaction log space in SQL SERVER 2005: 如何在SQL SERVER 2005中释放事务日志空间:

I have Transaction log size = 70 GB and there four transaction logs 1,2,3,4 in different drives. 我的事务日志大小= 70 GB,并且在不同的驱动器中有四个事务日志1,2,3,4。 Through DBCC SQLPERF(LOGSPACE) I found that the transaction log is Full (uses 100 %) and I want to free up the space in transaction log and I don't want T-log backup. 通过DBCC SQLPERF(LOGSPACE)我发现事务日志是Full(使用100%),我想释放事务日志中的空间,我不想要T-log备份。 I don't have space to backup the transaction log. 我没有空间来备份事务日志。 And my DB is in Replication state. 我的数据库处于复制状态。

  1. How can I free up the Transaction log or 如何释放事务日志或
  2. Instead of 3 transaction log files, can I have only one log file or 而不是3个事务日志文件,我可以只有一个日志文件或
  3. If shrink method what to do with Replication? 如果缩小方法如何处理复制?

Perform the following sequence of statements: 执行以下语句序列:

BACKUP LOG <db_name> WITH TRUNCATE_ONLY  
--or save to log to other drives on disk if required
GO

CHECKPOINT
GO

--replace 2 with your actual log file number.
DBCC SHRINKFILE (2, 100)     

If the log does not shrink then check the reason of log file growth. 如果日志没有缩小,请检查日志文件增长的原因。 More information about this can be found here: 有关这方面的更多信息,请访问:

http://sqlreality.com/blog/ms-sql-server-2008/troubleshooting-the-full-transaction-log-problem/ http://sqlreality.com/blog/ms-sql-server-2008/troubleshooting-the-full-transaction-log-problem/

Check the following article from Microsoft. 请查看Microsoft的以下文章。

http://msdn.microsoft.com/en-us/library/ms175495.aspx http://msdn.microsoft.com/en-us/library/ms175495.aspx

and i want to free up the space in Transaction log and I dont want T-log backup 我想释放事务日志中的空间,我不想要T-log备份

MS does not support this. MS不支持此功能。

Transaction log backup IS NEEDED HERE. 此处需要事务日志备份。 Get a drive, do it. 得到一个驱动器,做到这一点。

If you don't do it, you can not free the log. 如果您不这样做,则无法释放日志。

Without freeing the log you can not shrink the files. 在不释放日志的情况下,您无法收缩文件。 Ergo, you need to make a backup, whether you want to or not. 因此,无论您是否愿意,都需要进行备份。

If you don't care about the transaction logs the databases should have been created in simple recovery mode to start with. 如果您不关心事务日志,则应该以简单恢复模式创建数据库以开始。

缩小文件会单独完成你想要的吗?

DBCC SHRINKFILE (N'LogFile', 1)

It was already discussed about the recovery model switch on replicated databases here . 它已经讨论过关于复制数据库的恢复模式开关位置 and you can read some documentation as well on MSDN . 你也可以在MSDN上阅读一些文档

If you don't want to make T-log backups because of space restraints you can put the replicated database in Simple recovery model and try the: 如果由于空间限制而不想进行T-log备份,可以将复制的数据库放在简单恢复模型中并尝试:

Perform a CHECKPOINT. 执行检查点。 The database in the SIMPLE recovery mode clears THE LOG out on each checkpoint. SIMPLE恢复模式下的数据库清除每个检查点上的LOG。

DBCC SHRINKFILE (N'LogFileName', 1) -- shrink the log file to 1 MB 

After that change it back to Full. 之后将其更改为Full。 In order to remove some of your DB's log files you first have to empty the ones meant for removal and then remove them. 为了删除一些数据库的日志文件,首先必须清空要删除的文件,然后将其删除。 Details here . 细节在这里

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

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