Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inside SQL Server Containers

Similar presentations


Presentation on theme: "Inside SQL Server Containers"— Presentation transcript:

1 Inside SQL Server Containers
4/26/2019 7:53 PM Inside SQL Server Containers Bob Ward, Principal Architect, Microsoft © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Session learning objectives
4/26/2019 Session learning objectives At the end of this session, you should be better able to… Fundamental of Containers and why you would use them How SQL Server Containers work under the covers How to customize, update, and use SQL Server for updates and upgrades BONUS MATERIAL: Learn the fundamentals of SQL Server with Kubernetes

3 4/26/2019 7:53 PM Can you Docker? © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 Container configuration
4/26/2019 7:53 PM Why Containers? Portable Run anywhere Docker is supported Lightweight Reduced disk, CPU, and memory footprint Consistent Consistent image of SQL Server, scripts, and tools Efficient Faster deployment, reduced patching, and less downtime Container configuration Persisted storage Database Switch for simple upgrades Infrastructure Host OS Bins/libs sqlservr Docker Container Bins/libs sqlservr Container Bins/libs sqlservr Container © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Image Container Containers Explained
4/26/2019 7:53 PM VM = emulate hardware and load entire OS Containers = isolation but cooperate with host kernel Containers Explained Image Layered snapshot of a set of files structured in a filesystem Built with a Dockerfile using docker build or APIs Most built with a base image of an OS The base image OS must be the same kernel as host Container Runtime instance of an image Run as many you like based on the same image Isolated but can communicate with the “outside” Has access by default to all CPU and memory resources Each container has writeable layer but share read-only image layer Start and stop do not affect writeable layer Remove deletes writeable layer Volumes provide persistence on host © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 The Docker Container lifecycle
4/26/2019 7:53 PM The Docker Container lifecycle Dockerfile SQL Mac Challenge © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 Under the Covers OCI Namespace Union File System (UnionFS)
4/26/2019 7:53 PM OCI Under the Covers docker libcontainer Linux Kernel Namespace process, network, and other resource isolation Union File System (UnionFS) layered file system Control Groups (cgroups) accounting, governance, notifications Great explanation here at namespaces Use the lsns command as root to see created namespaces Other resources © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

8 SQL Server Containers 4/26/2019 7:53 PM
© Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

