2. Offline Database Maintenance
As the name implies, offline
database maintenance is performed while the database is unavailable to
the user community. As such, offline maintenance should be scheduled
(whenever possible) during nonbusiness hours.
As
discussed, Exchange Server 2007 performs an automated daily
defragmentation as part of the scheduled database maintenance. This
process, known as an online
defragmentation, is intended to keep the databases healthy and free
from corruption, but it does not shrink the physical size of the
database.
In an Exchange environment, as
more data is added to a database, the database grows in size. When
messages or mailboxes are deleted, however, the database does not
decrease in size, it simply frees up available “whitespace” that can be
overwritten by new mail or mailboxes.
Although
this is not normally a problem for an environment, there are scenarios
in which it can create issues. For example, if a database was to grow
extremely large and, in an effort to redistribute the load, an
administrator was to move 50% of the mailboxes to another server, the
database would still remain the same size. Even though the database
contains 50% whitespace, it still must be backed up in its entirety
and, in the event of a disaster, would have to be restored as such.
The only way to shrink a database is to perform an offline defragmentation, which is a manual process utilizing the eseutil/d command.
To
determine the amount of whitespace contained within a database, view
the application log of the Exchange server and filter on Event ID 1221.
This event shows how much free space exists within each database.
Caution
should be used before performing an offline defragmentation, and
administrators should be sure to back up the database prior to the
maintenance. Although Exchange databases have become more and more
stable over the past several iterations of Exchange, there is still the
possibility of an offline defragmentation corrupting a database. An
additional protective measure is to make a copy of the database after
it has been taken offline, and
then perform the maintenance procedures on the copy, rather than on the
original. In the event of severe problems, the original database can be
brought back online.
Caution
Exchange
Server 2007 databases and transaction log files should never be
manually modified. Although there are many database utilities in
existence that are capable of modifying Exchange databases, only those
utilities recommended by Microsoft for use with Exchange should be
utilized.
Performing Offline Database Maintenance
To
perform offline database maintenance, ensure a valid backup of the
database exists. The following steps can be followed to utilize the isinteg and eseutil utilities to perform offline database maintenance:
1. | Log on using an account that is an Exchange Server Administrator for the Exchange server housing the databases being maintained.
|
2. | Open the Exchange Management Console.
|
3. | In the console tree, expand Server Configuration and select Mailbox.
|
4. | In
the action pane, select the server you want to view. In the work pane,
expand the storage group that contains the database you want to view,
and then select the appropriate database.
|
5. | Note
the database file path for the database. This can be copied to the
Clipboard by viewing the properties of the database, highlighting the Database path, and clicking Ctrl+C. You will need this information later when you use the eseutil utility.
|
6. | In the action pane, click Dismount Database, and then click Yes to confirm.
|
7. | Open a command prompt by selecting Start, Run, typing cmd in the Open text box, and clicking OK to continue.
|
8. | Change to the drive and directory where isinteg resides. The default location is:
C:\Program Files\Microsoft\Exchange Server\Bin |
9. | Type
isinteg.exe –s <ServerName> -test allfoldertests
and then press Enter. A list of available databases on the server will
be presented, indicating which are online or offline, as shown in Figure 1.
|
10. | Choose
to run maintenance on the offline database by typing the appropriate
number and pressing Enter. Confirm the appropriate database, press Y,
and then press Enter to continue.
If isinteg
finds errors, run the appropriate fix as recommended and displayed
within the command prompt. The same error and recommended fix is
recorded in the Application Event Log. If necessary, repeat the isinteg integrity check until no errors are reported. When no errors are reported, continue to the next step.
|
11. | At the command prompt, type the following command to perform a database-level integrity check:
Eseutil.exe /g "database file path"
Replace database file path with the database location and filename copied in step 5.
If there is a space anywhere in the path or filename, be sure to
enclose the entire path and filename in double quotes, as shown
previously. A sample path and filename are as follows:
"D:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\Mailbox Database.edb"
When ready, press Enter to continue.
|
12. | At the command prompt, type the following command to defragment the database:
Eseutil.exe /d "database file path"
and press Enter. Again, the double quotes are necessary for paths with spaces in the names.
Tip
Although
it is always a good practice to perform offline database maintenance,
including defragmentation, on a quarterly basis, it is necessary only
when the amount of free space in the database is greater than 15% of
the total database size.
To calculate
the percentage of free space, take the total free space recorded in the
application log (Event ID 1221) and divide that by the size of the EDB
file.
|
13. | When the database compaction has completed, use the Exchange Management Console to mount the database. |
14. | Using
NTBackup or a third-party product, perform a full backup of the
database. This step should be accomplished as soon as possible. If the
database should fail prior to a backup being completed, the old
database would have to be restored, and offline maintenance performed
all over again.
|
Performing Database Maintenance Through Mailbox Moves
Online
and offline database maintenance each have their purposes, with offline
maintenance routines performing the most thorough maintenance. Offline
maintenance can take a significant amount of time to perform based on
the size of the database and its overall condition, as well as the
performance capabilities of the server housing the database. Even on
high-performance servers, offline database maintenance can sometimes
progress at a rate of approximately 5GB per hour. So, performing
offline maintenance on a large database (for example, 40GB) could take
8 hours or more to complete.
An
alternative method that does not require nearly as much downtime is
moving mailboxes to another mailbox store. An Exchange administrator
can create a new mailbox store either on the same Exchange Server 2007
server or on a separate server altogether. After the new mailbox store
is created, the administrator can move mailboxes over to the new
mailbox store. By moving the mailboxes over to the new mailbox store,
the database is in optimal condition. After all mailboxes have been
moved, the old database can be deleted.
Note
As
with any maintenance process, it is important to perform backups of
Exchange prior to performing the maintenance tasks. Also, moving
mailboxes for maintenance reasons should be performed during
nonbusiness hours to avoid interrupting users.
In
some cases where the database is experiencing many corruptions, not all
mailboxes will be able to be moved. For instance, there might be
roughly 5%–10% of the mailboxes still on the original mailbox store
that generated errors and did not move over to the new mailbox store.
In this scenario, the administrator can then perform offline database
maintenance on the message store.
The
benefit of this process is that, instead of performing long and arduous
offline maintenance routines on the large database, the utilities are
run against a much smaller database. This results in a significant
savings in maintenance time needed.