Transaction log file successfully shrunk in Database Mirroring (reprinted)

Source: Internet
Author: User

Transaction log files are successfully shrunk in database mirroring

How do you shrink a transaction log file when the database is already running in database mirroring?

We have a product database found that the transaction log file has reached 60GB, and the database itself is only 30GB. The transaction log file needs to be shrunk.

After a week of observation, on average there is no 1.5GB log, 99% of the log is produced in the evening, the weekend has a 16GB log, it seems that most of the non-working hours batch processing generated.

I think shrink log file, how to do it?? Google is not a good way to go for half a day, most of it is to switch to Simple mode, rebuild the database mirror database. This impact on the product environment is relatively large.

Only to touch the stone himself across the river:

Do what you want to do first:

BACKUP LOG dbname to DISK=' Path/dbname_tx_log.timestamp ';
GO
DBCC shrinkfile(' Dbname_log ', 4096)
GOIt only shrinks to about 50GB and reports that data is being used. Repeated execution has no effect, Google has no answer

I back up the log file again

BACKUP LOG dbname to DISK=' Path/dbname_tx_log.timestamp ';
GO
DBCC shrinkfile(' Dbname_log ', 4096)
GO

I found it.

Verify that the discovery did shrink to 4GB

DBCC SQLPERF (LOGSPACE);

Verify the database mirroring, everything is OK, the mirror side also shrinks synchronously (the query from the database does not change)

It looks like 2 backups to release transaction information at the end of the file

PS: We want to avoid frequent shrinking of database and transaction log files, cycle new backup log files, free up space, and make it more important to stabilize in a reasonable size

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.