9 SQL Server Images Public Registries SQL Server 2017
4/26/2019 7:53 PM SQL Server Images SQL Server Engine pre-installed SQL Server tools pre-installed See here how to add other packages Database and application compatibility Public Registries Docker Hub ( Red Hat Container Catalog ( The Microsoft Container Registry (mcr.microsoft.com) SQL Server 2017 Ubuntu based Images RTM plus each CU and GDR has separate image Includes mssql-server and mssql-tools packages SQL Server 2019 Preview images Ubuntu and RHEL based images Includes mssql-server and mssql-tools © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 Running a SQL Server Container
4/26/2019 7:53 PM Running a SQL Server Container environment variables (Ex. enable SQLAgent) sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Sql2017isfast’ -p 1401:1433 -v sqlvolume:/var/opt/mssql --hostname sql1 --name sql1 -d mcr.microsoft.com/mssql/server:2017-CU8 Your app connects to port 1401 Map default directory to host volume for persisted storage @SERVERNAME Use with docker client Run process in background. Remove this to debug SQL Server 2017 CU8 image © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 How do I update a SQL Server Container?
4/26/2019 7:53 PM How do I update a SQL Server Container? Interacting with Data Use your normal T-SQL and app to modify data Copy into the container a database backup and restore it Use volumes or your changes will be lost if container removed Configuration changes for SQL Server Use the environment variables (mssql-conf) Modify the container directly Build a new image with your scripts to make changes sp_configure ALTER SERVER CONFIGURATION © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 Demo SQL Containers in Action
4/26/2019 7:53 PM Demo SQL Containers in Action Follow the steps from © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

13 The SQL Server DockerFile
4/26/2019 7:53 PM The SQL Server DockerFile You typically map another port with docker run FROM <ubuntu or rhel base image> LABEL < Microsoft label information > EXPOSE 1433 COPY < SQL Server binaries and libraries > RUN ./install.sh CMD ["/opt/mssql/bin/sqlservr”] /opt/mssql/bin /opt/mssql/lib BUILD Install dependent packages and tools RUN SQL Server Docker Files on GitHub Dockerfile reference Dockerfile best practices Running SQL Server handles the rest © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 How does the SQL Server Container Work?
4/26/2019 7:53 PM How does the SQL Server Container Work? Image image contains binaries, libraries, and packages (*.sfp) /var/opt/mssql doesn’t exist Set ACCEPT_EULA, MSSQL_SA_PASSWORD, and MSSQL_PID (optional) Start SQL Server from the command line as follows: /opt/mssql/bin/sqlservr sqlservr forks sqlservr env variables used as startup parameters /var/opt/mssql structure created and populated System databases and files extracted from .sfp files Engine now runs as a process © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Multi-instance SQL Servers using Containers
4/26/2019 7:53 PM Multi-instance SQL Servers using Containers CPU Set affinity with --cpuset Or use SQL Server ALTER SERVER CONFIGURATION Container CPU weights and quotas Or use SQL Server Resource Governor Memory Restrict maximum memory with –-memory Or use mssql-conf memorylimitmb Or use ‘max server memory’ with sp_configure Network (same server) Default bridge network allows communication via IP address User defined bridge network provides name resolution Useful for repl and DTC © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

16 Building your own image
4/26/2019 7:53 PM Then RESTORE the backup after you start the container Building your own image FROM mcr.microsoft.com/mssql/server:2017-latest COPY ./yourbackup.bak /var/opt/mssql/data/yourbackup.bak CMD ["/opt/mssql/bin/sqlservr"] Docker compose ddl.sql CREATE DATABASE mydb GO CREATE TABLE mytable (…. …. The “Vin Yu” method FROM mcr.microsoft.com/mssql/server:2017-latest COPY . / RUN chmod +x /db-init.sh CMD /bin/bash ./entrypoint.sh db-init.sh sleep 15s /opt/mssql-tools/bin/sqlcmd –iddl.sql entrypoint.sh /db-init.sh & /opt/mssql/bin/sqlservr See here how to add other packages © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

17 But how do I patch and upgrade?
4/26/2019 7:53 PM SQL Server 2017 CU8 Container But how do I patch and upgrade? volume rollback SQL Server 2017 Latest Container update SQL Server databases SQL Server 2019 Container upgrade © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

18 Volume and SQL Server Containers Explained
4/26/2019 7:53 PM Volume and SQL Server Containers Explained SQL1 and SQL2 cannot access same db at same time 1 docker stop SQL1 SQL1 running SQL Server docker start SQL1 db Host Storage Host Storage Volume SQL1 files 3 docker stop SQL1 db db docker rm SQL1 SQL2 files SQL2 running SQL Server 4 2 db docker stop SQL1 docker stop SQL1 docker start SQL2 docker rm SQL1 © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

19 Demo Volumes and Updating SQL Server Containers
4/26/2019 7:53 PM Demo Volumes and Updating SQL Server Containers Follow the steps from © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Tech Ready 15 4/26/2019 Session takeaways Containers are portable, lightweight, consistent, and efficient Using containers for SQL Server provides a new method for database containers complimenting a DevOps methodology. Deploy SQL Server containers on docker for Windows, Linux, or macOS Learn how SQL Server containers supports the DevOps model Understand how containers provides a new method for updates for SQL Server © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Session resources Getting Started GitHub repo
Tech Ready 15 4/26/2019 Session resources Getting Started GitHub repo Vin Yu Ignite talk on Containers and DevOps Docker: Up and Running by Matthias and Kane Managing Kubernetes by Tracey and Burns K8s Training Course Anthony Nocentino pluralsight course on k8s Brendan’s whiteboard sessions on k8s © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

22 Questions? aka.ms/SQLBits19 4/26/2019 7:53 PM
© Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Bonus Material

24 FAQ Q: How does Licensing Work?
4/26/2019 7:53 PM FAQ Q: How does Licensing Work? A: Same as VMs. See our licensing guide at Q: Is there performance overhead? A: Not due to container. You should expect the same performance as running on bare metal or in VMs. Q: Can I use containers in production? A: Yes, read these docs on how, Q: Can I use Availability Groups? A: Yes, see this doc page AGs and k8s. Q: Can I integrate Active Directory with SQL on Containers A: Only SQL Authentication is supported at this time. Active Directory authentication is being explored for future support. © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

25 SQL Server and Kubernetes
4/26/2019 7:53 PM SQL Server and Kubernetes © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

26 Kubernetes (k8s) in a nutshell
4/26/2019 7:53 PM Kubernetes (k8s) in a nutshell Your application Cluster Node Node Load balancer Pod Pod SQL Server Node container Pod Another Program operator Pod Pod container SQL Server container Another Program Persistent Volume Storage © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

27 Let’s hear from an expert on k8s
Container and k8s course Let’s hear from an expert on k8s

28 k8s implementations minikube Kubeadm RedHat OpenShift
Get the full list here k8s implementations minikube Single node on your laptop Kubeadm Install your own cluster RedHat OpenShift K8s platform private or public cloud Azure Kubernetes Service (AKS) Azure hosted k8s OpenShift on Azure (OSA) Managed OpenShift on Azure Other Azure Stack Windows Server

29 SQL Server - Shared storage HA in Kubernetes
Built-in HADR orchestration with no clustering required Kubernetes Node Node Node Pod Load Balancer Service Pod SQL Server SQL Server User Pod SQL Server Persistent Volume Storage

30 SQL Server 2019 Always On Availability Groups on Kubernetes
4/26/2019 7:53 PM SQL Server Always On Availability Groups on Kubernetes Availability groups on Kubernetes Kubernetes cluster Node Pod Operator Load balancer Reporting app SQL Server/k8s failover integration Operator deployment AG concepts all apply Load Balancer for Primary App Load Balancer for Secondary Replica Readers Node Node Node Pod Pod Pod AG SQL Server secondary SQL Server primary SQL Server primary SQL Server secondary SQL Server secondary Presenter: Vin AG agent AG agent AG agent Load balancer Primary app © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Inside SQL Server Containers"

Similar presentations


Ads by Google