How to use Windows hosted file shares to support SQL Server containers

How to use Windows hosted file shares to support SQL Server containers

How to use Windows hosted file shares to support SQL Server containers

SQLShack

SQL Server training Español

How to use Windows hosted file shares to support SQL Server containers

February 23, 2017 by Paul Stanton In a previous article, Automate Delivery of SQL Server Production Data Environments Using Containers, we introduced SQL Server containers for delivery of production data environments to development and QA teams. In this article we look at the methods used for working with SQL Server data, and use of file shares to support delivery of production databases with containers.

In-container and Mounted Databases

Containers are SQL Server named instances configured and delivered with data in seconds. Each member of a team works with an isolated SQL Server container on a shared host. Containers can be discarded and replaced as needed. Rather than working with a score of VMs teams work with containers on a single host. The result is automated support for delivery of SQL Server environments for dev and QA, and a dramatic reduction in the number of VMs used, with associated VM maintenance and server license savings. SQL Server containers include a private file system. The first option for working with SQL Server databases is to copy the database files into the container file system. This is a popular approach for Dev/QA support of environments up to 300 to 400 GB. This method is effectively limited to mid-sized environments, due to the time and network bandwidth involved in the over the network copy of the files. Once the files are on the host, container creation speed is dictated by host IO performance. This method works well for many dev and QA teams. One downside is that the database is lost when the container is deleted. An alternative is to mount databases to the SQL Server container. Databases can be hosted on a File Server, Storage Array Network (SAN) array, or other storage system. Each container requires a dedicated file or mount point, so snapshots, copies, or clones are required for each container. Many storage systems can create writeable snapshots in seconds, which enables a 1 TB database to be delivered mounted to a container in seconds. This method is preferred for working with large data environments, as it avoids over-the-network file copies. And, the database persists beyond the container, so is preferred for production environments and whenever data persistence is needed.

NFS for Secure File Sharing of Production Data Environments

There are many different file servers and NAS storage solutions. One approach that works well is NFS file sharing between Windows Servers. This approach enables secure support for container creation and mounting of databases to a known container host. In the following step by step instructions are for two Windows Server 2012 hosts, on a shared domain. The following assumes that the two servers have been enabled with NFS services. Start by opening Windows Server Manager and select the file server host, File and Storage Services, Shares, and use the Task dropdown to select a “New Share,” as highlighted below. Select “NFS Share – Advanced.” For Authentication, select “Enable unmapped user access, by UID/GID”. Enter the container host that will be provided access to the file share. Note the permissions! Review permissions and choose either Full Control, or Read access as needed. The Share setup also allows for varied types and files. Select “Create” and see the confirmation of the Share setup. Open File Explorer and navigate to the share created, right-click and select Properties. Select the “Share” tab, select “share” and enable permissions for Everyone. Remember to click “Apply.” On the same share select the “Security” tab, and confirm appropriate user rights on the files. No changes should be needed. In a final step, select the “NFS Sharing” tab, which summarizes the share setup. The only machine provided access to the new Share is the Support1 machine users. We now have a secure method for supporting File Shares for a SQL Server container host. This method supports the use of the MOUNTDB command. Be sure to consider network performance. A dedicated high speed LAN is a recommended.

Workgroup File Sharing Support

While the solution outlined above is preferred, an alternative approach supports workgroup networks. The following configures a shared folder on a private network with Anonymous access. Select folder properties, Sharing tab and click on Advanced Sharing. Select “Share this folder, and click on Permissions. Open Group Policy Editor (Windows key +R, type gpedit.msc and hit enter). Navigate to Computer Configuration — Windows Settings — Security Options. Make the following changes: Enable “Accounts: Guest account status” Enable “Network access: Let Everyone permissions apply to anonymous users” Disable “Network access: Restrict anonymous access to Named Pipes and Shares” As a final step, enter the name of the share you created in “Network access: Shares that can be accessed anonymously” Now that the Group Policies are updated, open File Explorer, navigate to the shared folder, and select the Sharing tab, select Advanced Sharing, and click on “Share this folder.” Everyone should be listed, add Guest and ANONYMOUS LOGON and assign Read or Full Access.
Once completed, the \\\Share will support the anonymous access to files that can be mounted to SQL Server containers.

