This was verified on CentOS 6.5, CentOS 5.9 and XenServer 6.2
This is a very basic guide on getting iSCSI storage up and running on a CentOS 6 server. You should obviously review more about security, authentication and other best practices when implementing this in a production environment.
Configuring iSCSI storage on CentOS linux:
1) Install iSCSI target via yum.
# yum install scsi-target-utils
Review the changes and agree to the install once you are ready to proceed.
2) Create the first target by editing the configuration file.
# vi /etc/tgt/targets.conf
<target iqn.2007-10.com.rowdydesign:disk0> backing-store /dev/md2 initiator-address 192.168.0.1 lun 1 </target>
- target: This is iSCSI Qualified Name (IQN) of the target. Format is as follows:
- literal iqn (iSCSI Qualified Name)
- date (yyyy-mm) that the naming authority took ownership of the domain
- reversed domain name of the authority (e.g. org.alpinelinux, com.example, to.yp.cr)
- Optional “:” prefixing a storage target name specified by the naming authority.
- backing-store: Path to your storage device.
- initiator-address: IP Address you wish the service to listen on.
- lun: Logical Unit Number, use this to force a specific LUN. Often times this is not needed and you should never use LUN 0.
3) Configure the iSCSI target daemon.
# /etc/init.d/tgtd start
# chkconfig --levels 235 tgtd on
This will start the target daemon and configure it to start at boot time on run levels 2, 3, and 5.
4) Configure your firewall (iptables).
# vi /etc/sysconfig/iptables
Allow traffic on all interfaces for port 3260 (iscsi target). This is very insecure, you should implement proper access control for all open ports based on your needs.
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3260 -j ACCEPT
# service iptables restart
Restart iptables to processes the newly added rule.
5) Do a basic check to ensure your configuration is correct.
# tgtadm --mode target --op show
You should see output similar to the following:
Target 1: iqn.2007-10.com.rowdydesign:disk0 System information: Driver: iscsi State: ready I_T nexus information: I_T nexus: 5 Initiator: iqn.2014-01.com.example:558f6e88 Connection: 0 IP Address: 192.168.0.1 LUN information: LUN: 0 Type: controller SCSI ID: IET 00010000 SCSI SN: beaf10 Size: 0 MB, Block size: 1 Online: Yes Removable media: No Readonly: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 1869171 MB, Block size: 512 Online: Yes Removable media: No Readonly: No Backing store type: rdwr Backing store path: /dev/md2 Backing store flags: Account information: ACL information: 192.168.0.0/24
If all of that looks correct, congratulations!