Thursday, May 25, 2006

How to Perform an Offline Defrag on Exchange

I can not believe that I have not posted this before.

Part of the routine maintenance on Exchange Servers to take the Information stores down and run an offline defragmentation on them. This is done because the size of a database does not shrink as items are deleted or moved from within. Over time the database will grow through normal usage and could reach a size that is unmanageable. By routinely doing a defrag, we can make current used space contiguous (improved performance), eliminate unused storage space, and compact the database thus reducing its size.

The database is defragged using the ESEUTIL.exe command found in the c:\exchsrvr\bin directory. Eseutil basically copies all the current storages (mailboxes) and exports them to a newly created file. The process runs until all information has been copied to the new file. Then the original database (priv.edb) is deleted and the temp database is renamed to become the new compacted priv.edb.

Preliminary Steps (Both Processes)
1. Stop the Microsoft Exchange System Attendant (This will stop all other associated services as well)
2. Determine that enough space is available to run the offline defrag.

Same Server Defrag Steps
1. At a command prompt, change directory to the location of the database
2. Type the command below, including quotes:
“c:\program files\exchsrvr\bin\eseutil” /d e:\mdbdata\store1\priv.edb
3. The defrag will begin and the status will be displayed.
4. Once the defrag has completed restart the Microsoft Information Store (this will start all other necessary services).
5. Restart Exchange Service Anti-Virus software services.
6. Start a back-up run on the newly defragged database.

Separate Server Defrag Steps
1. From the original Exchange server, map a drive to the remote server with enough space for the defrag.
2. Create a blank directory on the remote server called exdefrag and copy the files below to this directory.
Ese.dll, jcb.dll, Eseutil.exe - located in the c:\winnt\system32 directory
Priv.edb - located in the e:\mdbdata\store1 directory
3. Open a command prompt on the server where the files have been moved to.
4. Change directory to the exdefrag directory that was created.
5. Type the command below, including quotes:
“c:\program files\exchsrvr\bin\eseutil” /d e:\mdbdata\store1\priv.edb
6. The defrag will begin and the status will be displayed.
7. Once the defrag has completed copy the new smaller priv.edb file back to its original server.
8. Restart the Microsoft Information Store service where the database resides (this will start all other necessary services as well).
9. Restart Exchange Service Anti-Virus software services.
10. Remove exdefrag directory from the remote server and logout.
11. Start a back-up run on the newly defragged database.

A same server defrag is much easier and far less of a hassle, but if you don’t have the necessary space, it is possible to defrag the store on another server.

No comments: