分类: 服务器与存储
2007-03-14 16:57:00
This is a ultimate guide how to setup your iSCSI target on a Linux FC4 machine. This article doesn't include the setup guide for Linux iSCSI Initiator. However, it does tell you how to download and use a Microsoft iSCSI Initiator for use on a Windows server/client PC for iSCSI Initiator role. You can read all about iSCSI on Linux (). Or just read the (phpwiki/index.php/FrequentlyAskedQuestions?PHPSESSID=a361557a79c96e1f545f8fe21b324baf).
Internet SCSI. Pronounced eye skuzzy. An IP-based standard for linking data storage devices over a network and transferring data by carrying SCSI commands over IP networks. iSCSI supports a Gigabit Ethernet interface at the physical layer, which allows systems supporting iSCSI interfaces to connect directly to standard Gigabit Ethernet switches and/or IP routers. When an operating system receives a request it generates the SCSI command and then sends an IP packet over an Ethernet connection. At the receiving end, the SCSI commands are separated from the request, and the SCSI commands and data are sent to the SCSI controller and then to the SCSI storage device. iSCSI will also return a response to the request using the same protocol. iSCSI is important to SAN technology because it enables a SAN to be deployed in a LAN, WAN, or MAN. iSCSI was developed by the IETF and became an official standard in February 2003.
Because we are in a production environment with mixed infrastructure, we will setup a FC4 server, exporting our spare partition via iSCSI (Note that you can export block devices, regular files, LVM and RAID). The iSCSI Initiator will be some Windows 2003 server, that will se this iSCSI exported partition as another local drive on this server. This will make our Linux box the iSCSI target, and a Windows 2003 server a iSCSI Initiator.
You need to download and install iscsitarget software from (). The downloaded version depends on your kernel version. You can see your kernel version issuing the command:
uname -a
For the time of writing, for the latest version of iscsitarget (0.4.13) you need kernel 2.6.14 or newer. If you don't have that kernel version you can get the latest kernel as shown below or you can get older versions of iscsitarget in *.rpm:
yum update kernel kernel-devel
Reboot your server after the kernel installation, to apply changes. At this point you are ready to build iSCSI target.
Goto /usr/local folder for example and extract the files from the archive in that folder:
tar xvfz iscsitarget-0.4.13.tar.gz
Goto the newly created folder and build iSCSI modules and service:
cd iscsitarget-0.4.13
...but first, export your kernel source path. Make sure you export the correct PATH for your kernel version!
export KERNELSRC=/usr/src/kernels/2.6.14-1.1526_FC4-i686
Compile and install
make && make install
Copy the default config file to /etc folder
cp etc/ietd.conf /etc
Well, you can play around with the options that you have, but actually, you only need to setup Target (for identifying this box), Incoming/Outgoing user (if you would like to use authentication), the part of storage that you are exporting and possibly Alias for this target. So i basically changed just the following:
Target iqn.2009-08.local.fog:storage.lvm
# Users, who can access this target
# (no users means anyone can access the target)
#IncomingUser
#OutgoingUser
# Lun definition
# (right now only block devices are possible)
Lun 0 Path=/dev/hdb
# Alias name for this target
Alias iSCSI
# various iSCSI parameters
# (not all are used right now, see also iSCSI spec
This is how my config file looks like. My domain name is fog.local, I'm not using authentication, I'm exporting second HDD (hdb) and the alias of this target is iSCSI. Feel free to look at the manual page for ietd.conf file for more parameters explanations.
At this point you are ready to start the service. Fire it up with
/etc/init.d/iscsi-target start
If you configured everything correct, you should see a message like this in your log file /var/log/messages
Oct 5 10:45:01 iscsi-fc4-prod kernel: iSCSI Enterprise Target Software - version 0.4.13
Oct 5 10:45:01 iscsi-fc4-prod kernel: iotype_init(97) register fileio
Oct 5 10:45:01 iscsi-fc4-prod kernel: iet_target_param_set(128) d 1 8192 262144 65536 2 20 8 0
Oct 5 10:45:01 iscsi-fc4-prod iscsi-target: ietd startup succeeded
If you want the iscsi-target service to be automaticaly run on next reboot do:
chkconfig iscsi-target on
Now you have a fully working iSCSI target up and running. If you would like to use the exported storage on Windows machine, read on, else you have to configure iSCSI Initiator on Linux client. You can find more on this subject from (phpwiki/).
This is the easy part, all the "hard work" was already done. There are a few steps left:
First get the initiator software from ().
Next, install the software (next, next, next.... finish). Note you have to install Initiator and Service.
When done, configure initiator as shown below:
Configure the IP address of the iSCSI target server:
Make the iSCSI target available and Log On to it. Note, that you can
automatically restore the target by checking the first checkbox.
Now we have set up everything we need to be successfully running iSCSI software in Enterprise production. Goto your Management Console and open Disk Management. If you've setup the Windows part correct, you should see a new drive in your Disk Management. Feel free to format it and make it usable in your system. This drive is treated just like a hardware drive would be, but it is all done over the network.
The example of successfully configured exported storage is shown below:
iSCSI can be a VERY useful thing, especially when you have a large storage to be exporting it over network. It's a cheap solution for a big part in every network infrastructure.