SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Truncate log for Mirrored Database


Truncate log for Mirrored Database

Author
Message
rishgup
rishgup
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 75
Hello,

I am running Mirroring on my Database. Log file for my database growing day by day on Principal server. Recovery Model is Full. Data file is only 2 GB but Transaction Log file is 50 GB.

I am running 2 Management Plans on Principal Server.

First Management plan is running Full Database back up every 3rd day and is running fine.
Second Management Plan is running the following
a) Transaction log backup.
b) TSQL Command backup log with no_log
c) Shrink Database utility.
transaction log backup works fine but for TSQL command it gives error that log can not truncate for mirrored database.

Is there any option I can truncate Log file for Mirrored database through Management Plan, without removing mirroring?

Response would be greatly appreciated.

Thanks
Rishabh
GilaMonster
GilaMonster
SSC Guru
SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)

Group: General Forum Members
Points: 214266 Visits: 46266
You cannot truncate the log of a mirrored database. You should not be truncating your log anyway. It breaks the log chain and means that you will not be able to do a point-in-time restore of the db to any point after the log truncation, until you take another full/diff backup.

a) Transaction log backup.
b) TSQL Command backup log with no_log
c) Shrink Database utility.


Why truncate the log at the 2nd step? You've just backed up the log which will discard all inactive transactions (after backing them up). The only thing that will achieve is to break the log chain.

Why do you want to shrink your database every 3 days. It results in sever index fragmentation and the DB is just going to grow again as soon as data is added. The repeated shrink/grow can result in fragmentation at a file-system level.

Have a quick read through these two blog posts please
http://sqlinthewild.co.za/index.php/2007/09/08/shrinking-databases/
http://sqlinthewild.co.za/index.php/2008/07/23/recovery-model-and-transaction-logs/

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


free_mascot
free_mascot
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: General Forum Members
Points: 7227 Visits: 2250
Another reasons to grow your Tlog is if your Mirroring is not working properly(i.e. latency is more) or if Mirroring is pending on destination DB it won't truncate the log.

Check and make sure Mirroring is workind smoothly.

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
FNS
FNS
SSC-Addicted
SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)

Group: General Forum Members
Points: 449 Visits: 584
No, you cannot shrink the tlog on a mirrored database without breaking the mirror first.

Given that your log is 50Gb vs data at 2Gb you're going to need to bite the bullet and turn off mirroring for a moment while you sort this out. Something is clearly amis here and you're going to need to get at things to figure out what which means turning off the mirror. The only job you should need to keep the tlog a sensible size is a regular tlog backup (via maint wizard if necessary). I'd also check this t-log backup actually working (ie you're getting a nice .trn file and it can be restored to a test system) and it is running regularly enough for the number of transactions that are being pumped through the database.
rishgup
rishgup
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 75
Mirroring is working properly.
rishgup
rishgup
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 75
FNS (10/20/2008)
No, you cannot shrink the tlog on a mirrored database without breaking the mirror first.

Given that your log is 50Gb vs data at 2Gb you're going to need to bite the bullet and turn off mirroring for a moment while you sort this out. Something is clearly amis here and you're going to need to get at things to figure out what which means turning off the mirror. The only job you should need to keep the tlog a sensible size is a regular tlog backup (via maint wizard if necessary). I'd also check this t-log backup actually working (ie you're getting a nice .trn file and it can be restored to a test system) and it is running regularly enough for the number of transactions that are being pumped through the database.




I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)

Group: General Forum Members
Points: 214266 Visits: 46266
rishgup (10/20/2008)

I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.


You need to backup the log a lot more than once a week. Depending on activity, once or twice an hour.

How often are you backing up the log? Is you query the sys.databases view, what does the column log_reuse_wait_desc show for the DB in question?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


rishgup
rishgup
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 75
GilaMonster (10/20/2008)
rishgup (10/20/2008)

I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.


You need to backup the log a lot more than once a week. Depending on activity, once or twice an hour.

How often are you backing up the log? Is you query the sys.databases view, what does the column log_reuse_wait_desc show for the DB in question?


Now I setup Transaction log back up every 2 hours and the log_reuse_wait_desc for database is LOG_BACKUP
GilaMonster
GilaMonster
SSC Guru
SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)SSC Guru (214K reputation)

Group: General Forum Members
Points: 214266 Visits: 46266
Then you should be set. That column value indicates that the log space is not been reused because a log backup is required. Once the log backup runs (check and make sure that they are actually running successfully), the space in the log should be reused.

You can shrink the file down to a reasonable size (say 1GB) and see how things go from there.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


rishgup
rishgup
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 75
GilaMonster (10/21/2008)
Then you should be set. That column value indicates that the log space is not been reused because a log backup is required. Once the log backup runs (check and make sure that they are actually running successfully), the space in the log should be reused.

You can shrink the file down to a reasonable size (say 1GB) and see how things go from there.

Thanks I'll update you guys
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search