Monday, October 22, 2012

Disabling Time Sync in VirtualBox

Have you ever need to control the date or time on one of your VirtualBox Guests? Typically, the Guest OS gets the date and time from the Host.

Time Synced

Usually, this is fine. However, there are times when you may wish to control how the Guest operates. This could be for a variety of testing reasons, particularly with Edge-Case Testing.

For example, Active Directory Authentication, Mirroring and Witnesses, Replication, Clustering, etc. In each of these applications, if the servers involved get beyond five minutes from one another, they may cease to operate normally.

By disabling time synchronization between the Host and the Guest, you will be able to move each servers' time backwards and forwards while you observe how they behave. Will your application continue to function? Will you be able to trap error messages and inform the user?

VBoxManage Utility

VirtualBox includes a command-line utility, VBoxManage, that will allow you to control every aspect of your Guest VMs.

On a Windows host you will find this in the following directory: C:\Program Files\Oracle\VirtualBox

VirtualBox Manage List VMs

This example lists all the VMs that you have defined on your VirtualBox installation.

.vbox Configuration Files

Before we dive into this utility, another piece we need to look at are the VirtualBox Machine Definition Files. These are XML file which control how your Guest VMs operate. Basically, when you use the GUI to setup and control your VM, all the various settings are stored here.

On my Host, these files are stored in C:\Users\<USERNAME>VirtualBox VMs

You will see one directory for each VM that you have defined. Within that folder you will see a file with the .vbox extension. Before we go too much further, go ahead and make a copy of that file. This way, if something happens while you are working with it, you can restore your VM's configuration.

Now, use Notepad to open the .vbox file and poke around a bit. Just be careful not to modify anything yet, that comes later. You should see something like this...

VirtualBox Configuration File

This is an XML file that contains all the configuration information for your VM.

Let's go take a look at a couple of sections and see what they do.

ExtraData

As you might guess, this section contains 'extra' data about your Guest VM.

Extra Data Section Before

BIOS

And this section contains information on how the virtual BIOS operates.

BIOS Section Before

OK, now that we've seen that, it's time to get to work.

Disable Time Synchronization

First, let's turn off Time Synchronization.

http://www.virtualbox.org/manual/ch08.html

VBoxManage SetExtraData "YOURVMNAME" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Note, if your VM has spaces in its name, then surround it with quotes.

If you want to turn Time Synchronization back on, use a '0'.

VBoxManage SetExtraData "YOURVMNAME" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"

If you don't remember the names of all your VMs, try this first.

OK, let get down to business.  To turn off Time Synchronization, use this command:

Disable Time Sync Command

Now, the Extra Data section of your .vbox file should look like this.

Extra Data Section After

So now when you start your VM, you will be able to change the Date and Time. Presumably, one could simply edit the .vbox file to make this change.

Time Offset

OK, but what if you would like your VM to start with a different time. That's easy to do, as well. For this step, there isn't a command-line option, so we need to edit the .vbox file manually.

Find the BIOS section, then edit the TimeOffset line with something similar...

<TimeOffset value="-123456789"/>

It should look like this when done.

BIOS Section After

The number represents milliseconds so adjust as necessary for your needs. Also, the number can be positive or negative.

Et voila! Your Guest VM now has a completely different time from your Host.

Monday, October 8, 2012

SQL in the City - Austin

Last week I had the pleasure of attending Red Gate's SQL in the City conference as it rolled through Austin. I was excited when I first learned about this event as it generated good buzz in other cities. They have marketed it a little like a touring rock band; with 'tour stops' and concert Tees. If you are interested in attending, there are still some more stops. To find out, go visit the SQL in the City website.

What is SQL in the City?

SQL in the City is Red Gate's version of community SQL Server training. I remember learning during SQL Rally that Red Gate would no longer be participating in SQL Saturdays. At first, I was disappointed, but after I heard their reasoning, I totally understand where they are coming from.

In a nutshell, there are too many SQL Saturday events and only so many dollars...er, pounds they have to spare for sponsoring community events. Consider most of their staff is located in England, so travel costs are a serious consideration. So they decided to create their own event as a way to get a better return for their time and money.

Sessions
I have to admit, I was a little skeptical at attending a vendor-specific training event. However, I was pleasantly surprised at the quality of the content. Red Gate has a wide range of products that span just about every angle of SQL Server you could imagine. The keynote by CEO Simon Galbraith gave us an nice overview and short history of Red Gate and their mission.

Keynote Speech
While some of the sessions did include references to Red Gate Tools, I didn't find it to be overwhelmingly so. Out of the five sessions I attended, only one felt like a bit of a sales pitch. But even so, I was excited to learn about the features it had and was instantly thinking of how I could use it at work. Also, there was a reasonable mix of non-Red Gate presentations available.

Highlights

Steve Jones
I was particularly excited about seeing Steve Jones speak. I met him briefly at SQL Saturday Dallas last year, but missed his session due to scheduling conflicts. He gave two very nice presentations about Database Maintenance and Disaster Planning. It was great listening to his stories about DBA glory and adventure. I always love listening to how people approach the human side of the job. Also, he revealed that you can always sell him your unused ACL tickets.

Grant Fritchey

Grant Fritchey gave a nice talk about using SQL Virtual Restore as part of your development sandbox environment. While I was aware of this product, I never knew exactly how it worked. I was impressed at what all you could do with it. At a high level, it works similarly to SQL Database Snapshots, but using a backup file as the basis. So you are able to make edits and updates against your virtual database and the changes are kept track of in a diff file of sorts, and the base data is read from the backup file. And, multiple people can have multiple copies of the database going at the same time. Very nice!

To finish out the day, I attended sessions from some hometown heroes. Namely, Jim Murphy and Wes Brown.

Wes Brown & Jim Murphy

Jim took us through an interactive demo of SQL 2012's Always On Mirroring. He showed us how to get the basic setup running. Then, he had a live application running against the principal database as well as the mirror. From there, he simulated a failover and showed how Always On handles transferring the database back and forth. This is some cool stuff.

To finish the day, I checked out Wes' presentation on all things storage. While I have seen a couple of his other presentations, I always come away learning something new. For me, this was how to look for clues to see if your IO performance problem lies with SQL Server, the SAN, or the Network connections between the two. Time to go chat with my SAN Admin...

Substanence, Schwag, and Shiner

Like any good conference, SQL in the City provided us with a tasty breakfast, plenty of snacks, and a surprisingly good lunch. After the conference was over, they had free books, T shirts, and most important of all, cold Shiner Bock!

Mingle Like You Mean It

The happy hour was a nice treat. It gave attendees a chance to mingle with one another, hunt down a presenter for one last pesky question, or to pick the brains of the Red Gaters for some more insight into their tools.



Check the Tour Dates

SQL in the City is a good community event and provides some great training for a nice price. If you see them coming to your town, sign up and tell your friends. Yes, this is a vendor-sponsored event so there is a certain focus on Red Gate's tools. However, I felt I got an in-depth introduction to the breadth of their offerings and how they can be applied to your SQL problems.