Monday, February 22, 2010

iSCSI Target

I have wanted to setup my own SQL Server failover cluster for quite a while, but never really understood how: a long time ago you had to pick special hardware off a list provided by Microsoft and you needed to run a special edition of Windows Server and you needed Fibre Channel. In short, a recent university graduate wasn't going to get anywhere.

It all seems to have changed though. iSCSI has emerged as an alternative to Fibre Channel, which means that you use your gigabit network to communicate with the SAN instead of some cheeky fibre optic cables (all those years ago it still wouldn't have helped to know that you could use copper cables too). Windows Server 2008 ships with the iSCSI initiator built-in, although you can download it for free from Microsoft if you're running Windows Server 2003 or earlier.

My first mission was simple. Get it working. I chose to run iSCSI Enterprise Target under Ubuntu, with a 16GB USB flash drive formatted in NTFS. This would be my SAN. Note: you need to choose the correct block device name so that you don't end up destroying hardware or losing data. For my flash disk I used /dev/sdc1 (maybe an Ubuntu guru could tell me why /dev/sdc without the number didn't work 100%) and yours will almost certainly be different. [edit:on a fresh install of karmic, i had to run sudo apt-get update first, otherwise it complained that the package couldn't be found]
sudo apt-get install iscsitarget
Once the installation was complete, I edited the service configuration file
sudo gedit /etc/ietd.conf
Adding in the following two lines:
Target iqn.2010-02.com.extellect:ta.tb.tc.td
Lun 0 Path=/dev/sdc1,Type=fileio

After saving the file and closing the editor, I restarted the Ubuntu machine, and powered up the Windows Server.

I clicked on Start > Administrative Tools > iSCSI Initiator then I clicked yes to the questions about firewall, and thought about setting the service as a dependency of the SQL Server service so that the drive would be available whenever SQL Server was running.

Looking at the iSCSI Target properties window:
Discovery tab: Add portal: aa.bb.cc.dd port 3260
Targets tab: automatically populated thanks to discovery: iqn.2010-02.com.extellect:ta.tb.tc.td and the status is "Inactive"
Click the Log on button, then OK.
The status is now "Connected"

At this point take a look at the Ubuntu machine to see the connection
sudo cat /proc/net/iet/session

Back to the Windows machine, this time opening Computer Management > Storage > Disk Management
I saw my flash drive but the disk said it was offline - right click and choose online from the context popup menu. Now I saw a familiar (and happy) sight:
Disk 2 Basic 14.95 GB Online - CRUZER (F:) 14.95 GB NTFS Healthy (Primary Partition)

Opened up SQL Server Management Studio and created a new database, choosing F: as the default data and log location. Created a table, inserted and then selected "Hello, World!"

Checked on the Ubuntu machine and there was the mdf and ldf!

1 comment:

Jono said...

As you can tell from my later post "Failover Fail" this didn't actually work and I will have to try and find a better iSCSI implementation than IET.