The other day I was taking a look at Vlad Catrinescu’s blog on quickly creating a SharePoint 2013 dev farm. It’s a great blog and provides some good information on creating a dev environment much faster than you could ever do it manually. I like to develop in an environment as similar to the production environment as possible and I also have the hardware to do it. With this in mind I wanted to come up with a way to quickly build a multi-server SharePoint 2013 developer environment. The problem is that for a single server install you could be looking at hours to install and configure, a multi-server environment could take even longer. I set out to build scripts that would not only deploy the SharePoint environments but would also create the VMs, deploy Active Directory and SQL Server, and configure the network. In addition, I wanted to be able to do this more than once (as different environments are sometimes needed at different times).
Huge thank you to Joanne Klein (@JoanneCKlein) for reviewing and editing the series for me.
Posts in this series:
- Creating and Configuring the VM – You are here!
- Configuring the Domain Controller, Active Directory and DNS
- Installing and Configuring SQL Server 2012
- Preparing SharePoint Servers
- Creating the AutoSPInstaller Answer File and installing SharePoint
Hardware Requirements
You are going to want either a high end desktop\laptop or a number of servers in your VM farm for this. To give you an example, I am running a Dell Precision M6700 that has been updated with multiple SSDs and 32GB of RAM. It’s an older beast of a laptop, but it does what I need. If you have something that puts out as much juice as this (or more) or access to a full VM farm, then I suggest you stick around as I discuss how we build out this developer environment. If you can’t run the required number of VMs, feel free to modify the scripts to meet your needs.
How the farm will look
This environment will consist of the following:
- Domain Controller configured with Active Directory 2012 and DNS
- 1 CPU
- 2 GB of RAM during configuration, but will drop this down to 1GB post config.
- 15 GB HDD
- Database Server loaded with SQL Server 2012 SP1
- 2 CPU
- 3 GB of RAM. If you find it is maxing out too much, you might want to pull some from the SP Servers and throw more here
- 25 GB System HDD (If working with large databases add a second HDD later to contain the databases)
- SharePoint 2013 + SP1 Applications Server
- 2 CPU
- 12 GB of RAM
- 60 GB HDD. VM will be designed to dynamically grow this disk so it won’t use it all at once
- SharePoint 2013 + SP1 Web Front End Server
- 2 CPU
- 10 GB of RAM
- 60 GB HDD. VM will be designed to dynamically grow this disk so it won’t use it all at once
This won’t mimic a true production environment as there won’t be any network routing with load balancers, but it will be closer than a single server development environment. Once configured it will leave me with roughly 4 GB of RAM for the host (if the DC is moved down to 1GB post config as planned).
What you will need
I am going to assume you have a MSDN license, or at least have access to the following software. For part 1 of this series you will need the following:
- Host system running Windows 8 or higher
- Windows Server 2012 (in ISO format)
- SharePoint 2013 with SP1 (in ISO format)
- SQL Server 2012 with SP1 (in ISO format)
Creating the VMs
While building a Hyper-V VM is not a time consuming task, when you are building multiple servers it can get tedious. I created a PowerShell script that will build and configure your VMs for you and have everything setup so you just have to power them on and install Windows Server. The script consists of two parts: the PowerShell script itself and a configuration file in XML format.
The script loops through each VM entry in the config file. It then builds some variables that need to be parsed to integers, grabs the network switch (or creates one if it doesn’t exist), creates the VM, assigns the Windows Server ISO to the DVD drive and finally enables Guest Service Integration so we have the ability to copy files from the host.
Quick note: I am only showing you how to create a private switch. If you wish to create your other switches using PowerShell the “Scripting Guy” has a great write-up on it.
#loop through each VM in the config to build out our farm. foreach($VM in $createVMConfig.Config.VMS.VM) { #We have some values stored in the config that need to be converted to integers (coming from the config they will be strings) #The memory components are then multiplied by 1GB (PowerShell has builtin convertor) to give us our memory size. $amountRam = [int]$VM.Memory * 1GB; $sizeHD = [int]$VM.HDSPace * 1GB; $vmGeneration = [int]$VM.VMGeneration; #First get the switch we are going to use. Create this first manually (if it isn't already there) $vmSwitch = Get-VMSwitch -Name $VM.NetworkSwitch; if(!$vmSwitch) { #Create our private switch. Because a private switch doesn't require a connection to the host, we don't have #to add any logic around grabbing the correct network adapter. New-VMSwitch -Name $VM.NetworkSwitch -SwitchType Private -Notes ‘Internal VMs only’ } #Create new VM New-VM -Name $VM.VMName ` -Generation $vmGeneration ` -Path $VM.VMPath ` -MemoryStartupBytes $amountRam ` -NewVHDPath $VM.VHDPath ` -NewVHDSizeBytes $sizeHD ` -SwitchName $VM.NetworkSwitch ` -BootDevice CD #Need to add the extra CPUs to the SharePoint Servers $numCPU = [int]$VM.CPUCount; if($numCPU -gt 1) { Set-VMProcessor -VMName $VM.VMName -Count $numCPU; } #VHD has been created, setup it up for first time installation Set-VMDvdDrive -VMName $VM.VMName -Path $VM.OSISOPath #Enable Guest Services for Integration Services Enable-VMIntegrationService -Name "Guest Service Interface" -VMName $VM.VMName }
The config file for my 4 VMs looks like this:
<?xml version="1.0" encoding="UTF-8"?> <Config> <VMS> <VM VMName="srv-DrevDC" VMGeneration="2" Memory="2" HDSPace="15" VMPath="U:\" CPUCount="1" VHDPath="U:\srv-DrevAD\VHD\srv-DrevAD.vhdx" NetworkSwitch="SP Dev Private" OSISOPath="D:\Software\en_windows_server_2012_x64_dvd_915478.iso" /> <VM VMName="srv-DrevSQL" VMGeneration="2" Memory="3" HDSPace="25" VMPath="U:\" CPUCount="1" VHDPath="U:\srv-DrevSQL\VHD\srv-DrevSQL.vhdx" NetworkSwitch="SP Dev Private" OSISOPath="D:\Software\en_windows_server_2012_x64_dvd_915478.iso" /> <VM VMName="srv-DrevSP2013APP" VMGeneration="2" Memory="12" HDSPace="60" VMPath="R:\" CPUCount="2" VHDPath="R:\srv-DrevSP2013APP\VHD\srv-DrevSP2013APP.vhdx" NetworkSwitch="SP Dev Private" OSISOPath="D:\Software\en_windows_server_2012_x64_dvd_915478.iso" /> <VM VMName="srv-DrevSP2013WFE" VMGeneration="2" Memory="10" HDSPace="60" VMPath="R:\" CPUCount="2" VHDPath="R:\srv-DrevSP2013Web\VHD\srv-DrevSP2013Web.vhdx" NetworkSwitch="SP Dev Private" OSISOPath="D:\Software\en_windows_server_2012_x64_dvd_915478.iso" /> </VMS> </Config>
When you are done you will see that you now have 4 shiny, new Hyper-V VMs already configured and ready for you to install the OS.
Installing Windows Server 2012
Unfortunately, creating brand new VMs doesn’t allow for the creation of unattended install files, but that’s ok. I am no server support analyst, however I have installed every flavour of Windows since Win95 and I can honestly say that Windows Server 2012 is the easiest OS to install yet to meet my needs. You only need to select a few options and let it install from there. My scripts in part 2 of this series will allow you to do the little bit of configuration you need to the OS without a bunch of clicking. Here’s how we go about installing the base Windows Server 2012 OS.
- Boot up your VM
- Be ready to press your space bar as Generation 2 VM requires this when booting from DVD. If you are not quick you will get an error message: Boot Failed. EFI SCSI Device. PXE Network Boot using IPv4.
- The OS will begin its install
- Enter your region settings:
- Click on Install Now
- When prompted for your license enter it here. Note: for Generation 2 VMs the keyboard is not emulated at this point so you need to use the virtual keyboard by clicking on the keyboard icon beside the license text box. This is the only part of the install I would consider worrying about an unattended install file as it is a pain. Tip: Use the enter key on the virtual keyboard instead of closing it. If you close it and made a mistake, there is a bug where the keyboard will not re-open and you will have to exit and re-enter the full key.
- Once you have entered the license key, select the type of Windows Server 2012 version you want. I selected the GUI version. Not ready to go back to straight command line OS yet.
- Accept the license
- At the installation type selection screen select Custom: Install Windows only (advanced)
- Click Next at the installation location screen
- Repeat for the other VMs while waiting for this and any others you have started to finish.
- When the OS is installed you will be prompted to enter the local admin password, so do that.
Your VMs are Ready to Go
That’s it. Your VMs are ready to go. I basically had all my VMs created with OS’s installing or installed within about 10 minutes using this method. It took me a lot longer to write this post then to complete the steps within.
The next step is to configure the domain controller, install and configure Active Directory and setup DNS.
Thanks for Reading!
Comments