Using Oracle Linux iSCSI targets with Oracle VM
- by wim.coekaerts
A few days ago I had written a blog entry on how to use Oracle Solaris 10 (in my case), ZFS and the iSCSI target feature in Oracle Solaris to create a set of devices exported to my Oracle VM server.
Oracle Linux can do this as well and I wanted to make sure I also tried out how to do this on Oracle Linux and here are the results.
When you install Oracle Linux 5 update 5 (anything newer than update 3), it comes with an rpm called scsi-target-utils. To begin your quest, should you choose to accept it :) make sure this is installed. rpm -qa |grep scsi-target
If it is not installed : up2date scsi-target-utils
The target utils come with a tool tgtadm which is similar to iscsitadm on Oracle Solaris.
There are 2 components again on the iSCSI server side. (1) create volumes - we will use lvm with lvcreate (2) expose a target using tgtadm.
My server has a simple setup. All the disks are part of a single volume group called vgroot.
To export a 50Gb volume I just create a new volume : lvcreate -L 50G -nmytest1 vgroot
This will show up as a new volume in /dev/mapper as /dev/mapper/vgroot-mytest1. Create as many as you want for your environment. Since I already have my blog entry about the 5 volumes, I am not going to repeat the whole thing. You can just go look at the previous blog entry.
Now that we have created the volume, we need to use tgtadm to set it up :
make sure the service is running : /etc/init.d/tgtd start or service tgtd start
(if you want to keep it running you can do chkconfig tgtd on to start it automatically at boottime)
Next you need a targetname to set everything up. My recommendation would be to install iscsi-initiator-utils . This will create an iscsi id and put it in /etc/iscsi/initiatorname.iscsi.
For convenience you can do :
source /etc/iscsi/initiatorname.iscsi
echo $InitiatorName
and from here on use $InitiatorName instead of the long complex iqn.
create your target :
tgtadm --lld iscsi --op new --mode target --tid 1 -T $InitiatorName
to show the status :
tgtadm --lld iscsi --op show --mode target
add the volume previously created :
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/mapper/vgroot-mytest1
re-run status to see it's there :
tgtadm --lld iscsi --op show --mode target
and just like on Oracle Solaris you now have to export (bind) it :
tgtadm --lld iscsi --op bind --mode target --tid 1 -I iqn.1986-03.com.sun:01:2a7526f0ffff
If you want to export the lun to every iscsi initiator then replace the iqn with ALL. Of course you have to add the iqn of each iscsi initiator or client you want to connect. In the case of my 2 node Oracle VM server setup, both Oracle VM server's initiator names would have to be added.
use status again to see that it has this iqn under ACL
tgtadm --lld iscsi --op show --mode target
You can drop the --lld iscsi if you want, or alias it. It just makes the command line more obvious as to what you are doing.
Oracle VM side :
Refer back to the previous blog entry for the detailed setup of my Oracle VM server volumes but the exact same commands will be used there.
discover : iscsiadm --mode discovery --type sendtargets --portal
login : iscsiadm --mode node --targetname iscsi targetname --portal --login
get devices : /etc/init.d/iscsi restart
and voila you should be in business.
have fun.