ISCSI 是一种供硬件设备使用可以在IP协议上运行运行的SCSI指令集:

1.准备用来做scsi设备的磁盘,可以是分区,整块磁盘,因为没有多的分区,所以用dd建一个1G的块设备

   dd if=/dev/zero of=/src/iscsi/disk.img bs=1M count=1000

2.安装 以下软件包:

 

 yum  -y install scsi-target-utils 

3.修改配置文件:
[root@storge iscsi]# vim /etc/tgt/targets.conf



    backing-store /src/iscsi/disk     虚拟设备
    incominguser jim 123       设置用户密码   
    initiator-address   192.168.0.0/24  设置允许的网段
    write-cache off         不允许快取

重启服务/etc/init.d/tgtd restart   默认端口3260

4.设置防火墙:

iptables -A INPUT -s  192.168.0.0/24 -p tcp --dport 3260 -j ACCEPT

5.查看启用的设备:

[root@storge iscsi]# tgt-admin --show
Target 1: iqn.2013-04.com.test:jimdisk
    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
            Readonly: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
    Account information:
        jim
    ACL information:
        ALL

二.客户端设置:

1.包安装:yum -y install 'iscsi*'

2.修改/etc/iscsi/iscsid.conf

node.session.auth.username = jim
node.session.auth.password = 123

discovery.sendtargets.auth.username = jim
discovery.sendtargets.auth.password = 123

3.取得iscsi设备:

[root@cluster1 ~]# iscsiadm -m node -T iqn.2013-04.com.test:jimdisk -p 19.134.90.169 -l
Logging in to [iface: default, target: iqn.2013-04.com.test:jimdisk, portal: 19.134.90.169,3260] (multiple)
Login to [iface: default, target: iqn.2013-04.com.test:jimdisk, portal: 19.134.90.169,3260] successful.

 

注意:selinux与iptables