340 likes | 473 Views
Automating SQL Buildouts With Hyper-V and SQL Server 2008 R2. Robert L Davis, Sr. DBA, Microsoft Corp. Agenda. Introduction: Who am I?. @SQLSoldier. 10+. www.sqlsoldier.com. SysPrep for SQL Server 2008 R2. Now supported in R2 Two step process Prepare image Complete image
E N D
Automating SQL BuildoutsWithHyper-V and SQL Server 2008 R2 Robert L Davis, Sr. DBA, Microsoft Corp.
Introduction: Who am I? @SQLSoldier 10+ www.sqlsoldier.com
SysPrep for SQL Server 2008 R2 Now supported in R2 Two step process • Prepare image • Complete image Prepare image once Save as a VHD Complete image as often as you like Complete walkthrough online on my blog: http://www.sqlsoldier.com/wp/sqlserver/walkthroughforsysprepinsqlserver2008r2
Hyper-V on Windows Server 2008 R2 Free with Windows Server 2008+ Free as a stand-alone Microsoft Hyper-V Server Lots of tools for easy management Maximum support for SQL Server virtualization Supported by SQL Server for guest host clustering
SysPrepping SQL Server on Hyper-V Copy the VHD to the new path for the VM Open Hyper-V Virtual Machine Manager Create a new Virtual Machine Skip the first page of the dialog Specify a name for the VM and the location from step 1 Assign memory for the VM Configure Networking Connect Virtual Hard Disk Check the Summary to make sure everything looks okay Click on Finish Start the VM and connect to it Rename the instance to the desired name and reboot
SysPrepping SQL Server on Hyper-V • Connect to the VM • Copy the SQL Server 2008 R2 installation files to the VM • Or make the file accessible over the network • Start the installation • Install any pre-requisites if prompted • When Installation Center starts, select the Advanced tab • Click on “Image preparation of a stand-alone instance of SQL Server” • Install the Setup Support Files and click Next • Agree to licensing statement and click Next • Select the features you want included in this image and click Next • This list is a very short list • (continued)
SysPrepping SQL Server on Hyper-V • Enter an Instance ID and click Next • Not the Instance name that will be used in the final install • Identifies the prepared image in case you have multiple • Confirm disk space requirements and click Next • Check Image Rules and click Next • Confirm image configuration and click Prepare • When image preparation completes, click Next • Click Close • Log off of the VM • Using Hyper-V Manager, shut the VM down • Copy the VHD for the prepared VM image to your VM image store
SysPrepping SQL Server on Hyper-V • Copy the VHD you created to the location of the new VM • Create a new VM the same way you did in part 1 using the new VHD • Start and connect to the new VM • Rename the VM to the desired final name and reboot • Connect to the VM • Navigate to and click on “Complete SQL Server 2008 R2 Installation” • Microsoft SQL Server 2008 R2 -> Configuration Tools • Or start Installation Center and looking under the Advanced tab • Install the Setup Support Files • Enter the Product Key or select a free edition • Agree to the licensing terms • (continued)
SysPrepping SQL Server on Hyper-V • Select the Instance ID of the prepared image you want to complete and click Next • The same Instance ID you entered in Part 2 • Verify the features you are installing and click Next • The features selected in Part 2 are displayed • Cannot change the features • Configure the instance to install as and click Next • Default instance or a named instance • Verify the image rules and click Next • Verify the summary information and click Complete • When the image progress completes, click Next • (continued)
SysPrepping SQL Server on Hyper-V • Click Close • Check the program files and see your installation • Feature set is limited with no SSMS, client connectivity, Books Online, etc. • Run Installation Center again and install the missing features that you want • Connect to your completed instance
SysPrepping SQL Server on Hyper-V Demo Environment: Windows Server 2008 R2 Datacenter Edition Hyper-V Hyper-V Virtual Machine Manager SQL Server 2008 R2 Datacenter Edition PowerShell 2.0
How do you automate it? Elfin magic? Complex machine? Complex system of tubes & monkeys? PowerShell?
Automating with PowerShell PowerShell 2.0 PowerShell Management Library for Hyper-V • http://pshyperv.codeplex.com/ • Interfaces with WMI • Created by James O’Neill (MSFT UK) TechNet Wiki Hyper-V Portal: Scripts • http://social.technet.microsoft.com/wiki/contents/articles/hyper-v-scripts.aspx
Automating with PowerShell • Copy the VHD to the new path for the VM • PowerShell Command: Copy-Item • Rename during copy • Example: • Copy-Item –LiteralPath “D:\VHDs\My.vhd” –Destination “D:\HyperV”
Automating with PowerShell • Script existing VM as model for new VM • PowerShell command: Get-VMBuildScript • Create PowerShell script from output • Example: • Get-VMBuildScript“SQLPASSVM” • Modify script • Add double-quotes around key values • Add parameter for VM Name • String • Mandatory • Add copy command • Use VM Name parameter for new VHD file name
Automating with PowerShell Follow Steps to complete image as noted previously
Automating with PowerShell Log in to VM Add any additional features you want
Resources Walkthrough for SysPrep in SQL Server 2008 R2 • http://www.sqlsoldier.com/wp/sqlserver/walkthroughforsysprepinsqlserver2008r2 PowerShell Management Library for Hyper-V • http://pshyperv.codeplex.com/ • Created by James O’Neill (MSFT UK) TechNet Wiki Hyper-V Portal: Scripts • http://social.technet.microsoft.com/wiki/contents/articles/hyper-v-scripts.aspx VHDs for Windows – Test Drive Program • Free evaluation edition VHD’s for download • http://technet.microsoft.com/en-us/bb738372.aspx
Resources Microsoft SQL Server 2008 Administration with Windows PowerShell • http://www.amazon.com/Microsoft-Administration-Windows-PowerShell-Programmer/dp/0470477288/ref=sr_1_1 • By Ananthakumar Muthusamy (MAK) and Yan Pan James O’Neill’s blog • http://blogs.technet.com/b/jamesone Tony Soper’s blog • http://blogs.technet.com/b/tonyso/ Hash tags for quick help on Twitter • #sqlhelp • #poshhelp
My Resources Blog: http://www.sqlsoldier.com Twitter: http://twitter.com/SQLSoldier Movember: http://us.movember.com/mospace/618068/ All files from this presentation can be downloaded from: http://www.sqlsoldier.com/PASS2010
Complete the Evaluation Form to Win! • Win a Dell Mini Netbook – every day – just for handing in your completed form. Each session evaluation form represents a chance to win. • Pick up your evaluation form: • In each presentation room • At the PASS Booth near registration • Drop off your completed form: • Near the exit of each presentation room • At the PASS Booth near registration Sponsored by Dell
Thank you for attending this session and the 2010 PASS Summit in Seattle