iscsi服务端配置(rhel5.5)

iscsi服务端配置

操作系统版本:

[root@ex333server ~]# lsb_release -a
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID:    RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release:    5.5

创建如下两个用来共享的逻辑卷:
[root@ex333server ~]# lvs
  /dev/cdrom: open failed: No medium found
  LV            VG       Attr   LSize Origin Snap%  Move Log Copy%  Convert
  lv_iscsi_244  vg_iscsi -wi-a- 4.00M                                     
  lv_iscsi_demo vg_iscsi -wi-a- 4.00M         


安装软件包:
yum install scsi-target-utils

启动服务:
/etc/init.d/tgtd restart
chkconfig tgtd on


1. 通过命令配置iscsi服务端:
创建一个target:
tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2012-05.com.example.ex333server:rdisks.demo

绑定共享设备到target:
tgtadm --lld iscsi --op new --mode=logicalunit --tid=1 --lun=1 --backing-store /dev/vg_iscsi/lv_iscsi_demo

设置可以访问共享的网段:
tgtadm --lld iscsi --op bind --mode=target --tid=1 --initiator-address=192.168.221.0/24

本地查看共享设备:
tgtadm --lld iscsi --op show --mode target

检查结果:
[root@ex333server init.d]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2012-05.com.example.ex333server:rdisks.demo
    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
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 4 MB
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: /dev/vg_iscsi/lv_iscsi_demo
    Account information:
    ACL information:
        192.168.221.0/24
[root@ex333server init.d]# service tgtd restart
Stopping SCSI target daemon: Stopping target framework daemon
                                                           [  OK  ]
Starting SCSI target daemon: Starting target framework daemon

[root@ex333server init.d]# tgtadm --lld iscsi --op show --mode target
[root@ex333server init.d]#

通过命令创建的iscsi共享在系统重启或服务重启后消失。


2. 通过配置文件创建iscsi共享:
vim /etc/tgt/targets.conf
<target iqn.2012-05.com.example:ex333server.demo>
    backing-store /dev/vg_iscsi/lv_iscsi_demo
    initiator-address 192.168.221.0/24
</target>

<target iqn.2012-05.com.example:ex333server.target244>
    backing-store /dev/vg_iscsi/lv_iscsi_244
    initiator-address 192.168.221.244
</target>
         

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/416a1bf2a5fd34cb56bcd15a8be87d8e.html