Conclusions

The approaches outlined above, and particularly the NFS share, provides practical methods for delivering mounted SQL Server environments for Dev and QA use. The examples are based on the WinDocks Community Edition, a free downloadable edition from WinDocks. WinDocks is an independent port of Docker’s open source to Windows, supporting all editions of Windows 8, Windows 10, Windows Server 2012, and Windows Server 2016. WinDocks also supports all editions of SQL Server 2008 onward. Download your own copy and explore the use of SQL Server containers here. Full disclosure, I am a principal at WinDocks. The same approach should also work with Microsoft’s container implementation that is built into Windows Server 2016, and Pro and Enterprise editions of Windows 10. Microsoft’s plans for SQL Server container support appear to be focused on SQL Server vNext. At the time of this article the only SQL Server images available for Microsoft’s containers are SQL Server 2016 Express and SQL Server vNext. The NFS based file share supports the mounting of databases to containers, or can be a secure source for files copied for “in-container” use. Below we see the end result of a mounted database. SQL Management Studio shows the mounted database dbtest, and File Explorer view confirms the files are not in the container file system. The container can be stopped, restarted, or deleted, and the database files can be freed for use by another container. For further reading on the use of SQL Server containers, refer to the links below.

References

WinDocks Community Edition Windows Containers Compared: WinDocks vs Microsoft Get Started with SQL Server containers Microsoft Container Image Support
Author Recent Posts Paul StantonPaul is a co-founder of WinDocks, and is focused on delivering the best container support for the SQL Server Professional community. He is a former Director at Microsoft, and was involved in early internetworking and cross platform solutions for Windows NT.

He loves to write and is a frequent contributor to technical web sites. He has recently expanded his focus to enable SQL Server containers as part of a Continuous Integration and DevOps process.

View all posts by Paul Stanton Latest posts by Paul Stanton (see all) How to use Windows hosted file shares to support SQL Server containers - February 23, 2017 Automate Delivery of SQL Server Production Data Environments Using Containers - January 12, 2017

Related posts

Automate Delivery of SQL Server Production Data Environments Using Containers Running SQL Server Containers on Windows Server 2016 Core Understanding Backup and Restore operations in SQL Server Docker Containers Refreshing SQL Server Containers automatically with Watchtower Windocks; Database cloning for SQL Server dev/test on “live” production data 11,272 Views

Follow us

Popular

SQL Convert Date functions and formats SQL Variables: Basics and usage SQL PARTITION BY Clause overview Different ways to SQL delete duplicate rows from a SQL Table How to UPDATE from a SELECT statement in SQL Server SQL Server functions for converting a String to a Date SELECT INTO TEMP TABLE statement in SQL Server SQL WHILE loop with simple examples How to backup and restore MySQL databases using the mysqldump command CASE statement in SQL Overview of SQL RANK functions Understanding the SQL MERGE statement INSERT INTO SELECT statement overview and examples SQL multiple joins for beginners with examples Understanding the SQL Decimal data type DELETE CASCADE and UPDATE CASCADE in SQL Server foreign key SQL Not Equal Operator introduction and examples SQL CROSS JOIN with examples The Table Variable in SQL Server SQL Server table hints – WITH (NOLOCK) best practices

Trending

SQL Server Transaction Log Backup, Truncate and Shrink Operations Six different methods to copy tables between databases in SQL Server How to implement error handling in SQL Server Working with the SQL Server command line (sqlcmd) Methods to avoid the SQL divide by zero error Query optimization techniques in SQL Server: tips and tricks How to create and configure a linked server in SQL Server Management Studio SQL replace: How to replace ASCII special characters in SQL Server How to identify slow running queries in SQL Server SQL varchar data type deep dive How to implement array-like functionality in SQL Server All about locking in SQL Server SQL Server stored procedures for beginners Database table partitioning in SQL Server How to drop temp tables in SQL Server How to determine free space and file size for SQL Server databases Using PowerShell to split a string into an array KILL SPID command in SQL Server How to install SQL Server Express edition SQL Union overview, usage and examples

Solutions

