Step-By-Step: Active Directory Optimization


End of support for Windows Server 2003 is fast approaching. With this in mind, most IT administrators are currently performing a migration to newer versions of Windows Server which in many cases includes an Active Directory migration. One item most do not take into consideration is the state of the Active Directory database after the migration is completed. Like any other database Active Directory can also become fragmented. Database optimization is recommended after an Active Directory migration is completed and should be scheduled moving forward to insure a better on going performance.

There are two methods of Active Directory defragmentation available: 

Online Defragmentation – Windows Server 2000 introduced a method that runs in certain intervals automatically to defragment the Active Directory database. It is part of active directory garbage collection process. When completed, it optimizes the data storage and reclaims the space for new active directory objects. This however will not reduce the size of the Active Directory database. The bonus of utilizing Online Defragmentation is that it not required to bring any service offline complete the task.

Offline Defragmentation – This method requires an IT administrator to stop the Active Directory service. In stopping said service, the process will create compact version of the existing Active directory database in different location. Once completed, the new defragmented compact database is copied to the original location.  Estimates are that the database is shrunk to 1/6th of its original size after offline fragmentation.

The “ntdsutil” is needed to perform defragmentation and is the same tool used to check Active Directory errors.  The following steps will detail the process.

Prerequisites

  1. Plan the Active Directory shutdown impact properly and measure how it will affect the rest of the organization. Length of time to complete the defragmentation depends on the size of the Active Directory database and the how bad it is fragmented.
     
  2. Always perform a system state backup prior to the process.

Step 1: Stopping the Active Directory Service

  1. Login to the primary domain controller as Domain admin or Enterprise Admin
     
  2. Navigate to Server Manager > Tools > Services
     
    opt1
     
  3. In Services.mmc right-click on Active Directory Domain Services and click Stop
     
    opt2
     
  4. Services to be stopped are then listed. Click Yes to continue.
     
    opt3
     

Step 2: Perfroming the Offline Active Directory Fragmentation

  1. Once services stops, run the Command Prompt in Administrator mode
     
  2. In the Command prompt window, type ntdsutil and press enter
     
    opt5
     
  3. In prompt type activate instance NTDS and press enter
     
    opt6
     
  4. Type files and press enter
     
    opt7
     
  5. At the file maintenance we need specify the location where NTDS compact database will save. For this Step-By-Step, the folder C:\CompactDB was created. Type compact to C:\CompactDB and press enter
     
  6. The defragment process begins. The time to completion will depend on the size of the database
     
    opt8

     
  7. Once completed type q to exit from the utility
     
  8. Close the Command Prompt console
     
  9. Copy the defragmented database from C:\CompactDB\ntds.dit to C:\Windows\NTDS\ntds.dit
     
  10. Delete the log files found in the directory
     
  11. Return to the Services.mmc
     
  12. Right-click on Active Directory Domain Services and click Start

The defragmentation of the Active Directory database is now complete.

Comments (0)

Skip to main content