■ Requirement : Setup an iSCSI target using tgtadm in Red Hat Enterprise Linux 5
■ OS Environment : Linux[RHEL, Centos]
■ Application: tgtadm
■ Implementation Steps :
SCSI uses a client-server architecture. A "client" (ie: your system) is an initiator, it initiates requests. A "server" (ie: your storage device) is a target, it has something you want and answers requests from the initiator(s). Initiators come in two varieties: software and hardware. A software initiator is just a driver that handles all requests and pairs the network interfaces driver and the SCSI drivers together to make it all work. Using a software initiator any system with an ethernet card can act as an iSCSI initiator. A hardware initiator is an iSCSI HBA, which is basically just an ethernet card with a SCSI ASIC on-board to offload all the work from the system CPU.
1. Install package :
$yum install scsi-target-utils -y
2. Start the tgtd service:
$ service tgtd start
3. Define an iSCSI target name:
$ tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
4. To view the currect configuration:
$tgtadm --lld iscsi --op show --mode target
DEMO :
here we create a 512M file as the block device:
$ dd if=/dev/zero of=/disk1 bs=1M count=512
Add it as a logical unit to the target:
$ tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1
Enable the target to accept any initiators:
$ tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
View the current configuration again:
$ tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
System information:
Driver: iscsi
Status: running
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 55G
Backing store: /disk1
Account information:
ACL information:
ALL
Ensure TCP port 3260 can be accessed from remote host.
Start from Red Hat Enterprise Linux 5.3, tgt-admin and /etc/tgt/targets.conf can be used for make the setup persistent over reboot:
$tgt-admin --dump > /etc/tgt/targets.conf
$ chkconfig tgtd on
In releases prior to Red Hat Enterprise Linux 5.3, you have to put the "tgtadm" commands into /etc/rc.local and enable the tgtd service:
echo >> /etc/rc.local <
tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
EOF
$ chkconfig tgtd on
■ OS Environment : Linux[RHEL, Centos]
■ Application: tgtadm
■ Implementation Steps :
SCSI uses a client-server architecture. A "client" (ie: your system) is an initiator, it initiates requests. A "server" (ie: your storage device) is a target, it has something you want and answers requests from the initiator(s). Initiators come in two varieties: software and hardware. A software initiator is just a driver that handles all requests and pairs the network interfaces driver and the SCSI drivers together to make it all work. Using a software initiator any system with an ethernet card can act as an iSCSI initiator. A hardware initiator is an iSCSI HBA, which is basically just an ethernet card with a SCSI ASIC on-board to offload all the work from the system CPU.
1. Install package :
$yum install scsi-target-utils -y
2. Start the tgtd service:
$ service tgtd start
3. Define an iSCSI target name:
$ tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
4. To view the currect configuration:
$tgtadm --lld iscsi --op show --mode target
DEMO :
here we create a 512M file as the block device:
$ dd if=/dev/zero of=/disk1 bs=1M count=512
Add it as a logical unit to the target:
$ tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1
Enable the target to accept any initiators:
$ tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
View the current configuration again:
$ tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
System information:
Driver: iscsi
Status: running
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 55G
Backing store: /disk1
Account information:
ACL information:
ALL
Ensure TCP port 3260 can be accessed from remote host.
Start from Red Hat Enterprise Linux 5.3, tgt-admin and /etc/tgt/targets.conf can be used for make the setup persistent over reboot:
$tgt-admin --dump > /etc/tgt/targets.conf
$ chkconfig tgtd on
In releases prior to Red Hat Enterprise Linux 5.3, you have to put the "tgtadm" commands into /etc/rc.local and enable the tgtd service:
echo >> /etc/rc.local <
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /disk1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
EOF
$ chkconfig tgtd on
Awesome......
ReplyDeleteVery nice, straightforward how-to. Thank you for sharing.
ReplyDelete