Vous êtes sur la page 1sur 3

Running an iSCSI SAN on CentOS 5

July 14th, 2008 Remco Bressers Leave a comment Go to comments Running iSCSI target on a Fedora system is as easy as yum install iscsitarget and configure the thing. Unfortunatly, on CentOS, the iSCSI Enterprise Target (IET) daemon is not in the default Yum repositories, because CentOS usually uses TGT (Linux SCSI Target Framework). Ok, i could dive into using TGT on a CentOS box, but thats not what i wanted to use on a corporate SAN. So, lets find it out the hard way and build from source. The iSCSI Target system First, some prerequisites :
# yum install kernel-devel openssl-devel gcc rpm-build

Download the latest IET from the Sourceforge repo and put the tgz in /usr/src
# # # # # cd /usr/src tar xvf iscsitarget-0.4.15.tar.gz cd iscsitarget-0.4.15 make make install

Alright. IETD is installed and ready to use. The iscsi-target init.d script is installed and will be started at boot-time. Nice! One bad thing is, that every time you install a new kernel, you need to recompile ietd. Write this down on your forehead or somewhere you will look at every single day Configuring ietd is a piece of cake if the documentation would be easy findable, but it isnt (or wasnt). First, lets decide who can connect to the IET daemon :
# vi /etc/initiators.allow iqn.2008-07.my-sanhead:mydiskname 192.168.1.0/24

Yep, quite a strange string. Its called an IQN (iscsi qualified name) and i use this naming convention: iqn.<year>-<month>.<hostname>:<LVM diskname> The IQN is an identifier for your iSCSI target. A target can consist of multiple disks and/or luns. The iSCSI initiator uses the IQN to connect to these disks/luns. The subnet 192.168.1.0/24 is allowed to use this iSCSI target. Next, well create the initiators.deny file, which is pretty straightforward :
# vi /etc/initiators.deny ALL:ALL

Time to create the IQN in the ietd configuration file.


# vi /etc/ietd.conf Target iqn.2008-07.my-sanhead:mydiskname IncomingUser username 12345 OutgoingUser username 123456789012 Lun 0 Path=/dev/SAN/diskname,Type=fileio,IOMode=wb Alias iSCSI for diskname ImmediateData Yes

MaxConnections 1 InitialR2T Yes

I use the following conventions, as defined in the RFC : For IncomingUser: Password always 5 characters For OutgoingUser: Password always 12 characters I use LVM as a disk backend. The disk can also be /dev/sdb or whatsoever. The iSCSI Initiator For the initiator, were also going to use a CentOS system, as this is my OS of choice. In Ubuntu/Debian/Fedora/Whatever-linux-u-may-have there usually is an open-iscsi in the repository. If not, you can always compile it from source at http://www.open-iscsi.org. Lets install the prerequisites :
# yum install iscsi-initiator-utils # yum install open-iscsi

Next, define the initiatorname. This is in the exact same form as the targetname, but it should not be the same. This initiatorname is the name (in IQN) of your computer.
# vi /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2008-07.mydesktoppc:someuniquename

Next, were going to configure the authentication and some specials in the iscsid config.
# vi /etc/iscsi/iscsid.conf node.startup = automatic node.session.auth.authmethod = CHAP node.session.auth.username = username node.session.auth.password = 12345 node.session.auth.username_in = username node.session.auth.password_in = 123456789012 node.session.timeo.replacement_timeout = 120 node.conn[0].timeo.login_timeout = 15 node.conn[0].timeo.logout_timeout = 15 node.conn[0].timeo.noop_out_interval = 10 node.conn[0].timeo.noop_out_timeout = 15 node.session.initial_login_retry_max = 10 node.session.cmds_max = 128 node.session.queue_depth = 32 node.session.iscsi.InitialR2T = No node.session.iscsi.ImmediateData = Yes node.session.iscsi.FirstBurstLength = 262144 node.session.iscsi.MaxBurstLength = 16776192 node.conn[0].iscsi.MaxRecvDataSegmentLength = 131072 discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768 node.session.iscsi.FastAbort = No

For more information about these setting, please refer to the open-iscsi page. Next up, start the thing :
# service iscsi start

Bingo! You just started the iSCSI daemon (all cheer). Now, were going to discover our targets on the target iSCSI host. I assume 192.168.1.1 is the target host in this example.

# iscsiadm -m discovery -t st -p 192.168.1.1 192.168.1.1:3260,1 iqn.2008-7.my-sanhead:mydiskname

As you can see, it found the target we created before. Now, lets login to it:
# iscsiadm -m node -p 192.168.1.1 -T iqn.2008-7.my-sanhead:mydiskname --login

Vous aimerez peut-être aussi