Truncating logs of mirrored database

Posted by Ashish Kaushal @ http://dbgeek.wordpress.com/2008/08/07/truncating-logs-of-mirrored-database/


Log files of mirrored database grow fast because there is no way to truncate logs of a mirrored database. The only way to truncate the logs is to remove the mirroring (not pause). Truncate the logs then reconfigure the mirror back.

Remove mirror

Right click on database > select Mirror... ("..." three dots means that clicking here will open a window)

Click on "Remove Mirroring" button.

Truncate Logs

Once mirroring is removed. Follow these steps to truncate logs:

1. By backing up the logs we make sure that active logs entries are flushed out on disk)

Backup log [dbname] to disk = 'd:\db.trn'

2. Truncate all the inactive enteries from the log file. because we have flushed the logs in step 1. This step will almost truncate the log file back to its initial size.

Backup log [dbname] with TRUNCATE_ONLY

3. Check the logical name of log file.  Its the "name" field of log file entry usually have fileid "2″

Exec sp_helpdb [dbname]

4. After the log file is truncated it does not release the free space to OS. You will need to shrink the log file in order to release that space back to OS. You must go to that database by using USE, in order to shrink log file.

Use [dbname]

DBCC Shrinkfile ([logical_name_of_log_file], TRUNCATEONLY)

5. Check if the log file size.

DBCC SQLPerf(Logspace)

6. Reconfigure the mirror.

Leave a comment

Recent Entries

  • Lync Server 2010 发布架构报错

    昨天想试试在现有的 OCS 2007 R2 的基础上部署 Lync Server 2010 试试看,装好 Topology Builder 之后,新建了一个拓扑,然后把该填的都填了,发布的时候老是报SQL错,很是郁闷,后来终于在log中找到了错误原因:  Script result: ERROR_VALIDATE_BAD_SQL_VERSION Error: Script failed (code "ERROR_VALIDATE_BAD_SQL_VERSION") when installing "CentralMgmtStore" on "LyncServer01.mail2any.local"....

  • 使用 URL Rewrite 重定向 Http 请求至 Https

    公司部署了个新的 IIS 站点,需要强制在 Https 下面访问,但是又不希望关掉80端口的 Http 请求,这样对用户体验来讲不好,最好是能强制所有的 Http 请求都会被重定向到 Https 上面去,显然, IIS 自带的 "HTTP Redirect" 已经不能满足这个需求,我们这里使用 IIS 7.0 下面的重定向扩展 URL Rewrite Module 来做。1. http://www.iis.net/download/URLRewrite 到这里下载,有分...

  • How to remember your OC and Outlook password

    How to make your computer remember your Microsoft Communicator 2007 R2 and Outlook 2007 password (如何让你的电脑在非域环境中记住 OC 2007 R2 和 Outlook 的密码)我们知道,在域的环境中,使用 OC 和 Outlook...

  • 微软 CRM 2011 Beta 快速安装图解

    微软在9月17日在网站上放出了 CRM 2011 (也就是CRM5.0)的 beta 版本,我就先来个简单的快读安装图解,一睹为快,下个月会写点新版 CRM 的使用感受。 下载: Microsoft Dynamics CRM 2011 Beta Microsoft Dynamics CRM 2011 Software Development Kit (SDK)Microsoft Dynamics CRM 2011...

  • 升级到 Exchange 2010 SP1 后出现的2个小问题

    今天有空把所有的 Exchange 服务器从 2010 RTM 升级到了 2010 SP1 了, 升级完了后发现了2个小问题: OWA打开正常,但是点到 ECP 的时候报 403 访问拒绝错误 某台 Exchange 打开 EMS 时报错如下: [server.mydomain.local] Connecting to remote server failed...

Close