Recipe6.9.Moving Databases and Logs to Different Disks


Recipe 6.9. Moving Databases and Logs to Different Disks

Problem

You want to relocate the files for a database, or the transaction logs for a storage group, from one disk volume to another.

Solution

Using a graphical user interface

To move the EDB and/or STM files in a database, do the following:

  1. Launch the Exchange System Manager (Exchange System Manager.msc).

  2. In the left pane, expand the appropriate Administrative Groups container, and then expand the Servers container.

  3. Expand the server that contains the target database, then expand the parent SG.

  4. Right-click the mailbox or public folder store whose databases you wish to move, and select Properties.

  5. Switch to the Databases tab and use the Browse button to indicate a new location for the Exchange database, the streaming database, or both.

  6. Click OK to save the new locations. You will be prompted for confirmation, reminding you that the store will be dismounted, and asking you if you wish to continue. Click Yes.

  7. Once the Exchange and streaming databases have been moved and remounted, click OK.

  8. Make certain that the new file system location has the following access rights:


Administrators

Full Control


Authenticated Users

Read and Execute, List Folder Contents, Read


Creator Owner

None


Server Operators

Modify, Read and Execute, List Folder Contents, Read, Write


System

Full Control

To move a storage group's logs to another volume, do the following:

  1. Launch the Exchange System Manager (Exchange System Manager.msc).

  2. In the left pane, expand the appropriate Administrative Groups container, and then expand the Servers container.

  3. Expand the server that contains the target SG.

  4. Right-click the SG whose transaction logs you wish to move and select Properties.

  5. On the General tab, click the Browse button to select a different disk or folder location for that SG's transaction logs.

  6. Make certain that the new filesystem location has the following access rights:


Administrators

Full Control


Authenticated Users

Read and Execute, List Folder Contents, Read


Creator Owner

None


Server Operators

Modify, Read and Execute, List Folder Contents, Read, Write


System

Full Control

Using VBScript

To move a database to another path, use this code:

' This code moves database files to the specified path.  ' The database is dismounted and remounted as necessary. ' ------ SCRIPT CONFIGURATION ------  strServerName = "<serverName>"    ' e.g., "BATMAN"      strMDBName = "<dbName>"        ' e.g., "Mailbox Database (SpiffyDatabaseName)"  strNewPath = "<fullPath>"     ' e.g., "c:\temp\"  ' ------ END CONFIGURATION --------- Set theServer = CreateObject("CDOEXM.ExchangeServer") Set theMDB = CreateObject("CDOEXM.MailboxStoreDB") theServer.DataSource.Open strServerName arrSG = theServer.StorageGroups theFirstSG = arrSG(0) strURL = "LDAP://" & theServer.DirectoryServer & "/cn=" & strMDBName & "," & theFirstSG theMDB.DataSource.Open strURL ' dismount the database before attempting to move it If (theMDB.Status= 0) then     theMDB.Dismount End If ' move the DB to the specified path, then remount it theMDB.MoveDataFiles strNewPath & strMDBName & ".edb", strNewPath & strMDBName & ".stm" theMDB.Mount WScript.Echo "Database moved to " & strNewPath & " and remounted."

If you want to move transaction logs for a storage group without touching the databases, use this code:

' This code moves transaction logs for the first storage group ' to the specified location ' ------ SCRIPT CONFIGURATION ------ strServerName = "<serverName>"    ' e.g., "BATMAN"     strNewPath = "<fullPath>"         ' e.g., "c:\temp\" ' ------ END CONFIGURATION --------- Set theServer = CreateObject("CDOEXM.ExchangeServer") Set theSG = CreateObject("CDOEXM.StorageGroup") theServer.DataSource.Open strServerName arrSG = theServer.StorageGroups theFirstSG = arrSG(0) strURL = "LDAP://" & theServer.DirectoryServer & "/" & theFirstSG theSG.DataSource.Open strURL ' move the log files to the specified path; this dismounts and remounts ' all of the SG's databases theSG.MoveLogFiles strNewPath WScript.Echo "Moved logs for SG " & theFirstSG & "to " & strNewPath

Discussion

For best performance and recoverability, you should keep your Exchange transaction logs on a different physical disk or array than the Exchange database files. This gives the ability to have up-to-date logs to play back in the event of a database drive failure, allowing administrators to restore to the point of failure. The Exchange 5.5 Performance Wizard would attempt to figure out which disks to put its database (singular) and log files on, but Exchange 2000 and later dump everything in \program files\exchsrvr\mdbdata. You can, and should, relocate your databases and log files to enhance performance and recoverability. However, before you can move a database, it has to be dismounted; and before you can move the log files for a storage group, you'll have to dismount all of its databases.

The scripts for this recipe use the CDOEXM interfaces for the MailboxStoreDB and StorageGroup objects to move databases and transaction logs. In both cases, the first SG's URL is used as the basis for constructing the URL to the target SG or database. The database moving script dismounts the database if it's mounted when the script is run, and mounts it after the move, because you cannot move a mounted database.

See Also

MS KB 821915 (How to Move Exchange Databases and Logs in Exchange Server 2003), MS KB 257184 (XADM: How to Move Exchange Databases and Logs in Exchange 2000 Server), and Exchange Server 2003 Performance and Scalability Guide (available from the Microsoft web site at http://www.microsoft.com/technet/prodtechnol/exchange/2003/library/perfscalguide.mspx)



Exchange Server Cookbook
Exchange Server Cookbook: For Exchange Server 2003 and Exchange 2000 Server
ISBN: 0596007175
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net