Friday, February 11, 2011

How to do a database Off-Line defrag in Exchange 2010

UPDATED 17/02/2011
Folks,
to be honest..the database's defrag is pretty the same as Exchange 5.5 version, but always is useful to remember the commands:

First of all , remember that:
Seeding is required under the following conditions:
  • When a new passive copy of a database is created. Seeding can be postponed for a new mailbox database copy, but eventually, each passive database copy must be seeded in order to function as a redundant database copy.
  • After a failover occurs in which data is lost as a result of the passive database copy having become diverged and unrecoverable.
  • When the system has detected a corrupted log file that cannot be replayed into the passive copy of the database.
  • After an offline defragmentation of any copy of the database occurs.
  • After the log generation sequence for the database has been reset back to 1.
So, we need to suspend the database copy first:

1-               Suspend-MailboxDatabaseCopy MST1DB1\MBXSERVER(passive) -Confirm:$false
2- Then all get the phisical database path
                  Get-MailboxDatabase "MST1DB1" | fl name,*path*
Name                    : MST1DB1
EdbFilePath             : E:\MST1DB1\MST1DB1.edb
LogFolderPath           : E:\MST1DB1logs
TemporaryDataFolderPath :
3- Dismount the database
                 Dismount-Database mst1db1 -confirm:$false
4- The defrag commnad (eseutil /D) , the /t switch redirects the temporary file to another disk (with enough free space ..of course)
                  eseutil /d E:\MST1DB1\MST1DB1.edb /t e:\def\temp.edb
Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 14.01
Copyright (C) Microsoft Corporation. All Rights Reserved.
Initiating DEFRAGMENTATION mode...
            Database: E:\MST1DB1\MST1DB1.edb
                  Defragmentation Status (% complete)
          0    10   20   30   40   50   60   70   80   90  100
          |----|----|----|----|----|----|----|----|----|----|
          ...................................................

Moving 'e:\def\temp.edb' to 'E:\MST1DB1\MST1DB1.edb'... DONE!
Note:
  It is recommended that you immediately perform a full backup
  of this database. If you restore a backup made before the
  defragmentation, the database will be rolled back to the state
  it was in at the time of that backup.
Operation completed successfully in 9.656 seconds.

5- Finally mount the database
                         Mount-Database mst1db1

6- Update the databases copy
  
  Update-MailboxDatabaseCopy MST1DB1\MAILBOX SERVER(passive)  -DeleteExistingFiles
7- Check the database and copy status and check the database file's size in active server and in all passive servers
                  
                          Get-MailboxDatabaseCopyStatus -Server MAILBOX SERVER(passive)
 ESEUTIL is an Exchange database utility located in the \bin directory of Exchange server. A number of switches are possible with ESEUTIL:
  • ESEUTIL /D – Used for offline defragmentation of a Database
  • ESEUTIL /R – Used for recovery purposes of a Database
  • ESEUTIL /g – Performs an integrity check  of a Database
  • ESEUTIL /k – Performs a checksum test of a Database
  • ESEUTIL /p – Repairs a Database when it’s corrupt (and beyond recovery)
  • ESEUTIL /m – can dump header information of a Database and Log Files
  • ESEUTIL /y – can copy large files like Mailbox Database files efficiently
  • ESEUTIL /c – Is used to ‘hard recover’ a database during an online backup

Rollup Installation With DAG Maintenance Scripts In Exchange 2010 SP1

Installing update rollups on DAG members was never a straight forward task like clicking Next, Next. We had to make sure that all the active databases have been moved to a different DAG member, activation of all databases on the server to be patched is blocked, mailbox database copy is suspended etc. If we had Forefront running, it had to be disabled as well.

To make patching DAG members easier, Microsoft has two new scripts in the “Scripts” folder of Exchange 2010 SP1. StartDAGServerMaintenance.ps1 and StopDAGServerMaintenance.ps1.
The StartDAGServerMaintenance.ps1 script does the following:
  • Run Suspend-MailboxDatabaseCopy for each database copy hosted on the DAG member.
  • Pauses the node in the cluster, which prevents it from being and becoming the Primary Active Manager.
  • Sets the value of the DatabaseCopyAutoActivationPolicy parameter on the DAG member to Blocked.
  • Moves all active databases currently hosted on the DAG member to other DAG members.
The StopDAGServerMaintenance.ps1 script does the following:
  • Run Resume-MailboxDatabaseCopy for each database copy hosted on the DAG member.
  • Resume the node in the cluster, which will enables full cluster functionality for the DAG member.
  • Sets the value of the DatabaseCopyAutoActivationPolicy parameter on the DAG member to Unrestricted.
In order to install a rollup on 2010 SP1 (UR1 at the time of writing), follow the steps below.
  • Run the StartDAGServerMaintenance.ps1 script from the “Scripts” folder with the –ServerName switch before patching the DAG member. Forefront will have to be disabled manually.
  • Use the -whatif switch to test the script



  • Install update rollup, make sure that it is run from an elevated command prompt, read my article.
  • Run the StopDAGServerMaintenance.ps1 script with the –ServerName switch after patching the DAG member. Enable forefront manually.


Enjoy....and patch your servers smoking a big cigarette

-Dario