2011年1月17日 星期一

Linux iSCSI Target(Server)

套件軟體
scsi-target-utils-0.0-6.20091205snap.el5_4.1

1.      iSCSI Target Service
[root@www ~]# service tgtd start
Starting SCSI target daemon: Starting target framework daemon

2.     定義iSCSI target 名稱
[root@www ~]# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2011-01.com.catchlink:storage.disk1
[root@www ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2011-01.com.catchlink:storage.disk1
    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:
    ACL information:

3.     增加邏輯 Lun  (/dev/hdb4)
[root@www ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hdb4

[root@www ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2011-01.com.catchlink:storage.disk1
    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: 20012 MB
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: /dev/hdb4
    Account information:
    ACL information:

4.     設定iSCSI Target 存取
[root@www ~]# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

[root@www ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2011-01.com.catchlink:storage.disk1
    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: 20012 MB
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: /dev/hdb4
    Account information:
    ACL information:
        ALL
-I: ALL表示沒限制; 如果要限制 ex: –I:192.168.1.1則限制這IP存取

5.     重啟 iSCSI Target Service
[root@www ~]# service tgtd restart
Stopping SCSI target daemon: Stopping target framework daemon
                                                           [  確定  ]
Starting SCSI target daemon: Starting target framework daemon

[root@www ~]# netstat -na |grep -w 3260
tcp        0      0 0.0.0.0:3260                0.0.0.0:*            LISTEN     
tcp        0      0 :::3260                     :::*                LISTEN     

6.     編輯重開機自動mount Lun
[root@www ~]# vi /etc/rc.local
 /usr/sbin/tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2010.01.com.catchlink:storage.disk1
 /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hdb4
 /usr/sbin/tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

[root@www tgt]# tgt-admin --dump > /etc/tgt/targets.conf

7.     自動啟用服務
[root@www ~]# chkconfig tgtd on
[root@www ~]# chkconfig tgtd --list
tgtd            0:關閉  1:關閉  2:開啟  3:開啟  4:開啟  5:開啟  6:關閉

沒有留言:

張貼留言