Sie sind auf Seite 1von 23

Building Virtualized SharePoint

Development Environments
Using Differencing Drives
By Reza Alirezaei , MOSS MVP,MCTS
Blog: http://blogs.devhorizon.com/reza
Version : 1.3.0

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 1


TABLE OF CONTENTS

Introduction ................................................................................................. 3
Background .................................................................................................. 4
Overall Plan .................................................................................................. 5
Differencing drives defined .......................................................................... 6
Creating the baseline image ......................................................................... 7
Creating level1 images based off the baseline image ................................... 9
Creating level2 images based off the level1 images ................................... 16
Procedures for fine tuning your differencing virtual hard disks ................. 19
Troubleshooting Differencing Drives .......................................................... 21
Performance tips for your Virtual Machines .............................................. 22
Additional Resources ................................................................................. 22

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 2


Important This document is for informational purposes only with NO WARRANTIES, EXPRESS, IMPLIED
OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.

Introduction:
There has been always a huge debate over using non- virtualized versus virtualized environments for
SharePoint Development. This always reminds me of a controversial debate about using custom
business objects vs dateset in the past , a debate that has never been an end to it. Pretty much the same
thing happening here, some people are in favor of virtual servers and working in these environment s
and others are in the opposition group. Some of the main criticisms against using virtualized
development environment include:

a) Many organizations set up trusted dev environments based on their own policies and do not
let you plug in your virtualized dev environment or they don't allow the existence of a server
(i.e. your WIN 2003 virtual machine ) hanging loose in their infrastructure for security purposes.

b) SharePoint developers want to develop on Windows XP or Windows Vista without extra


overhead of Virtual Machines. They are not only asking to eliminate virtual machines , also
demanding a light-weight version of SharePoint to be available on XP or Vista.

c) Hardware requirements for virtualization technology is too expensive for developers.

When it comes to virtualization technology , there is yet another difficult decision to make between
VMWare and Virtual Server (or VPC) . Although I can see VMWare more at enterprise level and a very
good candidate for server consolidation and speed, I believe for development purposes nothing can
compete with Virtual Server (or VPC). Its undo (much easier than snapshots in VMWare) and
differencing drives capabilities are just great. Needless to say, virtual Server (or VPC) is a product given
free of charge.

Well, I am focusing on a development platform in this article , but I would also like to draw your
attention to a risk associated with using VMWare at enterprise level . It is the level of support that you
may get from Microsoft. I have experienced MS support implications for customers who run their
SharePoint platform on VMWare , even for premier type of supports. I would highly recommend that
you consult your Microsoft representative before taking any chances in regards to choosing VMWare as
your main virtualization platform for SharePoint either for development purposes or at the enterprise
level. You don't want to take any chances and face difficulties should an issue occur during the life cycle
of your SharePoint projects.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 3


Background:
As a SharePoint consultant who mostly deals with minimum 3 client projects at a time (not mentioning
my community projects), I have always found it very easy to isolate my environments per *major*
project by using virtualization technology and on the top of that by using differencing drives. There are
a lot of benefits to working in a virtual environment , but to me the most important one is to ensure that
if one environment goes down for whatever reason , it doesn’t break all of the rest .

A virtualized environment gives me the following options:

1. Behaves as if it is a physical computer (cost saving).


2. Each virtual machine runs its own operating system and applications (runs real bits).
3. Persists state from session to session.
4. Emulates hardware that is not present on the physical computer.
5. Interacts with other computers/virtual computers on a network.
6. State can be “rolled back” to any point during your project development.
7. Enables mixing and matching of content in blended solutions .
8. Simplifies setup and deployment .
9. Saves development, testing and support costs .
10. Runs on a variety of hardware/software (even the Mac).
11. Portability (Comes in handy for your demos, training and etc).

Using differencing drives on the top of virtualization technology even adds more value :

1. Fantastic granularity and quicker way of provisioning client-specific environments.


2. Using less resources (i.e. less space).
3. Easier Administration.

Important I haven't seen a need for non-virtualized environment for my clients ,but it doesn't mean
that I am suggesting you to completely ignore it. In this article I am just sharing the idea based on which
I build my SharePoint development environments that may not be suitable for an specific project or a
client of yours. Needless to say , in my literature there is NOT a single solution that fits all, so it is always
evaluate all your options and decide accordingly based on your own project requirements.

