Home

Tuesday, March 17, 2009

SharePoint 3.0: How to Move SQL Database Files, Transaction Log Files to Different Disk Location

Description:

Instructions for moving database files (mdf) and transaction log files (ldf) to a different disk drive on the database server, in a MOSS 2007 server farm.


Solution:

1. Perform the necessary capacity planning analyses and tasks to ensure that the future configuration will perform and scale for growth.

2. Schedule a maintenance window to allow for enough time to perform the configuration changes and test the SharePoint portal after the changes are complete. Communicate the maintenance window appropriately to the business users.

3. Create folders on the destination disk drive for storing the files. If the servers are physical, consider storing the transaction log files on a separate physical disk from the database files, to maximize performance. If the servers are virtual, understand the disk configuration of the underlying servers to ensure considerations including disk performance, contention, scalability, and snapshots.

In this example, D:\MSSQL_Data is the destination of data files, and D:\MSSQL_TLogs is the destination of transaction log files.

4. On the MOSS web front end servers and the Index server, stop the following Windows Services:

WWW Publishing Service
Windows SharePoint Administration
Windows SharePoint Search
Windows SharePoint Timer
Windows SharePoint Tracing
Windows SharePoint VSS Writer
Office SharePoint Search


5. For each database that is being moved, run the SQL Commands below to take the database offline

SQL Server Management Studio > New Query
--------------------
ALTER DATABASE MOSS_ContentDatabase SET OFFLINE;
GO
--------------------

6. Using Windows Explorer, physically copy the mdf and ldf files of the databases to their new location.

7. Run the SQL Commands below to update the physical location of the database files

SQL Server Management Studio > New Query
--------------------
USE master;
GO
ALTER DATABASE MOSS_ContentDatabaseMODIFY FILE (NAME = MOSS_ContentDatabase, FILENAME = 'D:\MSSQL_Data\MOSS_ContentDatabase.mdf');
GO
ALTER DATABASE MOSS_ContentDatabaseMODIFY FILE (NAME = MOSS_ContentDatabase_log, FILENAME = 'D:\MSSQL_TLogs\MOSS_ContentDatabase_log.ldf');
GO
ALTER DATABASE MOSS_ContentDatabase
SET ONLINE
GO
--------------------

8. Verify that the updated location has been properly set for each database by running the command below:

SQL Server Management Studio > New Query
--------------------
USE master;
GO
SELECT name, physical_name
FROM sys.master_files
WHERE database_id = DB_ID('MOSS_ContentDatabase');
GO
--------------------

2 comments:

Doug said...

Good stuff - this was really helpful, thank you!

Unknown said...

Nice post very helpful

dbakings

Blog Archive

Followers