Blog

The official blog of managed hosting provider OrcsWeb.

DPM Daily Maintenance Script

We recently completed a project to move over 300 servers from our old backup infrastructure to a brand new disk-based DPM 2007 solution. We have been very pleased with DPM 2007 thus far, but are finding that it required a fair amount of hand holding in the mornings to kick off failed jobs, increase disk allocations, and perform consistency checks. Unfortunately, the DPM console can only be loaded on the DPM server itself, and it cannot connect to a remote DPM server. That means logging in via RDP to each DPM server and addressing the alerts. After a few weeks of doing this by hand, we added them to our SCOM 2007 server which helped consolidate the alerts to a single interface, but we found we could not modify disk allocations via SCOM.

So I sat down and hashed out DPM Daily Maintenance Script. This powershell script will query the database for alerts and addresses the four most common. Replica disk and Recovery Point Volume threshold exceeded, Replica is inconsistent, and Recovery Point creation failed. The script takes 4 optional parameters:

replicaIncreaseRatio - Percentage of existing replica disk size to increase (ie. 1.1 increases by 10%. This is the default if nothing is specified)
scIncreaseRatio -  Percentage of existing recovery point volume size to increase (ie. 1.1 increases by 10%. This is the default if nothing is specified)
replicaIncreaseSize - Fixed value to increase replica disk (ie. 1GB)
scIncreaseSize - Fixed value to increase recovery point volume (ie. 1GB)

The script will first query the database for alerts, and then sorts them alphabetically and by alert type. This means that if a replica became inconsistent because the replica disk threshold was exceeded or if a recovery point creation failed because the recovery point volume threshold was exceeded, the script will increase the size of the volume before re-running the job. Also, for replica disks, the script will actually query the original datasource and resize the replica disk to the current workload's size plus the ratio or fixed amount specified in the script. This ensures that the replica disk is extended to the proper amount during the first pass in cases where a large amount of data is added to the workload.

We have been running this scripts on 6 DPM servers for about 6 weeks now and I have to say they have virtually eliminated the daily maintenance (I was on vacation for 2 weeks during that time and DPM happily hummed along without any intervention, self-healing twice per day). We still use SCOM to monitor the alerts and are manually checking for replicas that are constantly becoming inconsistent or recovery point creations that are consistently failing and addressing those by hand. We have setup a scheduled task that runs twice per day using the following command line:

C:\Windows\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft DPM\DPM\bin\dpmshell.psc1" -command ".'C:\admin\DailyMaintenance.ps1'" >> C:\admin\DailyMaintenance.log

DailyMaintenance.zip

There are a few 3rd party products that can help with these same alerts, and Microsoft is working on making our lives easier with DPM v3, but in the meantime, this should take some of the burden off of the sys admins.

Partition Alignment

Squeezing every ounce of performance out of your disk array is critical in IO intensive applications. Most times, this is simply an after-thought. However, doing a little leg-work during the implementation phase can go a long way to increasing the performance of your application. Aligning partitions is a great idea for SQL and virtualized environments - these are the places you will see the most benefit.

The concept of aligning partitions is actually quite simple and applies to SAN's and really any disk array alike. If you are using RAID in any capacity, then aligning disk partitions will help increase performance. It is best illustrated by the following graphics, borrowed from http://www.vmware.com/pdf/esx3_partition_align.pdf (This is a great read, but specific to VMWare environments, however, the same concepts apply).

Using unaligned partitions in a virtual environment, you can see that a read could ultimately result in 3 disks accesses to the underlying disk subsystem:

 

By aligning partitions properly, that same read results in just 1 disk access:

While these graphics are Virtual Machine and VMWare specific, the same is true for Hyper-V and SQL (except remove the middle layer for SQL). In order for partition alignment to work properly, you need to ensure that the lowest level of the disk sub-system has the highest segment size (also referred to as stripe size). Depending upon your RAID controller or SAN, this could default to as low as 4K or as high as 1024K. I won't cover what differences in segment sizes mean for performance, that's an entirely difference discussion, but generally speaking defaults are usually 64K or 128K. The basic idea behind a proper stripe size is that you want to size it so that most of your reads/writes can happen in 1 operation.

From there, you need to ensure that your block or file allocation unit size is set properly - ideally smaller or the same size as the segment size and that it is a multiple of the segment size. Lastly, you should then set the offset to the same as the segment size. By default, Windows 2003 will offset by 31.5K, Windows 2008 by 1024K, and VMWare VMFS default's to 128.