As for development environment matters , I have always been able to convince my clients to allow me
to work in the environment that I think is suitable for my project s, not the environment that someone
else with no or minimal development experience dictates to me. The truth is , there were a few
incidents in which I was unable to sell my desirable working conditions ,but I managed to work out
something that was finally led to something close to what I had in mind at first place. Quite frankly, I
never develop on XP or Vista (even for my non-SharePoint projects ), because If there is the option for
developing on the most stable operating system ever (WIN 2003/2008)and when this is the environment

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 4


that eventually I will deploy my work anyway, why should I bother developing on Vista/XP with all its
bells and whistles? Why Should I bother with an extra deployment from my Vista/XP machine to the
Server? Why Should I bother to remotely attaching to the worker process to debug my applications?

Adequate memory and disk space is also not expensive these days , so I would argue this as a limitation
for developing in virtualized environments. Having said all this, I strongly believe in setting up my
SharePoint development environment based on the virtualization technology and using differencing
drives in particular. okay, it is time to build this environment, so let's get started.

Overall Plan:
The overall plan is to create a baseline image as the core virtual machine(WIN2k3_Base) . MossDiff
machine and WssDiff machine are created using differencing drives and they are meant to be core
virtual machines for all WSS and MOSS virtual machines. MossSandBox machine , which is also built
using differencing drive, is derived from MossDiff and WSSSandBox machine is derived from WssDiff.
We will only use the last two virtual machines and we will write-protect or lock all the other three
machines (WIN2k3_Base, WssDiff,MossDiff). I will walk you through this process later in this paper.

Overall Plan

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 5


Differencing drives defined
A differencing drive is a virtual hard disk that is associated with a parent virtual hard disk. The
differencing drive contains only the changes from the parent virtual disk. Multiple differencing drives
can be associated with the same parent virtual disk. Once differencing drives are associated with a
parent virtual hard disk the parent disk cannot be changed because changes to the parent will cause all
of the differencing drives associated with it to be unbootable. Unlike dynamically expanding disks,
differencing drives cannot be compressed. Picture below shows a graphical comparison between
differencing and all other drives available for you when you use virtual server or VPC.

Figure 1: Differencing Drive

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 6


Creating baseline image:
The first thing you need to build is a "baseline image" that has all the most common things that you will
use in almost all of your environments (dev and non-dev). Here are different things installed on my base
virtual machine:

1. Windows Server 2003 SP2


2. All latest Windows Update Patches (Set Windows Update to Manual)
3. Virtual Machine Additions
4. Enable Terminal Server Admin Mode
5. Create bunch of local users
6. Install Windows Powershell
7. Install SQL Server 2005 Standard (Include AdventureWorks database sample)

For brevity , I'll skip the steps required to create baseline image , but it is called Win2k3_base and I've
placed it in F:\LiveVMs\sysPBase folder as shown in figure 2.

Figure 2: Base Virtual Machine folder

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 7


There are couple things that you need to configure in the base image , before we go forward and built
everything on the top of it.

 Remove the page file


1. Open the system control panel and select the Advanced tab.
2. In the Performance section, click Settings.
3. On the Advanced tab, in the Virtual memory section, click Change.
4. In the Virtual Memory dialog box, No paging file, click Set, and then click OK.
5. In the System Control Panel Applet information box click OK.
6. In the Performance Options dialog box click OK.
7. In the System control panel click OK.

 Enable Remote Desktop


1. Open the system control panel and select the Remote tab.
2. In the Remote Desktop section, click Enable Remote Desktop on this computer.
3. In the System Control Panel Applet information box click OK.

 Adjust for best performance


1. Open the system control panel and select the Advanced tab.
2. In the Performance section, click Settings.
3. On the Visual Effects tab, click Adjust for best performance.
4. In the Performance Options dialog box click OK.
5. In the System control panel click OK.

 Set maximum event log sizes and clear all events


