• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 12151
  • Last Modified:

How to compact the Exchange 2007 Databases

There are a billion how-to's on the 'net.  I'd like a real world answer to this question.

Very simply stated, how does one go about compacting the Exchange 2007 Databases on a Windows Server 2003 R2 Standard x64 box?  What services, if any, do I need to stop, is this a command line function, and if so, what are the exact switches, etc?

1 Solution
you can do a offline defrag using the ESEUTIL
that will reclaim all free space available

Very simply stated, how does one go about compacting the Exchange 2007 Databases on a Windows Server 2003 R2 Standard x64 box?

Well, if you are asking for what sort of real world solution is about (which includes MNC like WalMart - Microsoft - Netware - Shell - HP) uses - no one ever touches those switches EVER. For a simple reason Eseutil means that database has to go offline (that's a crime in today's world - ask your boss if you dont believe me). So now, what do we do ?

***We create a new mailbox store on the same server.
***Move mailboxes from source store to target store (in small batches over weekends)
***Once all mailboxes have been moved - this means that the corruption is also removed from your store including white spaces (since move mailbox would never carry empty spaces).
***Verify if the target store is working fine.
***Mount blank store (for source store)
***Move mailboxes back to this store (using the above steps)
***Now, what you have is a database that is corruption and white spaces free.
***Once, done DELETE the old store (which was earlier target store).

This requires ZERO amount of downtime - that is why it is preferred globally.

Is that clear ???

RLLSTechAuthor Commented:
Crystal clear.  That option was actually considered, but we're only a 47 user law firm, going offline at night is an option for us.  And this needs to be accomplished over the course of one evening.

So now that we know I can go offline.  What's the procedure?
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

LOL well your the guy to decide it.

Keep it simple.

Check the last recorded event id 1221 - this would inform you the free space you would get after going through the following process.

Stop SMTP Service and Routing Engine Services.
Dismount your stores gracefully (right click and dismount stores)
Check the database path (go to properties - database tab)
Calculate the database size (.EDB + .STM)
You would require 110% of the above size free to run the Eseutil command.
Say for example you have the Database on C:\Program Files\Exchsrvr\Mdbdata and you have free space on D drive. In that case run the command from that particular command.

On the command prompt it should look like this.

D:\"C:\Program Files\Exchsrvr\Bin\Eseutil.exe" /d "C:\Program Files\Exchsrvr\Mdbdata\priv1.edb"

This command will run with speed 4-5 Gb/hr.

Once done. Please rename the log files folder (go to property of storage group in ESM) and replace with an empty folder - THIS IS IMP

Once done. Total the .EDB and .STM files and check if the size has reduced.

Mount stores gracefully (right click mount)

Phew..!!!!!!!!!!! that was alot of typing
RLLSTechAuthor Commented:
Thank you.  I understand all but one part:

"Once done. Please rename the log files folder (go to property of storage group in ESM) and replace with an empty folder - THIS IS IMP"

So, before I restart any services or remount the stores, I rename the folder in which the tracking logs are stored?

If I'm looking in the right place, I see this, "E:\Program Files\Microsoft\Exchange Server\TransportRoles\Logs\MessageTracking"  Is that correct?

Didn't i mention storage group properties ?? Those are located above your stores.

I was referring to transaction logs and not message tracking logs buddy.

The reason why it is important to rename the log file folder since the database signature gets changed after your eseutil is run over it and hence it cannot be associated with old log files. Hence, it would require new set of log files.

RLLSTechAuthor Commented:
You probably did.  I apparently don't absorb everything I read.  Anyway, I rename the folders, create a new folder for the transaction logs, then point the storage group properties to the newly created folder, correct?

Sorry for so many questions.  I've done some of this stuff on test servers, but not enough that I know it from memory.  Since this will be done on a live server, I really, REALLY don't wanna hose anything. :)
You do not need to make any changes at storage group since you would be recreating that folder.
Say for example if you have the log files folder named at  C:\LOGS - so you would be renaming this folder to say LOGS1 - and now you would recreate a blank folder with the name LOGS.

So nothing change at configuration level of Exchange.
RLLSTechAuthor Commented:
Got it.  I'm going to do this now.  I'll report back with the results.
If you have the hard disk space but the problem is that the message store is too large then surely you could just increase the maximum size of the message store - <a href="http://technet.microsoft.com/en-us/library/bb232092.aspx">see Technet</a>. A 2 minute registry change and a service restart must be easier than some of the above suggestions...
@CharAP: the question is "How to compact the Exchange 2007 Databases" Not how to reduce or prevent from having a big store. If it had been the latter - you had given a good solution, also it would have been a better resolution to divide mailboxes across multiple stores simple.
RLLSTechAuthor Commented:
Everything worked beautifully.  Thank you.

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now