Upload
solarwinds
View
32
Download
0
Embed Size (px)
Citation preview
Hi! Ho! Hi! Ho! SQL Server on Linux We Go!Janis Griffin, Database Performance Evangelist, SolarWinds
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
Who Am I
• Senior DBA / Performance Evangelist for SolarWinds• [email protected]• Twitter® - @DoBoutAnything• Current – 25+ Years in Oracle®, DB2®, ASE, SQL Server®, MySQL®• DBA and Developer
• Specialize in Performance Tuning• Review Database Performance for Customers and Prospects
• Common Question – How do I tune it?
• Excited about SQL Server on Linux!• Opens up a whole new area to explore
• Why Put SQL Server on Linux & Docker• Distributions, Architecture & Licensing• How to Install, Backup & Maintain
• Several Linux Commands• SQLCMD
• Client Connectivity & Tools• SQL Operations Studio
• Demo• Summary
Agenda
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• IT Landscape is Constantly Changing• Many OSs (Linux, Windows, etc.), different languages, multiple data types• Mix of on-premises/cloud/hybrid environments• Complex environments can challenge IT to:
• Require specific skill sets (personnel)• Reduce operational costs
• Microsoft has committed to providing interoperability to open source• Gives industry leading performance & security• TPC benchmark stats for SQL Server 2017 on Linux
• http://www.tpc.org/tpch/results/tpch_result_detail.asp?id=117041701
• Security supports Active Directory authentication • Single sign-on with no password• Uses domain credentials and Kerberos protocol
Why SQL Server 2017 on Linux & Docker?
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Redhat 7.3 or 7.4• Red Hat Enterprise Linux• Oracle Enterprise Linux• CentOS
• SuSE v12 SP2• SUSE Enterprise Linux
• Debian 16.04• Ubuntu Server• Ubuntu Workstation
• Docker Engine 1.8+• For Mac & Linux
• SQL-server-linux-setup
Distributions & Architecture
SQLPAL = SQL
Platform
Abstraction
Layer
microsoft.blog.sql-server-on-linux-how-introduction
• Three Main Editions – Express, Standard & Enterprise• Rewritten so there is common programming across all editions
• Develop once and purchase different editions to scale
• Developer & Test edition include Enterprise features
• Buy same SKUs and get rights to run on both Windows & Linux• SQL Server Software Assurance Benefits (SA)
• Standard / Enterprise • Next version rights • License Mobility to shared 3rd party servers• Fail-Over servers for high availability
• Enterprise • Machine Learning Server for Hadoop
• https://blogs.technet.microsoft.com/dataplatforminsider/2017/09/26/in-database-machine-learning-in-sql-server-2017/
• Power BI Report Server
• Need to acquire when buying initial license – can’t add later
SQL Server 2017 Licensing
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• License Mobility• Requires SA on licenses running the workload• Deploy your workload only to authorized Mobility Partners
• Fail-Over servers for high availability• Combined with license mobility, provides full flexibility on dedicated or 3rd party
• For planned or unplanned downtime
• Secondary/passive SQL server is granted through SA• Without SA, both active & passive servers need to be licensed• 90 day reassignment rule is waived due to License Mobility SA benefits
• Limited Time Special Offer Runs October 2nd – June 30th, 2018• Red Hat & Microsoft have created a promotion
• New orders for RHEL Enterprise Linux for use on SQL Server 2017• Webinar - SQL Server 2017 Pricing & Licensing Microsoft Engineering Town Hall
SQL Server 2017 Licensing – Cont.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• / = Root• Every single file & directory starts here• Only ‘root’ user has write privilege • /root is ‘root’ user’s home directory
• Not the same as /
• /var = Variable Files• Files can grow under this directory • SQL Server default directory
• /var/opt/mssql• Holds log and config files
• Also system log files, database files, etc
• /opt = Optional add-on Applications• Holds SQL Server application (default)
• /opt/mssql/bin• /opt/msql/lib
Linux Directory Structure
• Directory != Drive• /var/opt/mssql/data can be on different device than /var/opt/mssql/log
• A ‘mssql’ user & ‘mssql’ group is automatically setup on install• Home directory is /home/mssql • Application files are owned by ‘mssql’
• Some commands need ‘sudo’ privileges• ‘sudo’ means ‘Super User Do’
• Linux is case sensitive• ‘hello world’ != ‘HELLO WORLD’
• Hidden files are prefaced with a dot• .bash_profile
• Bash Shell is common command language• Built from Bourne shell with added plugins (Bourne Again Shell)• Used for scripting
More About Linux
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• ls -ltra• List directory contents (i.e. ls –ltra /var/opt/mssql)• -l = long listing –t = sort newest first –r = reverse –a all files
• cd • Change directory (i.e. cd /var/opt/mssql/log)
• ps –ef• Displays active processes (i.e. ps –ef | grep sql)• -e = every process –f = full format listing• top = interactive view
• grep• Seaches files or standard output for pattern matching
• Example: history | grep –i mssql-conf
• man• Interface to on-line reference manuals (i.e. man ps)
Useful Linux Commands
A great way to get familiar with
Linux commands is to download:
http://www.cygwin.com/
Provides functionality similar to a
Linux distribution on Windows.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• PUTTY – free SSH & Telnet Client• https://www.ssh.com/ssh/putty/download
• Login as root or sudosudo curl -o /etc/yum.repos.d/mssql-server.repohttps://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
sudo yum install -y mssql-server
Installing Sql Server 2017 On Centos 7
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
sudo yum install -y mssql-server
Installing SQL Server 2017 on Centos 7 – cont.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
sudo /opt/mssql/bin/mssql-conf setup
Installing SQL Server 2017 on Centos 7 – cont.
systemctl status mssql-server
Installing SQL Server 2017 on Centos 7 – cont.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
sudo yum install -y mssql-tools unixODBC-devel
Installing MSSQL-Tools on Centos 7
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• SQL Command line Interface• ‘sqlcmd -?’ shows all parameters• Connect using
• Localhost• IP address• IP address, port
• Run a script at command linesqlcmd -S 10.199.8.172,1433 -U sa \
-i waits.sql -o waits.log
SQLCMD
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Must first install SQL Server 2017 reposudo yum install mssql-server-agent
sudo systemctl restart mssql-server
Installing SQL Server Agent on Centos 7
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Can use Docker for Linux/Mac/Windows • Installs in /var/lib/docker – can create symbolic links• Use if you want to run multiple instances on same server
• Download Docker for Centos
• Install Docker
• Start Docker
• Test Docker
Installing SQL Server 2017 Container Image with Docker
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
sudo yum install ./docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
systemctl start docker
sudo docker run hello-world
Docker provides an additional layer of
abstraction & automation at the operating-
system-level. It can package an application &
its dependencies in a virtual container. This
helps enable flexibility & portability to run on-
premises, public & private cloud, bare metal,
etc.
• Get SQL Server for Linux
• Create container called sql1
• Access via docker command
• Access via sqlcmd
SQL Server 2017 Container Image with Docker – cont.
sudo docker pull microsoft/mssql-server-linux:2017-latest
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Mys3cr3tpazz' -p 1433:1433 \
--name=sql1 –v sql1:/var/opt/mssql -d microsoft/mssql-server-linux:2017-latest
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S 10.199.8.172 -U sa -P Mys3cr3tpazz
sqlcmd -S 10.199.8.172,1433 -U sa -P Mys3cr3tpazz
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• docker ps –a• Show list of containers
• docker container <start / stop> <container_name>• docker container rm <container_name>
• BEWARE! This will remove the sql server instance
• docker container stats • List CPU, Memory, I/O Stats for each container
• docker volume ls • Shows volume names
• docker volume inspect <volume_name>• Shows name and location of data
Useful Docker Commands
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Make a directory for backupsdocker exec -it sql1 mkdir /var/opt/mssql/backup
• Download example databasesudo curl -L -o wwi.bak \
'https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak‘
• Copy backup of example database to new backup directorydocker cp wwi.bak sql1:/var/opt/mssql/backup
• List files from backupdocker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost \-U SA -P 'Mys3cr3tpazz' \-Q 'RESTORE FILELISTONLY FROM DISK = "/var/opt/mssql/backup/wwi.bak"' \
| tr -s ' ' | cut -d ' ' -f 1-2
Backup & Restore In Docker
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Restore from backupdocker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P 'Mys3cr3tpazz' \-Q 'RESTORE DATABASE WideWorldImporters FROM DISK = "/var/opt/mssql/backup/wwi.bak" WITH MOVE
"WWI_Primary" TO "/var/opt/mssql/data/WideWorldImporters.mdf", MOVE "WWI_UserData" TO "/var/opt/mssql/data/WideWorldImporters_userdata.ndf", MOVE "WWI_Log" TO "/var/opt/mssql/data/WideWorldImporters.ldf", MOVE "WWI_InMemory_Data_1" TO "/var/opt/mssql/data/WideWorldImporters_InMemory_Data_1"'
Restore & Backup In Docker – cont.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \-S localhost -U SA -P 'Mys3cr3tpazz' \-Q "BACKUP DATABASE [WideWorldImporters] TO DISK =
N'/var/opt/mssql/backup/wwi_20171127.bak' WITH NOFORMAT, NOINIT, NAME = 'WideWorldImporters-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10“
docker cp sql1:/var/opt/mssql/backup/wwi_20171127.bak /backup/wwi_20171127.bak
Backup & Copy Files Out of Container
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Command-line Tools• sqlcmd & bcp
• SSMS• Connect remotely from Windows• Includes PowerShell
• Visual Studio Code• How-to-develop-use-vscode
• SQL Server Data Tools (SSDT)• For Visual Studio • Build project on Windows
• Deploy to Linux
• SQL Operations Studio • Installs on Linux/Windows/MacOS• GUI interface – sqlops
https://docs.microsoft.com/en-us/sql/sql-operations-studio/download
Client Connectivity & Tools
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Many different libraries or drivers for Linux/Windows/MacOS• Step by step how-to:
• https://www.microsoft.com/en-us/sql-server/developer-get-started/
Client Connectivity & Tools – cont.
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• Terminal• Top • Directory Structure• SQLCMD• Docker Commands• Create an instance
• SSMS• SQLOps
Demo
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
• SQL Server 2017 (Linux/Windows/MacOS)• Can help with the ever changing landscape of IT organizations• Develop applications once
• Developer & Test editions contain all enterprise features
• But deploy & scale on-premises, in the cloud or run a hybrid solution
• Microsoft has committed to open source communities • Providing many different client libraries to run Linux/Windows/Docker• Making licensing simple
• Buy same SKUs and get rights to run on both Windows & Linux
• Easy to install, backup & maintain• Need to learn a few Linux / Docker commands• sqlcmd & bcp• SSMS & sqlops
Summary
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
www.solarwinds.com/dpa-download/
Resolve Performance Issues quickly—Free Trial
• Try Database Performance Analyzer FREE for 14 days
• Improve root cause of slow performance
o Quickly identify root cause of issues that impact end-user response time
o See historical trends over days, months, and years
o Understand impact of VMware® performance
o Agentless architecture with no dependence on Oracle Packs, installs in minutes
© 2017 SolarWinds Worldwide, LLC. All rights reserved.
The SolarWinds, SolarWinds & Design, Orion, and THWACK trademarks are the exclusive
property of SolarWinds Worldwide, LLC or its affiliates, are registered with the U.S.
Patent and Trademark Office, and may be registered or pending registration in other
countries. All other SolarWinds trademarks, service marks, and logos may be common
law marks or are registered or pending registration. All other trademarks mentioned
herein are used for identification purposes only and are trademarks of (and may be
registered trademarks) of their respective companies.