一、安裝iscsi target
yum install -y scsi-target-utils
二、添加磁盤并格式化
2.1檢視添加的磁盤系統是否正确識别fdisk -l
2.2分别格式化添加的磁盤 fdisk /dev/sdb;fdisk /dev/sdc;fdisk /dev/sdd;fdisk /dev/sde
2.3檢視是否格式化完成
[root@iscsi ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2087 16763796 83 Linux
/dev/sda2 2088 2609 4192965 82 Linux swap / Solaris
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
/dev/sdb1 1 512 524272 83 Linux
Disk /dev/sdc: 536 MB, 536870912 bytes
/dev/sdc1 1 512 524272 83 Linux
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
/dev/sdd1 1 391 3140676 83 Linux
Disk /dev/sde: 3221 MB, 3221225472 bytes
/dev/sde1 1 391 3140676 83 Linux
三、啟動iscsi target服務
service tgtd start
四、檢視服務是否啟動,端口是否正常
[root@iscsi ~]# netstat -an | grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.200:3260 192.168.1.253:10282 ESTABLISHED
tcp 0 0 :::3260 :::* LISTEN
[root@iscsi ~]#
五、使用tgtadm配置iscsi target的IQN、磁盤資源、及initiator伺服器
5.1 配置iscsi target伺服器的IQN為 iqn.2016-09.com.centos:000
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2016-09.com.centos:000
5.2 把格式化後的四個磁盤配置設定給tid1
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 2 -b /dev/sdc1
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 3 -b /dev/sdd1
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 4 -b /dev/sde1
5.3配置initiator伺服器,隻允許IP為192.168.1.199;192.168.1.198的initiator伺服器通路
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.1.199
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.1.198
六、檢視資源配置設定是否正常,initiator伺服器配置是否正常
[root@iscsi ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2016-09.com.centos:000
System information:
Driver: iscsi
State: ready
I_T nexus information:
I_T nexus: 1
Initiator: iqn.1988-12.com.oracle:002
Connection: 0
IP Address: 192.168.1.253
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 537 MB
Backing store path: /dev/sdb1
LUN: 2
SCSI ID: IET 00010002
SCSI SN: beaf12
Backing store path: /dev/sdc1
LUN: 3
SCSI ID: IET 00010003
SCSI SN: beaf13
Size: 3216 MB
Backing store path: /dev/sdd1
LUN: 4
SCSI ID: IET 00010004
SCSI SN: beaf14
Backing store path: /dev/sde1
Account information:
ACL information:
192.168.1.199
192.168.1.198
七、把tgtd服務配置資訊加入到/etc/rc.local檔案中,使其可以重新開機自動生效
本文轉自 技術花妞妞 51CTO部落格,原文連結:http://blog.51cto.com/xiaogongju/1947599