用Tgtadm 在EL/ RHEL5上创建一个iSCSI目标
适用于:
Linux Kernel - Version: 5.3
Linux Itanium
Linux x86-64
目标:
如何用tgtadm和tgtd建立一个iSCSI目标。
对于这个例子,以下是必要的:
scsi-target-utils
the Partiton /dev/hdb1
Enterprise Linux / Redhat Enterprise Linux 5 Update 3
解决方案:
创建一个永久的配置
1,Install scsi-target-utils
# up2date scsi-target-utils
Name Version Rel
----------------------------------------------------------
scsi-target-utils 0.0 5.20080917snap.el5x86_64
Testing package set / solving RPM inter-dependencies...
Downloading headers to solve dependencies...
########################################
scsi-target-utils-0.0-5.200 ########################## Done.
perl-Config-General-2.40-1. ########################## Done.
Preparing ########################################### [100%]
Installing...
1:perl-Config-General ########################################### [100%]
2:scsi-target-utils ########################################### [100%]
The following packages were added to your selection to satisfy dependencies:
Name Version Release
--------------------------------------------------------------
perl-Config-General 2.40 1.el5
2,Start the tgtd Service
# /etc/init.d/tgtd start
Starting SCSI target daemon: [ OK ]
3,在/etc/TGT/targets.conf创建一个条目,我们使用的是iSCSI目标作为分区/dev/hdb1
# cat /etc/tgt/targets.conf
<target iqn.2001-04.com.mydomain:storage.disk1>
backing-store /dev/hdb1
incominguser disk1user 123456
outgoinguser disk1user 12345
</target>
4,Enable tgtd at boot
# chkconfig tgtd on
5,禁用的iptables(或配置iptables允许TCP端口3260)
# /etc/init.d/iptables stop,
# chkconfig iptables off
6,重启tgtd或系统
7,验证配置
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.mydomain:storage.disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 3512 MB
Online: Yes
Removable media: No
Backing store: /dev/hdb1
Account information:
ACL information:
ALL
8.与您的iSCSI客户端的新创建的目标连接,可以使用的指令Note.473179.1。
手动添加上飞行的目标
Start the tgtd Service
# /etc/init.d/tgtd start
Starting SCSI target daemon: [ OK ]
Create a Target
# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.mydomain:storage.disk1
Add a Partition to the Target, we are using /dev/hdb1 as the Partition as the iSCSI Target
[root@iscsi ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hdb1
Allow all iSCSI Initiators to connect to the newly created Target
# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
Verify your Configuration
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.mydomain:storage.disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 2509 MB
Online: Yes
Removable media: No
Backing store: /dev/hdb1
Account information:
ACL information:
请注意,此配置是不是永久性的,tgtd是重新启动或重新启动服务器时,将丢失。
此外,没有用户/密码是需要与此配置。