Tuesday, September 14, 2010

Flush Transaction Logs in Exchange

This article applies to all versions of Exchange from 5.5 to 2010.

The following knowledge base article gives you all the fruit about flushing transaction logs but I assume you just want to know how to do it right?

http://support.microsoft.com/kb/240145

Your Exchange Logs get deleted when your database backup completes. When your exchange server receives an email it dumps the email to the transaction logs. When the exchange server free's up it then plays these logs into the database. Sometimes Exchange may not have played all the log files into the database, so you cant simply "delete" them.

1. Dismount the all Exchange Mailbox Databases under the Storage Group you wish to clean up.

2. Use the ESEUTIL program to view if all the logs have been played into the Exchange Database.

eseutil /MH database.edb



If all the databases are in a Clean Shutdown or Consistent state, you may remove all the transaction logs. Older versions say "Consistent", New Versions of Exchange say "Clean Shutdown". In my screenshot I'm using Exchange 2010.

Note: If it is not in a "Clean Shutdown" or "Consistent" state, you can use eseutil to reply the log files into the database or remount the database and allow Exchange to replay them.

Caution: Do not delete log files if the state is not "Clean Shutdown" or "Consistent" as you will loose email!

3. Delete all log files including the chk file. The checkpoint file keeps track of which log files have been and have not been played into the database. Since there are no log files anymore, the checkpoint is not needed.

Caution: If your database is in the same directory as your log files be careful you dont accidently delete your edb database file as well!

4. Re-mount your exchange databases in your storage group. This will automatically create a new checkpoint file ready to go!

20 comments:

  1. Microsoft says to "move" your files first... just in case. I think that might be wise.

    ReplyDelete
  2. Thanks, this really helped me out. And yes, definitely move first

    ReplyDelete
  3. Thanks for this post. This really help me to retrieve my exchange 2010 server disk space.

    ReplyDelete
  4. Awesome!! helped a lot, thanks :-)

    ReplyDelete
  5. Good job this is a nice post for reading this is my first time at this blog and really like what i m reading thanks i will keep visiting.

    ReplyDelete
  6. Awesome!! helped a lot, thanks :-)
    Syed Rehan Ali

    ReplyDelete
  7. Does this also work for Exchange 2013? Can't find any references for that.

    ReplyDelete
  8. Clint, you're a genius :) It worked like a charm

    ReplyDelete
  9. Thank you Clint for an excellent article! I'm glad I learned this today.

    ReplyDelete
  10. This saved the day! Thanks for the post!

    ReplyDelete
  11. if this is a DAG environment do you remove the LOG files from both DAG members? or only one?

    ReplyDelete
  12. I am in the middle of copying my logs to another partition as we speak. I think this will fix my issue as my database was dismounted on its own and the log volume was full. I'm new to exchange management. Is this really the "hands on" maintenance that is expected to be done on the logs for this server? I feel like I am missing something that will clear things out after database checks are made. I read circular logging is not recommended.

    Thx for the post. It should help. Any other info?

    Rob

    ReplyDelete
    Replies
    1. Logs are flushed when your database is backed up. Get a backup solution in place and you only need to worry about this when the backup fails to flush the logs.

      Delete
  13. Regarding the query about DAG environments, transaction logs are independent on each cluster node. Cleaning up the transaction logs on one node will not cleanup the logs on other cluster nodes.

    ReplyDelete
  14. Thank you for the simple walkthrough, worked perfectly!

    ReplyDelete
  15. Has anyone tested this on Exchange 2016?

    ReplyDelete
  16. This works fine for Exchange 2016 Raymond.

    ReplyDelete