准备一台redhat6的虚拟机,添加两块虚拟硬盘vdb vdc,容量随意.
关掉防火墙和selinux
[root@storage88 ~]# service iptables stop
[root@storage88 ~]# setenforce 0
[root@storage88 ~]# chkconfig --level 35 iptables off
安装scsi-target-utils
[root@storage88 ~]# yum -y install scsi-target-utils
[root@storage88 ~]# cp /etc/tgt/targets.conf /opt/
修改配置文件,给两块磁盘设置共享存储。
[root@storage88 ~]# vim /etc/tgt/targets.conf
62 <target iqn.2018-12.cn.tedu:storage88.diskb>
63 backing-store /dev/vdb
64 write-cache off
65 initiator-address 192.168.4.30
66 initiator-address 192.168.4.40
67 vendor_id mydiskb
68 product_id tarena
69 </target>
70
71 <target iqn.2018-12.cn.tedu:storage88.diskc>
72 backing-store /dev/vdc
73 write-cache off
74 vendor_id mydiskc
75 product_id tarena
76 </target>
启动服务
[root@storage88 ~]# service tgtd start
[root@storage88 ~]# chkconfig --level 35 tgtd on
[root@storage88 ~]# netstat -untalp |grep :3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 4982/tgtd
tcp 0 0 :::3260 :::* LISTEN 4982/tgtd
查看共享信息
[root@storage88 ~]# tgt-admin -s
Target 1: iqn.2018-12.cn.tedu:storage88.diskb
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: 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: 5369 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vdb
Backing store flags:
Account information:
ACL information:
192.168.4.30
192.168.4.40
Target 2: iqn.2018-12.cn.tedu:storage88.diskc
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00020000
SCSI SN: beaf20
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00020001
SCSI SN: beaf21
Size: 5369 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vdc
Backing store flags:
Account information:
ACL information:
ALL