Migrating SQL Server Databases to Containers On Pure Storage


Introduction

 In this bog I will demonstrate how we can migrate an existing SQL Server database running on either a Bare Metal or Virtualised environment to a container platform running on Pure Storage and the Pure Storage Plugin.

Overview of Environment

Source environment
  • Virtual machine on ESX 7
  • Windows 2016
  • SQL Server 2016
  • SSMS 18.4
  • Database - Demo 
Target Environment
  • Docker 19.03
  • Oracle Linux 7.6
  • Pure Storage Plugin 3.10


Step 1 - Backup Source DB


I am using SSMS UI to backup the database for this example, you can just as easily backup the
database using T-SQL.

Lets Select some data in the table before we backup, so we can compare it to after we migrate to the container





















  • Backup up the Database














Step 2 - Copy DB backup    


Once we have completed the database backup we need to copy it over the docker host, I'm not covering the copy process in this blog, however if you have any questions please feel free to contact me at cbannayan@purestorage.com

Step 3 - Create a new SQL Server Container

  • Create a new persistent volume called sqldemo of size 100G for the SQL container




  • Confirm the volume is created on the FlashArray


  • Let's create the container using the persistent volume






    • Container name: sqldemo
    • volume:              sqldemo
    • port:                   1427
    • SQL Server:       2019

  • let's log onto the container and confirm our volume is mounted


As we can see, the volume is mounted on /var/opt/mssql with the same serial number "484e" as the volume listing on the array

  • Let's log into the container and confirm it's up and running, as you can see we have only the default databases




Step 4 - Copy the backup to the container and restore







  • Lets log into the container and restore the database
RESTORE DATABASE demo FROM DISK = N'/var/opt/mssql/backup/demo.bak' \ 
WITH RECOVERY, MOVE  'demo' TO N'/var/opt/mssql/data/demo.mdf', MOVE \ 
'demo_log' TO N'/var/opt/mssql/backup/demo_log.ldf'



  • Confirm the database has been restore, as you can see the demo database has been restored

  • Lets confirm the data in the database is the same as the source DB


from the table output we can confirm out data matches the table in source database, lets do
a row count to double check


Container:



Source Database:



Step 5 - Now lets Clone the Container


So now that we have migrated the database to the container, this container can now become our GOLD image, from here we can create copies/clones for developers and testers. Using the Pure Storage plugin we will now create a clone of the production container.

  • Let's clone the production sqldemo volume








You can see from the above output that we have create a new clone volume called sqldemo-clone which has it's source as sqldemo

  • Now lets create a new clone container called sqldemo-clone using the clone volume sqldemo-clone








  • Lets log into the new container and confirm our production database exists, notice we have used he new port number 1425 which we used to create the new clone container













Summary

In this blog we have seen how we can migrate an existing production or Source SQL Server Database to a container, whilst production configurations may vary and some may not be fit for containerisation, the ones that are can be done quite easily as shown. Using the Pure Storage Container plugin we have demonstrated how quickly and easily we can clone and create multiple copies of the source database.

More and More organisations are adopting or planning a Container/Kubernetes strategy, Using Pure Storage provides the foundation for the strategy.

Note: Please see my other blogs on configuring SQL Server with containers.

http://bannaych.blogspot.com/2020/04/mssql-server-on-docker-with-pure.html

http://bannaych.blogspot.com/2020/05/cloning-sql-server-containers-with-pure.html









Comments

Popular posts from this blog

Oracle Containers on Kubernetes and Pure Service Orchestrator

SQL Server container with Pure Storage Docker volumes

Using Portainer to Manage and Deploy Oracle Containers with Pure Storage