Wednesday, May 27, 2009

How to create an iSCSI Target on Centos 5.3

This article is a quick howto on how I set up a working iscsi target on a centos box. Note that this was just for my own personal testing and should not be used in a production environment without some serious security and performance enhancements.

On with the HOWTO:...

Start out with a Centos 5.3 server. I will not go into how to set this up but I am willing to bet if you are looking at how to set up iscsi then you already know how to set up a Centos server.

From a command line type

yum update

This will make sure the system is up to date.

Then Download iscsitarget-0.4.17.tar.gz from SourceForge

I put the above file in /usr/src/iscsitarget If that folder does not exist you will need to create it.

mkdir /usr/src/iscsitarget

Then change to that directory

cd /usr/src/iscsitarget

Now you will have to enter the following commands to extract the files and install iscsitarget.

tar xvf iscsitarget-0.4.17.tar.gz
cd iscsitarget-0.4.17
make install

Once installed I created a folder to house my test disk files

mkdir /data/iscsidisks

Then create an empty file for your iscsi target file

dd if=/dev/zero of=/data/iscsidisks/LUN0 bs=1M count=512

(The above command will create a 512 MB file. Adjust accordingly.)

Now onto the config file for iscsitarget

Open up the /etc/ietd.conf file

I added the below options but there are many others as well. See the man file for more help.

IncomingUser scott 123456789012
OutgoingUser scott 123456789012
Lun 0 Path=/data/iscsidisks/LUN0,Type=fileio
Alias test
InitialR2T Yes
ImmediateData Yes
MaxOutstandingR2T 8

You may need to adjust the allow and deny files. For my testing I opened it up to allow all connection but you can adjust accordingly

Open up the /etc/initiators.allow file. I added

to the file.

Now you can then restart the iscsi-target service

/etc/init.d/iscsi-target restart

At this point you should now have a working iscsi target that you can connect to from an iscsi initiator. I will post a separate article on how to connect to this target.

For instructions How to connect to the iSCSI target from Windows Vista click here

For more linux articles please click here
For more iSCSI articles please click here

1 comment:

kumar said...

interesting. so with this setup i can throw in a bunch of sata II hdisks in my centos box and make them a ISCSI target ( mysql db) allow a web application to access them?

this will becom a mysql HA solution?

did i get this wrong? pls respond to kumar at if possible.