1. Open the Event Viewer Administrative tool.
2. Right-click Application and then click Properties.
3. In the Log size section set the Maximum log size to 512KB.
4. In the Log size section select Overwrite events as needed.
5. Click Clear log.
6. In the Event Viewer question box click No.
7. Click OK.
8. Repeat steps 2 through 7 for the Security ,System and Office logs.
9. Close the Event Viewer.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 8


 Disable PAE X86 on the virtual machines.Virtual machines can only leverage up to 3.6 GB of memory
each; thus you don't need PAE. Enable Physical Address Extension (PAE) X86 on your host operating
system to enable your host operating system to leverage more than 4 gb of memory if applicable.

Creating level1 images based off the baseline image:


As you can see , there are two main branches off the baseline image:

1. WssDiff : A core WSS machine.


2. MossDiff: A core MOSS machine .

Okay, now the question is how to create these two machines. First let's start with WSS machine.

1. Create a folder called WSSdiff in F:\LiveVMs (Change the drive alias)


2. Enter the folder path created above (F:\LiveVMs\WssDiff) in Virtual Server Search Paths

Figure 3

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 9


3. Create a differencing drive based off WIN2k3_Base . It is important that you create this drive
before you create the actual virtual machine. Go to Virtual Server Admin Site -->Virtual Disks -->
Create--> Differencing Virtual Hard Disk, fill out the page as below and hit "Create" button .

Figure 4

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 10


4. Once you create the Differencing Drive , you can go ahead and create the virtual machine. Go to
Virtual Server Admin Site -->Virtual Machines -->Create, fill out the page as below and hit
"Create" button.

Figure 5

5. Your WssDiff virtual machine should show up in the master view.


6. Run your WssDiff Machine and install WSS and all development tools ,SDKs,IDEs that you need
for your WSS development. In this case I installed the following :

Add 12 Hive folder to your favorites


Install WSS SP1 (and then MOSS 2007 SP1 for Moss Machine)
Add the url to the site collection to the Intranet Zone
Install Office Client 2007
Visual Studio 2005 Professional SP1
Visual Studio extensions for WF
Visual Studio extensions for WSS
Latest WSS SDK (and latest MOSS SDK for Moss machine)
Download and Install warm up scripts from here
Add the WSS.XSD SharePoint XML Schema to the Visual Studio 2005 XML Schema Cache
(http://andrewconnell.com/blog/archive/2006/10/20/4944.aspx)

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 11


Links to be saved in Desktop\Links which should be also added to the task bar
a) Link to the directory C:\Program Files\Common Files\Microsoft Shared\web
server extensions\12
b) Link to c:\windows\assembly
c) Link to the Central Admin home page

Figure 6: Install all WSS development bits on WSSDiff machine

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 12


1. WssDiff folder should look like figure 7.

Figure 7 :WSSDiff folder

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 13


2. There are couple settings that you need to configure in on WSSDiff machine.

a. Performance -->Settings --> Performance Options -->Data Execution Prevention --> Turn
on for selected programs .
b. Environment Variables --> System Variables --> Path --> Place the BIN folder of 12 Hive
here (i.e. C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\12\BIN).

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 14


Figure 8 : System Properties dialog box

c. If you are using more than one network cards in your host OS , try to load balance your
virtual machines on them. Don't put all the pressure on one network card only.
d. If you are planning to boot up more than one virtual machine at a time, try to distribute
your vhds on different hard disks evenly. For more information please see section " Start
virtual computers serially, not in parallel" later in this paper.

3. Follow step 1 to step 8 for the other machine (MossDiff) customized for your MOSS
development works.
4. Once you are done setting up MossDiff virtual machine , you need to write-protect or lock the
WIN2k3_Base image to prevent data loss. For more information please see section "Differencing
drive reports that its parent has changed" later in this paper.

a. Remove WIN2k3_Base virtual machine from Virtual Server Admin console. Don't worry ,
this will not delete the actual vhd and vmc files.
b. Make vhd file read only and change the extension of vmc file to something meaningful
as shown in figure 9 below.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 15


figure 9

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 16