Setting the segment size may or may not be an online operation - that depends entirely on your RAID controller or SAN as to whether this can be done to an already configured array or if it has to be done during the initial configuration. Changing the offset and/or block size of a partition however is NOT an online operation. This means that all data will have to be removed from the partition, the offset configured, and the partition recreated. Prior to Windows 2008, this cannot be done to system partitions so for Windows 2003, you would have to attach the virtual hard disk to another system, set the offset and format the partition, and then perform the windows installation.

The following links provide detailed information about aligning partitions in both VMWare and Windows. Consult your SAN or RAID controller documentation for setting or finding out the segment size.

Recommendations for Aligning VMFS Partitions

Disk Partition Alignment Best Practices for SQL Server

How to run PowerShell 1 and 2, and Windows XP system tools, on Windows 7

It’s no secret that I’m a huge PowerShell fan.  I’ve been very excited to start using all the handy new tools in PowerShell 2.0 RTM, but I still need PowerShell 1.0 for backwards compatibility testing.  While there are quite a few options out there to do this, I even found someone who figured out how to make PowerShell portable, I didn’t need anything fancy, complex or expensive.  Just a simple way to easily test my commands in PowerShell 2.0 and 1.0.

With the announcement of Windows XP Mode a little dinging noise went off in the back of my head.  “Hey,” I thought, “why not just make PowerShell 1.0 into an XP Mode application?”  We have a winner!  Then, once XP Mode was released, I found out that no matter what you do Microsoft has decided to block executables in %windir% (C:\Windows) from XP Mode.  That’s okay, where there is a will there is a way, right?  In this case the answer is, yes.

I won’t go over the PowerShell and XP Mode install parts in detail, but, in summary, you need to be running Windows 7 Ultimate, Enterprise or Professional, download and install Windows Virtual PC [RC] and XP Mode [RC] on Windows 7, and then .NET 2.0+ and PowerShell 1.0 for Windows XP 32-bit on the Windows XP Mode virtual machine for this XP Mode trickery to work.  In addition to the XP Mode and PowerShell components you need a handy little tool written by the master of all things Windows, Mark Russinovich, called Junction.

Virtual PC [RC] and XP Mode [RC]:

http://www.microsoft.com/windows/virtual-pc/download.aspx

.NET 3.5 SP1 redistributable:

http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&displaylang=en

PowerShell 1.0:

http://www.microsoft.com/.../powershell/download.mspx

Junction:

http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

Is that the sound of mental bells I hear ringing?  For those that don’t have the mental bells ringing, junction is the pre-Vista/2008 version of mklink.  Junction creates a symbolic NTFS link between two folders.  It’s like a shortcut, but Windows treats the “linked” directory like it was the real directory.  In other words, the trick to tricking XP Mode is to create a junction to the folders which contain the tools you want to use in XP Mode.

To be on the safe side I created a link/junction from “C:\Program Files” to the PowerShell directory, C:\WINDOWS\system32\windowspowershell\v1.0.  Here is the command I used, from the command prompt, after extracting junction to C:\Windows\System32.

junction "C:\Program Files\Shell of Power" "C:\WINDOWS\system32\windowspowershell\v1.0"

And, no, you don’t have to use “Shell of Power” as the folder name.  It doesn’t matter what name you use, but whatever folder name you do choose it can’t exist before you run junction.exe.

Now create a shortcut from “C:\Program Files\Shell of Power\powershell.exe” to “C:\Documents and Settings\All Users\Start Menu\Programs” and delete the silly “Shortcut to” part if you did the drag and drop method.  Log Off and hibernate the XP Mode VM (just close the window, default action is to hibernate). Pull up your “Windows XP Mode Applications” and you will see “powershell (Windows XP Mode)” in the list.  Click the link, wait for the XP Mode application to spin up, and voila!

Let’s take this one step further, shall we? Say you also want command prompt from XP Mode.  I like to use it to do ping, telnet, and tracert tests from outside my VPN connection without actually turning off my VPN connection.  Simple.  Just make a shortcut from “C:\Windows\System32\cmd.exe” to the “Shell of Power” folder.  Then create a second shortcut from the cmd.exe shortcut in “Shell of Power” to the All Users program list.  And, once again, viola!  Rinse and repeat for any tool or program in %windir% you want to use as an XP Mode application.

That just about covers it.  My not-so-secret way of tricking XP Mode into letting us admins and scripters use PowerShell 1.0 and the good old Windows XP system tools on your shiny new Windows 7 installation.  Oh, and thank you for XP Mode, Microsoft!

 

#James Kehr
Get-Member $OW | ?{$_.title -eq "System Administrator"`
-and $_.certification -contains 'MCITP:SA 2008, MCSE 2000, MCDST, Network+, A+'}

New-Variable -name company -value 'ORCS Web, Inc.' -description www.orcsweb.com | 1.888.313.9421’