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