iSCSI drives are used to configure high performance server storage. These are specifically also needed to be able to configure Clustering in Microsoft SQL Server. For a long time, configuring an iSCSI storage required the presence of real iSCSI hardware, which is a roadblock in environments that are gearing up for full scale virtualization. With Windows Server 2012, Microsoft made available virtual iSCSI storage, where the drives have virtual hard disks (VHDs) in the backend instead of iSCSI hardware. This article explores how to leverage this feature.
iSCSI storage technology lets a single disk be attached to multiple servers and provide different data functions to the using machine. It is a remote storage technology, where the actual disk is not locally connected at the particular server, but is made available to it through the network. Typically, you would have had to spend a lot of money and purchase an iSCSI storage device, configure it to act as your network-attached storage (NAS) and then derive your remote disk drives from this. These drives would then be mapped into the particular machines that they got assigned to as drives. Many software were built around this principle and specifically to leverage its functionality and advantages, one such being Microsoft’s SQL Server database engine. When you wish to configure Microsoft SQL Server in a clustered environment, lacking an iSCSI storage available to use for your Cluster and Witness disks will prove to be your first roadblock.
Windows Server 2012 brings good news to the table, by including in its File Server role, services and abstractions to use a virtual hard disk (VHD file) and surface it as an iSCSI device through the iSCSI Target Server. In this article, we show you how to install, configure and use this facility.
Installing the Role
To use iSCSI in Windows Server 2012, you need to add the iSCSI Target Server and iSCSI Target Storage Provider. The second one is not actually required, but it provides VSS based access to the virtual disks, making it that much more reliable. When you add the iSCSI Target Server role feature, the File Server role will be added as a dependency. Optionally, you can also add the iSNS Server Service — this will allow your iSCSI configuration to be available over iSNS. You do not need to reboot after this.
From Server Manager
Invoke the Add Roles and Features wizard, select Role based installation, select your server and from the Server Roles page, expand the File and Storage Services item and check on the “iSCSI Target Server”. You will be prompted to add the File Server item as a dependency, accept it. Optionally (but recommended), add the iSCSI Target Storage Provider item. On the next page (Features), if you require iSNS, check on the iSNS Server Service. Proceed to finish the wizard and apply the changes.
From PowerShell
The command is:
PS:\> Add-WindowsFeature FS-iSCSITarget-Server, iSCSITarget-VSS-VDS, iSNS
The above command will install the iSCSI Target Server, the VSS provider for iSCSI Target and the iSNS server service. Feel free to remove the names of components you do not need from that command.
Creating Virtual Hard Disks for Use with the iSCSI Target Server
Launch Server Manager, click into the “File and Storage Services” item on the left hand pane and then on iSCSI. If Server Manager was already open, you will need to hit the Refresh button before you can start using your new iSCSI Target Server. From the “Task” drop down on the upper section, select “New iSCSI Virtual Disk” to open up a wizard. For the storage location, you can either choose a drive and Windows will create its storage paths, or you can use “Custom Path” (our preference) and set the location to your preferred spot. Remember to choose a physical drive that has sufficient space to store all of your virtual iSCSI hard disks. Also, if you have multiple hard disk, try to spread the load around these physical hard disks by balancing high usage and low usage disks across them.
Give a name to the disk, specify a size and if it is fixed, dynamic or differencing. On the next screen, you specify a “Target”. Targets are like folders or locators in the iSCSI world. On your machines that will consume these disks, you will configure them to connect to one or more Targets. Only the virtual disks that are mapped to a target will be available to the consuming machines that connect to that target. We don’t have any targets at this point, so select to create one and specify a name.
The Access Servers screen is where you specify the identification the consuming machines will use to request for this iSCSI Target. You can specify something called an IQN (similar to a domain name, you can enter a longish domain-name like string
), DNS Names, IP Addresses or MAC Addresses. We recommend that you set this to an IQN since this is easily configurable and reconfigurable. If you face issues, it is easier to troubleshoot using IQNs rather than by DNS, IP or MAC Addresses. You cannot use wildcards in any of these values. Finally, select the authentication type — if you are not using VPN or other connection types and the consuming computer will directly connect to the iSCSI Target Server using normal networking, then you can leave all of this blank.
NOTE: If you want to expose your iSCSI Target Server over a public network and want to secure it against someone being able to guess your IQN, it is recommended that you enable either or both of CHAP and Reverse CHAP. This will let you set up a username/password based access.
As you may have guessed, you can perform all the above steps using PowerShell. The commands to provision a new 10GB fixed size iSCSI disk, create a new Target called “10GB_Storage” with an IQN of “10.gb.iscsi.storage.network” and assign this new iSCSI disk to this Target would be as follows:
PS:\> New-iSCSIVirtualDisk -Path
"<a href="file:///S:/iSCSIDisks/10GBDISK.vhdx">S:\iSCSIDisks\10GBDISK.vhdx</a>" -Size 10GB
PS:\> New-iSCSIServerTarget -TargetName "10GB_Storage" -InitiatorID "IQN:10.gb.iscsi.storage.network"
PS:\> Add-iSCSIVirtualDiskTargetMapping -TargetName "10GB_Storage"
-DevicePath "S:\iSCSIDisks\10GBDISK.vhdx"
The iSCSI Initiator UI
You need to run this UI atleast once on every machine that is either a Target Server or a consumer. Open up the “Administrative Tools” folder and look for the item “iSCSI Initiator”. Fire it up. It will immediately prompt you to say that the Microsoft iSCSI Service is not running and you should start it. Answer YES to start the service. Once the services have been started, the Initiator UI will come up. On the iSCSI Target Server, you do not need this UI again.
On every machine that will consume your iSCSI disks, you then go to the “Configuration” (last) tab and click on the first “Change” button. Set the value to the same name as the “IQN” value you set on the Target Server machine. If you also set up CHAP and Reverse CHAP, click on the CHAP button as well and enter the CHAP password you entered in the Target’s CHAP password field.
Now, go to the “Discovery” tab and click on the first Refresh button. Based on the IQN entered, it will list all the discovered iSCSI Targets (allowed for that IQN) in the first box. If your system has issues resolving computer names or you have overly restrictive firewalls, make the task easier by clicking on the “Discover Portal” button and entering the IP address of your iSCSI Target Server (leave the port number as default). If you had installed iSNS Servers, you can click the second Refresh button or click on the “Add Server” button to add the IP address of the iSNS Server manually.
If everything is configured and working correctly, if you now switch to the first (Targets) tab, you should see a list of available targets to connect to. Select one or more targets to connect to and click on the Connect button. To see the results of these operations, click on the “Volumes and Devices” tab to see all the disks from all connected targets listed. Click on Auto Configure to add them to Disk Manager for use.
Again, all of this is achievable through PowerShell as below (assume “StorageServer
” is the DNS name for our iSCSI Target Server machine):
PS:\> Set-Service -Name "msiscsi" -StartupType Automatic
PS:\> Start-Service "msiscsi"
PS:\> Set-InitiatorPort -NodeAddress "10.gb.iscsi.storage.network"
PS:\> New-iSCSITargetPortal -TargetPortalAddress "StorageServer"
PS:\> Get-iSCSITarget | Connect-iSCSITarget -IsPersistent $True
PS:\> Get-iSCSISession | Register-iSCSISession
Initialize and Use the Disks
We are not done yet. After clicking on the Auto Configure button as above, launch the Disk Management Console (diskmgmt.msc). All the iSCSI disks will be listed, but will be marked “Offline”, right-click on each disk on the left-side pane where it says things like “Disk 2”, and select Initialize Disk and then “Bring Online”. This will initialize your disk and bring it online, partition and format the disks and assign them drive letters. Do these operations in the same order in which you want the drive letters.
NOTE: If you don’t want the standard sequential drive lettering, allow Windows to assign the drive letter as usual and then change the drive letter.
Now you are ready to use the iSCSI disk on your remote machine! And yes, it is all being stored on a virtual hard disk file back on your iSCSI Target Server.