Saturday, February 5, 2011

Using VirtualBox to resize a virtual disk

Recently I needed to resize the C drive on a Windows 2008 R2 virtual machine from its existing 10GB to 20GB.

I performed the following steps using VirtualBox v4.

1. Execute from the command prompt (Note the Virtual Machine was Powered Off)
VBoxManage modifyhd C:\VM_Test_Env\Servers\W2K8R2-04.vdi --resize 20480



2. Start the virtual machine.

3. In Disk Management – right click the C drive – select Extend Volume – follow the Wizard prompts.


You should end up with a larger C drive.

Tuesday, February 1, 2011

WinDbg & mdmp files

Often you see mdmp files in the Log folder from when SQL Server has an issue.


The below steps, which use WinDbg, may be able to assist you find the cause of the issue.

1. Download and install Microsoft .NET Framework 4 (Standalone Installer) http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=0A391ABD-25C1-4FC0-919F-B21F31AB88B7

2. Download Windows SDK http://msdn.microsoft.com/en-us/windows/bb980924


3. Install the below option


4. Open WinDbg and add path to symbol files


SRV*c:\symbols*http://msdl.microsoft.com/download/symbols


5. Open the mdmp file


6. Run !analyze -v


The FAULTING_IP field shows the instruction pointer at the time of the fault and is the most probable cause for the issue.

7. Use lmvm to get more information on the module and then search the net for issues with the object e.g. for above you would use lmvm msvcrt


 

More information on the various outputs from ‘!analyze  -v’ can be found here http://msdn.microsoft.com/en-us/library/ff560201%28v=vs.85%29.aspx 

Friday, January 28, 2011

GhostCleanupTask & Exception Error 1222

If you experience Exception Error 1222 Severity 16 State 18 with the SPID being less than 50 and the LoginName shows 'sa', then these may be generated by the GhostCleanupTask.

To verify if indeed the GhostCleanupTask is the cause, try add the EventClasses 'Exception', 'Lock:Timout' and 'SQLTransaction' as well as filter on the LoginName 'sa' in SQL Server Profiler.

As mentioned in this link http://support.microsoft.com/kb/920093 the below will stop these errors:

DBCC TRACEON (661,-1)

To re-enable the GhostCleanupTask use:

DBCC TRACEOFF (661,-1)

Thursday, January 13, 2011

Extended Events Quick Test Code

Below is an example of creating, starting, viewing, stopping and dropping an extended event in SQL Server 2008.

-- Code to create an extended event
CREATE EVENT SESSION sqlkevin
ON SERVER
-- obtain events using SELECT * FROM sys.dm_xe_objects WHERE object_type = 'event' ORDER BY name
-- sqlserver below is used by comparing package_guid in sys.dm_xe_objects with name in SELECT * FROM sys.dm_xe_packages
ADD EVENT sqlserver.checkpoint_begin
-- obtain target for results by using SELECT * FROM sys.dm_xe_objects WHERE object_type = 'target'
-- package0 below is used by comparing package_guid in sys.dm_xe_objects with name in sys.dm_xe_packages
ADD TARGET package0.asynchronous_file_target
-- obtain SET permissions for this target from SELECT * FROM sys.dm_xe_object_columns WHERE object_name = asynchronous_file_target'
-- re below, look in the description column in sys.dm_xe_object_columns for more info
(SET filename = N'C:\sqlkevin_testlog.xel', metadatafile = N'C:\sqlkevin_testmetadata.xem')

-- Code to start an extended event
ALTER EVENT SESSION sqlkevin
ON SERVER
STATE = START

-- Code to see extended event
SELECT * FROM sys.server_event_sessions
SELECT * FROM sys.server_event_session_actions
SELECT * FROM sys.server_event_session_events
SELECT * FROM sys.server_event_session_fields
SELECT * FROM sys.server_event_session_targets
SELECT * FROM sys.dm_xe_sessions
SELECT * FROM sys.dm_xe_session_targets
SELECT * FROM sys.dm_xe_session_events
SELECT * FROM sys.dm_xe_session_object_columns

-- Create an Event
CHECKPOINT

-- Read the output file
-- Note that if there is no data to check point you may have to retry the below select statement until a checkpoint occurs
SELECT * FROM sys.fn_xe_file_target_read_file
('C:\sqlkevin_testlog*.xel', 'C:\sqlkevin_testmetadata*.xem', null, null)

-- Code to stop an extended event
ALTER EVENT SESSION sqlkevin
ON SERVER
STATE = STOP

-- Code to remove an extended event
DROP EVENT SESSION sqlkevin
ON SERVER
 

SQL Server and disk drives with 512 emulation (512e)

Interesting article about the 512e mode on hard disks when used with SQL Server.

Key extract from this link

'For SQL Server the best recommendation is to work with the hardware manufacture to make sure the 512e mode is disabled on drives that hold the SQL Server database and log files and that the Windows API is reporting 4K sector sizes.'

Further reading: