How to compact the Exchange 2007 Databases

Posted on 2008-10-15
Last Modified: 2011-05-25
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?

Question by:RLLSTech
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 22722971
you can do a offline defrag using the ESEUTIL
that will reclaim all free space available
LVL 33

Expert Comment

ID: 22724648

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 ???


Author Comment

ID: 22724764
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?
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

LVL 33

Accepted Solution

Exchange_Geek earned 500 total points
ID: 22724917
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

Author Comment

ID: 22724998
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?

LVL 33

Expert Comment

ID: 22725181
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.


Author Comment

ID: 22725218
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. :)
LVL 33

Expert Comment

ID: 22725240
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.

Author Comment

ID: 22727050
Got it.  I'm going to do this now.  I'll report back with the results.

Expert Comment

ID: 22729934
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="">see Technet</a>. A 2 minute registry change and a service restart must be easier than some of the above suggestions...
LVL 33

Expert Comment

ID: 22731460
@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.

Author Closing Comment

ID: 31506373
Everything worked beautifully.  Thank you.

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question