SQL Server Database Management: Creating Databases and Modifying Disk File Locations
Managing SQL Server databases within a clustered environment demands precise configuration, especially when it involves shared storage that wasn’t part of the initial SQL Server installation. This article provides a comprehensive guide on how to create new databases or relocate existing data and log files onto a secondary shared cluster disk. Understanding and correctly implementing these procedures is critical for maintaining high availability and optimal performance in a SQL Server Failover Cluster Instance (FCI).
SQL Server’s robust clustering capabilities are designed to ensure continuous operation, even in the event of hardware failures. However, this resilience relies heavily on the correct configuration of all underlying resources, particularly shared storage. When new shared disks are introduced, they must be properly integrated into the SQL Server cluster group and defined as dependencies to prevent operational issues and error messages.
Understanding SQL Server Failover Cluster Instances and Disk Dependencies¶
A SQL Server Failover Cluster Instance (FCI) integrates with Windows Server Failover Clustering (WSFC) to provide high availability for the entire SQL Server instance. This means that if one node in the cluster fails, the SQL Server instance automatically “fails over” to another operational node, ensuring minimal downtime. Central to this architecture is shared storage, where all database files, transaction logs, and other critical data reside, accessible by all nodes in the cluster.
For SQL Server to reliably access and manage files on a shared disk, that disk resource must be explicitly configured as a dependency of the SQL Server cluster resource within the Failover Cluster Manager. This dependency ensures that the disk is always online and available before the SQL Server service attempts to start or operate. Without this critical link, SQL Server will be unable to locate or access the necessary files, leading to service failures or the specific errors described below when attempting to use the non-dependent disk.
The concept of resource dependencies is fundamental to the stability of any clustered service. In the context of SQL Server, the SQL Server service (and often the SQL Server Agent service) depends on its associated Network Name, IP Address, and all the shared disk resources where its databases reside. This hierarchical relationship ensures a controlled startup and failover sequence, guaranteeing that all necessary components are online and accessible in the correct order.
Common Errors When Shared Disks Are Not Dependencies¶
Attempting to create a new database, move existing database files, or even create a full-text catalog on a shared cluster drive that is not correctly configured as a dependency to the SQL Server resource will result in specific error messages. These errors indicate that SQL Server cannot recognize or establish a connection to the specified disk through the cluster services, thus preventing the operation. It’s a security and integrity measure designed to protect your data.
When you try to create a new database on a non-dependent shared cluster drive, you are likely to encounter errors similar to these:
Server: Msg 5184, Level 16, State 2, Line 1
Cannot use file '%.*ls' for clustered server. Only formatted files on which the cluster resource of the server has a dependency can be used.
Server: Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check previous errors.
These messages clearly state the root cause: the specified file path (%.*ls being a placeholder for the actual file path) is on a disk that SQL Server’s cluster resource does not have a dependency on. Message 5184 is the primary indicator, directly explaining the requirement for a dependency. Message 1802 then confirms the failure of the CREATE DATABASE operation due to this underlying issue.
A similar set of errors will manifest if you attempt to move or add data and log files for an existing database onto a shared cluster drive that is not part of the SQL Server group and lacks the necessary dependency. SQL Server treats any file operation on a new disk path with the same stringency, ensuring the target storage is properly integrated into its cluster configuration before proceeding. The principle remains consistent: all storage used by SQL Server in a clustered environment must be a declared dependency.
Furthermore, if your SQL Server instance utilizes full-text search capabilities and you attempt to create a full-text index catalog on a disk without the proper dependency, a distinct but related error will be displayed:
Server: Msg 7627, Level 16, State 1, Procedure sp_fulltext_database, Line 61
Full-text catalog in directory 'Y:\FTDATA' for clustered server cannot be created. Only directories on a disk in the cluster group of the server can be used.
This error specifically highlights the requirement for the full-text catalog directory to reside on a disk that is part of the SQL Server’s cluster group, implying the necessary dependency. Regardless of the specific operation—be it creating a new database, relocating existing files, or establishing a full-text catalog—the underlying issue is always the missing disk dependency within the SQL Server cluster resource configuration. Resolving this dependency is the key to successfully performing these operations.
Prerequisites for Adding a Shared Disk to a SQL Server Cluster¶
Before you proceed with modifying the SQL Server cluster configuration, ensure that several prerequisites are met. These steps are crucial for a smooth and successful integration of the new shared storage. Neglecting any of these could lead to further complications or operational issues.
First, the shared disk must be physically connected and visible to all nodes participating in the SQL Server cluster. This involves proper cabling and storage array configuration, ensuring that the disk is presented as a shared volume across all cluster nodes. Once connected, initialize and format the disk with NTFS, selecting an appropriate allocation unit size (e.g., 64KB for SQL Server data files) for optimal performance.
Second, verify that the cluster service account and the SQL Server service account have the necessary permissions to manage cluster resources and access the new disk. Typically, the cluster service account requires administrative privileges on all cluster nodes, while the SQL Server service account needs full control permissions on the disk volume. Ensure that the disk is online and healthy in the Failover Cluster Manager, even if it’s currently in a different resource group.
Detailed Steps to Add a Shared Disk as a SQL Server Dependency¶
Adding a shared cluster disk as a dependency to your SQL Server instance involves two primary phases: ensuring the disk is in the correct resource group and then explicitly defining the dependency. Both steps are performed within the Windows Server Failover Cluster Manager.
Phase 1: Moving the Disk Resource to the SQL Server Group¶
The shared cluster disk must reside within the same resource group as your SQL Server cluster instance. If the disk is currently in a separate “Available Storage” group or another application’s group, it needs to be moved.
- Open Failover Cluster Manager: Launch the Failover Cluster Manager by searching for “Failover Cluster Manager” in the Windows Start menu or by navigating through Administrative Tools.
- Navigate to Roles: In the left-hand pane of the Failover Cluster Manager, expand your cluster name, then select “Roles.” Here, you will see a list of all configured cluster roles, including your SQL Server instance.
- Identify the SQL Server Role: Locate the role corresponding to your SQL Server Failover Cluster Instance (e.g., “SQL Server (MSSQLSERVER)” or a custom instance name). Right-click on this role and ensure it is currently online or bring it online if it’s offline.
- Locate the Disk Resource: In the left-hand pane, navigate to “Storage” > “Disks.” Identify the shared cluster disk that you intend to use for your SQL Server databases. Verify its current status and owner.
- Change the Disk’s Group: Right-click on the identified disk resource. From the context menu, select “Move” > “Move to another service or application.” A dialog box will appear, listing available roles. Select your SQL Server role (e.g., “SQL Server (MSSQLSERVER)”) from the list and click “OK.”
- Verify the Move: After the move operation completes, return to your SQL Server role under “Roles.” Expand the role, and you should now see the newly moved disk listed under its “Resources” tab. Ensure the disk resource is online and healthy within this group.
Phase 2: Adding the Disk Resource as a Dependency¶
Once the shared disk is part of the SQL Server’s resource group, you can define it as a dependency for the SQL Server service itself. This step is crucial for SQL Server to acknowledge and utilize the disk.
- Access SQL Server Role Properties: In the Failover Cluster Manager, under “Roles,” select your SQL Server role. In the “Resources” tab at the bottom, right-click on the “SQL Server” resource (e.g., “SQL Server (MSSQLSERVER)”) and choose “Properties.”
- Navigate to Dependencies Tab: In the SQL Server Properties dialog box, click on the “Dependencies” tab. This tab displays all resources that SQL Server requires to be online before it can start.
- Add the New Disk Dependency:
- Locate the “Available Resources” section. You should see your newly moved disk listed here.
- Select the disk resource you wish to add (e.g., “Cluster Disk 2” or a specific drive letter).
- Click the “Add” button to move it to the “Dependencies” list on the right.
- The dependency type will typically be “AND,” meaning SQL Server requires all listed dependencies to be online. If you have multiple disk resources, ensure they are all linked with “AND” logic.
- Apply and Confirm: Click “Apply” and then “OK” to save the changes.
- Test Failover (Recommended): To ensure the changes are correctly applied and the SQL Server instance can still failover smoothly, initiate a manual failover to another node in the cluster. Monitor the event logs and resource states during and after the failover to confirm everything comes online as expected. This step is vital for validating your configuration.
Following these steps meticulously will successfully integrate your new shared disk into the SQL Server cluster, making it available for database operations without encountering dependency-related errors.
mermaid
graph TD
A[Start] --> B{Open Failover Cluster Manager};
B --> C[Navigate to Roles -> SQL Server Role];
C --> D[Identify Target Shared Disk under Storage -> Disks];
D --> E{Right-click Disk -> Move -> Move to another service or application};
E --> F[Select SQL Server Role as destination];
F --> G{Verify Disk is now under SQL Server Role Resources};
G --> H[Right-click SQL Server Resource (e.g., SQL Server (MSSQLSERVER)) -> Properties];
H --> I[Go to Dependencies Tab];
I --> J{Add the newly moved Disk Resource from Available Resources};
J --> K[Ensure Dependency Type is AND];
K --> L[Click Apply and OK];
L --> M{Perform a Test Failover (Optional but Recommended)};
M --> N[End];
Post-Dependency Configuration and Best Practices¶
Once the shared disk is successfully added as a dependency, you can proceed with creating new databases, moving existing files, or performing other storage-related operations without encountering dependency errors. However, there are additional best practices to consider for optimal performance and management within your clustered environment.
Creating a New Database on the New Disk¶
With the new disk (e.g., drive Y:) properly configured, you can now use standard T-SQL commands to create a database on it. It’s good practice to separate data files (.mdf), log files (.ldf), and potentially other file types onto different physical disks or logical volumes for performance and manageability.
USE [master];
GO
CREATE DATABASE [NewDatabaseOnSharedDrive]
ON PRIMARY
(
NAME = N'NewDatabaseOnSharedDrive_Data',
FILENAME = N'Y:\SQLData\NewDatabaseOnSharedDrive_Data.mdf',
SIZE = 1024MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 256MB
)
LOG ON
(
NAME = N'NewDatabaseOnSharedDrive_Log',
FILENAME = N'Y:\SQLLogs\NewDatabaseOnSharedDrive_Log.ldf',
SIZE = 256MB,
MAXSIZE = 2048GB,
FILEGROWTH = 256MB
);
GO
Ensure that the directories (Y:\SQLData and Y:\SQLLogs in this example) exist and that the SQL Server service account has full control permissions on them. Pre-creating these directories enhances stability and avoids potential creation errors.
Moving Existing Database Files to the New Disk¶
Relocating existing database files is a common task, often performed to balance storage, improve performance, or consolidate data. This involves detaching the database, moving the files, and then reattaching it, or using the ALTER DATABASE ... MODIFY FILE command. For an online operation, ALTER DATABASE ... MODIFY FILE is preferred.
-- Move Data File
ALTER DATABASE [ExistingDatabase]
MODIFY FILE (
NAME = ExistingDatabase_Data,
FILENAME = 'Y:\SQLData\ExistingDatabase_Data.mdf'
);
GO
-- Move Log File
ALTER DATABASE [ExistingDatabase]
MODIFY FILE (
NAME = ExistingDatabase_Log,
FILENAME = 'Y:\SQLLogs\ExistingDatabase_Log.ldf'
);
GO
-- The changes take effect after the database is taken offline and brought back online,
-- or after the SQL Server instance is restarted.
-- For a database with high availability (AlwaysOn Availability Groups),
-- a restart or taking the database offline is not advisable.
-- Instead, the file move will be pending until the next graceful restart of the SQL Server service.
-- If the database can tolerate a brief outage:
ALTER DATABASE [ExistingDatabase] SET OFFLINE WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [ExistingDatabase] SET ONLINE;
GO
It is crucial to physically move the .mdf and .ldf files to the new Y:\SQLData and Y:\SQLLogs directories after executing the ALTER DATABASE commands. The ALTER DATABASE command merely updates the system catalog; the actual file movement is a manual step. For AlwaysOn Availability Groups, a planned failover or restart will apply these pending changes without manual file movement or offline commands.
Creating a Full-Text Catalog on the New Disk¶
If your applications rely on full-text search, creating catalogs on dedicated, fast storage is beneficial. The process is straightforward once the disk dependency is established.
USE [NewDatabaseOnSharedDrive];
GO
CREATE FULLTEXT CATALOG [FullTextCatalog_Y]
ON FILEGROUP [PRIMARY] -- or a specific filegroup
IN PATH 'Y:\FTDATA';
GO
Again, ensure that the Y:\FTDATA directory exists and has the correct permissions for the SQL Server service account before executing this command. This dedicated directory helps organize full-text indexes and potentially allows for different backup or recovery strategies.
General Best Practices for Clustered Storage¶
- Dedicated Volumes: For mission-critical databases, consider dedicating separate volumes for data files, log files, TempDB, and backups. This enhances performance by reducing I/O contention.
- TempDB Configuration: While TempDB is typically reset on SQL Server restart, its files should also reside on a fast, clustered disk. Configure TempDB files with appropriate size and growth settings, and ensure it uses multiple data files (one per CPU core, up to 8) to reduce allocation contention.
- Regular Monitoring: Continuously monitor disk I/O, latency, and available space on all shared volumes. Tools like Performance Monitor, SQL Server Dynamic Management Views (DMVs), and your storage array’s monitoring solutions are invaluable.
- Backup and Recovery Strategy: Ensure your backup strategy accounts for all new disk locations. Test your recovery procedures regularly to confirm data integrity and efficient restoration times.
- Documentation: Keep thorough documentation of your cluster configuration, including disk assignments, dependencies, and any custom settings. This is invaluable for troubleshooting and future maintenance.
For a visual guide on managing SQL Server failover clusters, including disk configuration, you might find this external resource helpful:

Please note: The video thumbnail and link above are illustrative. For actual content, search YouTube for “SQL Server Failover Cluster disk configuration” or “SQL Server FCI shared storage.”
Troubleshooting Common Issues¶
Even with careful planning, issues can arise during disk configuration. Here’s a brief guide to common problems and their potential solutions:
| Issue | Potential Cause | Resolution |
|---|---|---|
| Disk not visible in Cluster Manager | Physical connection issues, SAN zoning problems, disk not initialized/formatted. | Verify physical connections, check SAN zoning, ensure disk is initialized (GPT/MBR) and formatted (NTFS) on at least one node. Rescan for disks in Disk Management. |
| Permissions errors (SQL Server) | SQL Server service account lacks permissions on the new drive/folders. | Grant “Full Control” permissions to the SQL Server service account (e.g., NT Service\MSSQLSERVER or your domain account) on the root of the new drive and any subfolders created for data/logs. |
| Resource failed to come online | Incorrect dependency order, network issues, resource conflicts. | Review event logs for specific errors. Check resource dependencies for circular or missing links. Ensure all network resources (IP, Network Name) are functioning. |
| Failover takes too long/fails | Large database files causing long dismount/mount times, network latency. | Optimize disk I/O performance. Review cluster log for specific timeouts. Ensure network connectivity between nodes is robust. Consider increasing the LooksAliveThreshold and IsAliveThreshold for the SQL Server resource if brief network glitches are causing false failovers (with caution). |
CREATE DATABASE fails after config |
Permissions on new directory, directory doesn’t exist, file path typo in T-SQL. | Double-check directory existence and permissions. Verify the file paths in your CREATE DATABASE or ALTER DATABASE statements are correct and match the new drive letter. |
Always consult the Windows Event Viewer (System and Application logs) and the SQL Server Error Logs for detailed error messages. These logs are your primary source for identifying the root cause of any issues encountered.
Conclusion¶
Effectively managing SQL Server databases in a clustered environment requires a thorough understanding of resource dependencies and careful configuration. By correctly adding shared cluster disks as dependencies to your SQL Server resource within the Failover Cluster Manager, you ensure that your database operations proceed smoothly and maintain the high availability that an FCI is designed to provide. This process, while seemingly intricate, is fundamental to the stability and performance of your SQL Server deployment. Adhering to best practices for storage, monitoring, and regular testing will further enhance the resilience and efficiency of your mission-critical databases.
Do you have experience with modifying SQL Server cluster dependencies or troubleshooting related issues? Share your insights and challenges in the comments below – your experiences could help others in the community!
Post a Comment