Art of the DBA Rotating Header Image

Virtualization at Home

As tech geeks, we love to poke, prod, and play with all sorts of new software. We love to tinker. We love to explore. Most of all we love to be able to do all of this without wrecking our own machines.  Having a sandbox where it’s easy to play and not worry about rolling back changes or uninstalling software is ideal, but that isn’t so easy to do on just one machine and very few of us have 5-10 computers that we can wipe/reinstall at a moments notice. That is, until we start building our own virtual servers at home.

I’m sure most of you are familiar with virtual servers now. I always considered it heavy hitting stuff, enterprise level tech that I really couldn’t use at home. Well, at least up until I discovered VirtualBox. Since then, I have fallen in love with this particular piece of software and I’m trying to use it as much as possible. Walk with me for a bit and I’ll show you the some of what I learned when I created a machine to host SQL Denali CTP 1. Hopefully it helps you enough so you can set up your own virtual host and take your learning to another level.

Installation

VirtualBox is available on pretty much any platform and you can download it for Windows, Linux, and Mac OS X. I’ve installed it on my XP laptop and an Ubuntu 9.0 desktop I have at home, finding both installations to be pretty straightforward. For Windows, just download the latest setup executable and fire it off. You’ll walk through the typical series of setup screens and there aren’t really any options to worry about. Ubuntu was even easier, just typing in sudo apt-get install virtualbox-4.0 with my admin password(’cause I’m a su-doer not a su-don’t-er) and off to the races.

Quick Tour

With the installation complete let’s take a quick look at the interface:

VirtualBox Main Screen

The three big buttons there at the top are really what we want to be concerned with:

  • New – Create a new machine
  • Settings – Look at the setup of the selected machine
  • Start – Power on the selected machine.

As you can see, it’s pretty simple. Of course, the devil is in the details, so let me show you how I got a machine ready for Denali.

Creating a new machine

The wizard for creating a new machine is very good, just select the OS type and version that’s appropriate (for Denali, I did Windows 2008 64-bit) and go with all the defaults. Some things to keep in mind:

  • Base Memory – This is only the minimum amount of memory VirtualBox will reserve for the machine. The virtual machine will grab whatever free memory is available on the host, so keep this in mind if you get specific with the memory settings on your SQL Server install on the virtual machine. If running multiple virtual machines, be careful that your total base memory allocations don’t exceed total memory on the box!
  • I typically do dynamically sized storage. Unless you have a space crunch on your box, it should be fine to allow it to grow.

Starting a new machine

Before you actually start the machine, there’s two items you’ll want to look at first. The first thing to consider is the virtual machine’s network settings. VirtualBox offers you four options (found under Settings->Network) which are described in full detail on the manual page.

VirtualBox Network Settings

While in all cases your virtual machines will piggy-back on the host’s network card, the setting you select will determine how it shows itself to the world. I won’t get into the details of each specific setting, but this is the place where you do not want to used the default setting of NAT (Natural Address Translation). Instead, I suggest you go with one of these two settings, depending on what you intend to use the machine for:

  • Bridged Networking – This allows the machine to appear as any other machine on your local network. It can join domains and workgroups, as well as receive an IP address from your network DHCP host. I usually use this setting, since at home my virtual host machine is different than the machine where I sit and do my work.
  • Host-only Adapter – This ones a little trickier to setup, but is useful if you’re running VirtualBox on a laptop that you’re doing demos on. The virtual machine will join a network that is only visible to the host and virtual machines on that host. At this point, VirtualBox itself will act as the DHCP provider, which is setup under File->Preferences->Network.

The other gotcha to address only applies to 64-bit machines. When I created my machine for Denali, I kept getting an error message about “VT-x/AMD-V hardware acceleration has not been enabled”. After some Googling, I discovered that this is a BIOS setting and you’re basically enabling your CPU to handle virtualization. Now it’s called different things for different motherboards, so you’ll need to do a little research on yours, but for my Asus board (M4785-M) I had to enable Secure Virtual Machine Mode under Advanced/CPU Configuration. Note, you’ll only have to enable this once on your hardware.

Now we can start the machine. There’s a wizard to guide you through the first run, which all you’re going to do is tell it where the CD-ROM drive is so it can find your install media. I didn’t do anything fancy here, like mapping it to a shared folder or a network drive, and it just worked for me. On both Windows and Ubuntu, VirtualBox had no issues finding the drive and using it on boot of the new machine.

Installing the OS and software

From this point forward, everything was a normal Windows and SQL install. I used a demo copy of SQL Server 2008 R2 and had no issues with the install. While I didn’t join the virtual machine to a domain (I’m not that fancy at home), it found my local workgroup just fine(since I was using bridged networking).

Virtual Box - Running!

The only other setup piece I had to do was to make sure the the network configuration within the virtual machine was setup properly.  First off, I disabled the Windows Firewall on the virtual machine. I’m sure with some time you could configure it appropriately, but I’m a DBA, not a network administrator.  Then I went into the SQL Server Configuration Manager and made sure Named Pipes and TCP/IP protocols for my instance were enabled.

When you’re using the virtual machine on the host (not RDC-ing into it, which is what I usually do), there’s a couple tricks to keep in mind:

  • The cursor will lock itself into the virtual machine when you click on it. To release the cursor from the virtual machine back to the host, press right CTRL.
  • CTRL+ALT+DEL is not registered within the machine itself due to the VirtualBox application. To send that command to the virtual machine, release the cursor, then in your toolbar go to Machine->Insert CTRL+ALT+DEL.

This should help you get started with virtual machines at home. While it’s not specific to SQL Server, I’ve found this tool to be immensely helpful for building demos at home and testing out new versions of the software. Hopefully this will be just as useful to you. Feel free to contact me, either by email or twitter me with any questions or experiences you’ve had using virtualization at home.

 

One Comment

  1. Marc Beacom says:

    Thanks for the post Mike. Downloading and giving VirtualBox a go.

Leave a Reply to Marc Beacom Cancel reply

Your email address will not be published. Required fields are marked *