Creating level2 images based off Level1 images:
For creating level2 images , you must follow step 1 to step 5 described in the previous section (just
change the names and that's all) and soon you will get your first WSS environment up and ready to go.
The reason that you don't need to follow step 6 and step8 is because those two steps are already taken
care in parent image and that's the whole beauty of using differencing drives. Figure 10 below shows the
end result in the Virtual Server master view.

Figure 10

There are couple important notes here that I would like to draw your attention to:

1. When you are done with your WssSandBox and MossSandbox , you have to go through the
same write-protection process stated in step 10 above for WssDiff and MossDiff images. It is
very important to do this , otherwise you may have some problems later on.

2. Make sure you enable Undo Disk feature when creating WssSandBox and MossSandbox.
Remember that we didn't need this option in base images as we were not going to change those
machine. Those machines are only meant to serve as a core platform to build our customer-
specific or project-specific virtual machines. When using undo drive, all the changes are written
to the undo drive and the differencing drive is left untouched. When you shut down the virtual
computer, you have the option to persist those changes you have made in your sandboxes or
not. This is a perfect option for a sandbox environment.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 17


Figure 11

3. As you might have noticed by now, this solution is not good for a farm installation. It is good for
stand-alone development environments that you only bring one machine up at a time. My
experience tell s me that most of developers' computers do not have the power to boot up
more than one virtual machines at a time, so this solution assumes that you only have one
machine boot up at a time. This doesn't mean that you cannot branch out other sandboxes off
the WssDiff or MossDiff core machine,but you are limited to have one branch running at the
time. If you can't live with this limitation , then read the solution below.

4. If you ever need to boot up two machines , derived from the same base image , then you need
to follow these steps:
a. Boot up the machine without Network capability.
b. Apply a new SID (Or SysPrep). This makes sure that there is no SID collision in DHCP or
any other OS unique settings that cannot be replicated.
c. Reboot the machine.
d. Reconnect the machine to the network of your choice. Figure 12 shows that how I have
been able to start 3 machines derived from the same core image (WIN2k3_base) up and
running without any problems.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 18


Figure 12

e. If you are planning to boot up more than one virtual machine at a time, you have to
actively monitor and adjust the settings in CPU Resource Allocation (Figure 12) to
ensure you have the optimum configuration for your virtual machines

Figure 13

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 19


Procedures for fine tuning your differencing virtual hard disks
This section contains the procedures that must be followed in order to optimize a virtual hard disk. All of
the following procedures must be followed in the order that they are described here.

Important Before optimizing any virtual hard disk it is best to make a back-up of it and do not perform
these tasks with undo drives enabled.

Defragment Host drive


Before beginning the back up process ensure that the physical hard disk on which the virtual disk resides
has been defragmented. It is important to do this defragmentation while the virtual computer is
shutdown.

Removing unnecessary items


The following procedures provide the instructions for removing items from the virtual computer that are
not necessary for the operation of the virtual computer but that cause the virtual computer to be very
large.

 Clear the dll cache


1. Open a command prompt window
2. At the command prompt type sfc /cachesize = 1
3. Restart the virtual computer.
4. Open a command prompt window
5. At the command prompt type sfc /purgecache
6. Close the command prompt

 Clear the %windir%\servicepack folder if it exists


1. Using My Computer or Windows Explorer navigate to %windri%\servicepack.
2. Select all of the files and folders in this folder and delete them.

 Clear the %windri%\Driver Cache\i386 folder


1. Using My Computer or Windows Explorer navigate to %windir%\Driver Cache\i386
2. Select all of the files and folder in this folder and delete them.
 Clear %Programfiles%\WindowsUpdate folder
3. Using My Computer or Windows Explorer navigate to %Programfiles%\WindowsUpdate.

Note The WindowsUpdate folder is a Hidden folder. You must therefore chose to display hidden
and system folders in order to perform this step.

4. Select all of the files and folders in this folder and delete them

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 20


 Clear %windir%\system32\wbem\autorecover folder
1. Using My Computer or Windows Explorer navigate to %windir%\system32\wbem\autorecover
2. Select all of the files and folders in this folder and delete them.
 Clear %windir%\web\wallpaper folder
3. Using My Computer or Windows Explorer navigate to %windir%\web\wallpaper
4. Select all of the files and folders in this folder and delete them.

 Delete unnecessary log files


1. Use the Windows search utility to search the C drive for *.log
2. Select all of the resulting files except the following
%windir%\system32\msdtc\msdtc.log,
%windir%\system32\msdtc\trace\dtctrace.log,
%windir%\debug\usermode\chkacc.log,
%windir%\system32\wbem\logs\wmiprov.log

Note Other log files will be present in the virtual computer as some logs are created automatically
when the virtual computer is running.

Defragment the virtual drive


After defragmenting the physical hard disk you must then defragment the hard disk on the virtual
computer.

 To defragment the virtual disk


1. Start the virtual computer and log on
2. Verify that the Recycle Bin and Temporary directories are empty.
3. Run the Windows Disk Defragmenter utility and click Defragment. You must defragment even if the
tool indicates that you do not need to.
4. When complete click OK in the Disk Defragmenter message box and then close the Disk
Defragmenter application.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 21


Troubleshooting Differencing Drives
1) Differencing drive reports that its parent has changed
The following error message indicating that the parent disk has changed may indicate either no problem
at all, or it may indicate that a very serious problem exits with the virtual computer.

