Centos上iscsi-target使用lvm卷作为Lun的设备

海外服务器 (600) 2015-10-27 14:34:16

Centos上iscsi-target使用lvm卷作为Lun的设备,我们为TARET配置LUN的时候,可以使用文件(fileio),磁盘,或者逻辑卷,在IP-SAN存储网络中,存储客户端叫做iSCSI Initiator,存储服务器叫做iSCSI Target。

在下面的例子当中,我们的环境

192.168.1.110            iSCSI Target

192.168.1.152            iSCSI Intiator
 
首先我们要新建一个逻辑卷组,请保证你的磁盘有足够的空间,如果没有足够的空间,请添加磁盘

# create a phisical volume
[root@dlp ~]#
pvcreate /dev/sdb1
 
Physical volume “/dev/sdb1″ successfully created
# create a volume group named “vg_target00″
[root@dlp ~]#
vgcreate -s 32M vg_target00 /dev/sdb1
 
Volume group “vg_target00″ successfully created
# create a logical volume named “lv_target00″
[root@dlp ~]#
lvcreate -L 100G -n lv_target00 vg_target00
 
Logical volume “lv_target00″ created
[root@dlp ~]#
yum -y install scsi-target-utils
[root@dlp ~]#
vi /etc/tgt/targets.conf
# add at the last
# if you set some devices, add <target>-</target> and set the same way with follows
# naming rule : [ iqn.yaer-month.domain:any name ]
<target iqn.2013-06.world.server:target0>
# provided devicce as a iSCSI target
backing-store /dev/vg_target00/lv_target00
# iSCSI Initiator’s IP address you allow to connect
initiator-address 192.168.1.152
# authentication info ( set anyone you like for “username”, “password” )
incominguser username password
</target>
[root@dlp ~]#
/etc/rc.d/init.d/tgtd start
Starting SCSI target daemon:
[ OK ]
[root@dlp ~]#
chkconfig tgtd on
[root@dlp ~]#
tgtadm –mode target –op show
# confirm status
 
Target 1: iqn.2011-07.world.server:target0
    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
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: None
    Account information:
        username
    ACL information:
        10.0.0.31

THE END