Installing SQL Server Databases on SMB File Shares: Part 2

By Michael Otey on June 21, 2016


Since the release of Windows Server 2012 and SQL Server 2012,you now have the option of installing SQL Server databases on Windows Server SMB file Shares. You can do this for either standalone SQL Server installations or for clustered instances. In part 1, I provided an overview of the Windows Server SMB enhancements that made this possible and looked at some of the requirements and limitations of using SQL Server database on SMB file shares. In part 2, I’ll cover the more implementation details and you’ll see how to install a database on a file share.

Before diving straight into the details you might wonder what benefits there are to using SMB shares for SQL Server databases. There are a number of possible benefits for installing SQL Server databases on SMB file shares. Using SMB file shares can allow you to build a low-cost SQL Server cluster without the need for an expensive SAN.  SMB file shares can be very useful for databases that are small or databases that don’t have a lot of users or transactions. Databases that contain historical data can be another good candidate to place on an SMB as file shares are typically inexpensive storage locations. Another useful SMB implementation is for database migrations. If you have a database located on an SMB file share moving it to another SQL Server instance  can be as easy as detaching the database from the old instance and then attach to the new instance.

The process to install a database using SMB file shares is easy as specifying the file share’s UNC path instead of using a drive latter and path when you create the database.

Setting permissions on the File Share

In order for SQL Server to use the SMB files share the SQL Server Service must have The FULL CONTROL share permissions and NTFS permissions on the SMB share folders. Microsoft recommends that you use a domain account as the SQL Server service account. If system account is used as a service account then you need to grant the permissions for the machine account using the format: <domain_name>\<computer_name>$.
You can set the share permission using Server Manager or by using the NET SHARE command like you can see in the following example.
NET SHARE example=C:\FolderPath /GRANT:Everyone,Change /GRANT:Administrators,Full /UNLIMITED /CACHE

Using an SMB Share as the Default Data Directory

During SQL Server setup if you want to use an SMB file share as a storage option then you need to specify domain account for the SQL Server service. IF you want to use the System account then you must change it after the SQL Server installation process has completed.
To set the default data directory during the SQL Server setup use the Database Engine Configuration page then click on the Data Directories tab and specific the SMB file share UNC in the Data root directory prompt like \\FileServer\ShareName\.
If you are performing a command line installation then you need to specify the UNC value for the
/INSTALLSQLDATADIR prompt as \\FileServer\ShareName\ like you can see in the following example.

Setup.exe /q /ACTION=Install /FEATURES=SQL /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=”<DomainName\UserName>” /SQLSVCPASSWORD=”<StrongPassword>” /SQLSYSADMINACCOUNTS=”<DomainName\UserName>” /AGTSVCACCOUNT=”<DomainName\UserName>” /AGTSVCPASSWORD=”<StrongPassword>” /INSTALLSQLDATADIR=”\\FileServer\ShareName” /IACCEPTSQLSERVERLICENSETERMS

Creating Databases on SMB Shares

You can create databases on SMB file shares using either SQL Server Management Studio (SSMS) or by using the T-SQL CREATE DATABASE or ALTER DATABASE commands. Essentially you specify UNC paths for your data and log files like you can see in the following example.

CREATE DATABASE [MySMBDB] ON PRIMARY ( name = N'MyDB_data',
filename = N'\\WS2016-N0\DB\MyDB_data.mdf',
size = 3072kb, maxsize = unlimited,filegrowth = 1024kb )
log ON ( name = N'MyDB_log',
filename =N'\\WS2016-N0\DB\MyDB_log.ldf',
size = 1024kb, maxsize = 2048gb, filegrowth = 10%)
GO

You can see an example of creating database on an SMB file share using SSMS in Figure 2.

Figure SMB Files Part 2

Figure 2 – Creating Databases on SMB File Shares using SQL Server Management Studio

It’s important to remember that when you’re using SMB file shares for database storage the network performance is very important. Be sure to be running on the fastest network possible at least 1 GB and faster is better. In addition to reduce bandwidth contention consider using a dedicated network between SQL Server and the file servers housing the database files.

Related Posts

Leave a Reply