Read a SQL Server transaction logSQL Server database auditing techniquesHow to recover SQL Server data from accidental UPDATE and DELETE operationsHow to quickly search for SQL database data and objectsSynchronize SQL Server databases in different remote sourcesRecover SQL data from a dropped table without backupsHow to restore specific table(s) from a SQL Server database backupRecover deleted SQL data from transaction logsHow to recover SQL Server data from accidental updates without backupsAutomatically compare and synchronize SQL Server dataOpen LDF file and view LDF file contentQuickly convert SQL code to language-specific client codeHow to recover a single table from a SQL Server database backupRecover data lost due to a TRUNCATE operation without backupsHow to recover SQL Server data from accidental DELETE, TRUNCATE and DROP operationsReverting your SQL Server database back to a specific point in timeHow to create SSIS package documentationMigrate a SQL Server database to a newer version of SQL ServerHow to restore a SQL Server database backup to an older version of SQL Server

Categories and tips

►Auditing and compliance (50) Auditing (40) Data classification (1) Data masking (9) Azure (295) Azure Data Studio (46) Backup and restore (108) ►Business Intelligence (482) Analysis Services (SSAS) (47) Biml (10) Data Mining (14) Data Quality Services (4) Data Tools (SSDT) (13) Data Warehouse (16) Excel (20) General (39) Integration Services (SSIS) (125) Master Data Services (6) OLAP cube (15) PowerBI (95) Reporting Services (SSRS) (67) Data science (21) ►Database design (233) Clustering (16) Common Table Expressions (CTE) (11) Concurrency (1) Constraints (8) Data types (11) FILESTREAM (22) General database design (104) Partitioning (13) Relationships and dependencies (12) Temporal tables (12) Views (16) ►Database development (418) Comparison (4) Continuous delivery (CD) (5) Continuous integration (CI) (11) Development (146) Functions (106) Hyper-V (1) Search (10) Source Control (15) SQL unit testing (23) Stored procedures (34) String Concatenation (2) Synonyms (1) Team Explorer (2) Testing (35) Visual Studio (14) DBAtools (35) DevOps (23) DevSecOps (2) Documentation (22) ETL (76) ►Features (213) Adaptive query processing (11) Bulk insert (16) Database mail (10) DBCC (7) Experimentation Assistant (DEA) (3) High Availability (36) Query store (10) Replication (40) Transaction log (59) Transparent Data Encryption (TDE) (21) Importing, exporting (51) Installation, setup and configuration (121) Jobs (42) ►Languages and coding (686) Cursors (9) DDL (9) DML (6) JSON (17) PowerShell (77) Python (37) R (16) SQL commands (196) SQLCMD (7) String functions (21) T-SQL (275) XML (15) Lists (12) Machine learning (37) Maintenance (99) Migration (50) Miscellaneous (1) ►Performance tuning (869) Alerting (8) Always On Availability Groups (82) Buffer Pool Extension (BPE) (9) Columnstore index (9) Deadlocks (16) Execution plans (125) In-Memory OLTP (22) Indexes (79) Latches (5) Locking (10) Monitoring (100) Performance (196) Performance counters (28) Performance Testing (9) Query analysis (121) Reports (20) SSAS monitoring (3) SSIS monitoring (10) SSRS monitoring (4) Wait types (11) ►Professional development (68) Professional development (27) Project management (9) SQL interview questions (32) Recovery (33) Security (84) Server management (24) SQL Azure (271) SQL Server Management Studio (SSMS) (90) SQL Server on Linux (21) ►SQL Server versions (177) SQL Server 2012 (6) SQL Server 2016 (63) SQL Server 2017 (49) SQL Server 2019 (57) SQL Server 2022 (2) ▼Technologies (334) AWS (45) AWS RDS (56) Azure Cosmos DB (28) Containers (12) Docker (9) Graph database (13) Kerberos (2) Kubernetes (1) Linux (44) LocalDB (2) MySQL (49) Oracle (10) PolyBase (10) PostgreSQL (36) SharePoint (4) Ubuntu (13) Uncategorized (4) Utilities (21) Helpers and best practices BI performance counters SQL code smells rules SQL Server wait types © 2022 Quest Software Inc. ALL RIGHTS RESERVED. GDPR Terms of Use Privacy
Share:
0 comments

Comments (0)

Leave a Comment

Minimum 10 characters required

* All fields are required. Comments are moderated before appearing.

No comments yet. Be the first to comment!