The only way to determine the severity of the problem is to allow the virtual computer to continue to
boot. If the virtual computer completely boots, and you are able to logon to the virtual computer
without error, then the parent virtual disk is fine and you don’t need to take any further action.

However, if an error occurs during boot and/or logon you should replace the base virtual disk with the
one that you originally created and hopefully backup somewhere for future references.

The more serious form of this error occurs when you open the base virtual disk directly without the use
of a differencing drive. You must not do this as it may cause a corruption to the virtual computer that is
based on the parent/differencing drive combination.

When the error message occurs erroneously it is most likely related to a problem that occurs when the
virtual hard disk is extracted from an archive. In some cases the virtual hard disk date time stamp is
incremented by one second when it is extracted from an archive. The differencing drive stores the date
time stamp of the parent disk in its header and checks it against the actual date time stamp of the
parent disk file. The difference of one second between the stored date time and the actual date time
causes this error to be displayed, and in this case it is completely harmless.

If, after opening the virtual computer, you save the differencing/parent virtual disk combination you will
never see the error again as the date/time stamp is updated in the differencing disk.

2) Differencing drive can’t find its parent disk


When a differencing drive is configured as the hard disk for a virtual machine, Virtual Server (or VPC)
must be able to determine the location of the parent virtual disk. Differencing drives store the location
information for the parent virtual disk in both relative and absolute paths. So if the parent virtual disk is
in either the same directory structure as when the parent and differencing drives were last linked, or if
the parent is in the same folder as the differencing drive, the virtual disks can be moved from computer
to computer with no problem.

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 22


Performance tips for your Virtual Machines
1) Start virtual computers serially, not in parallel
When virtual machines start they must do a great deal of disk I/O. If you start multiple virtual machines
at once all of them are attempting to do this disk I/O to the same partition and therefore are causing the
disk to churn as the processor timeslices between the two virtual computers that are starting causing
the disk to have to seek in possibly disparate locations.

By starting one virtual computer and then starting another one after the first has reached the logon
screen you allow each virtual machine exclusive access to the disk and it will take less time to start the
virtual computers.

2) Restart the host


I have also found in some cases that virtual machine may start to run slowly after they have been
running for a significant amount of time. In case you experience such a problem I recommend that you
close and save the state of the virtual machine instead of turning them off or shutting them down. Then
restart the host operating system and resume the virtual machines again.

3) Avoid frequent Reboots


Every time Windows reboots it writes information to the disk. In the case of a virtual machine that is
using a differencing drive all of that information is written to the differencing drive. In fact, I have
observed cases by frequent reboots differencing drive reaches approximately the same size as the
parent virtual disk. If you are installing a number of pieces of software that all require a reboot, it is
better to choose to not reboot when possible and then reboot after everything has been installed. It is
also better to pause the virtual computer rather than shutting it down when not using it.

4) Minimize overhead on host


To improve performance of the virtual computers you should run as few applications and services as
possible on the host computer You should also minimize the display color depth and the visual effects
that are used on the host computer.

This concludes this paper.

Additional Resources:
1. Andrew Connell has posted a great article on virtual machines using differencing drives .
2. Virtual Machine best practices on TechNet .

Created By Reza Alirezaei (http://blogs.devhorizon.com/reza) Page 23

Das könnte Ihnen auch gefallen