- target이름 설정
$ tgtadm --lld iscsi -o new -m target --tid 1 -T iqn.test.storage
#iqn.test.storage이 값은 임의 변경 가능하고, 물리적인 디스크와 직접 연결하는 부분이 아님
 
- target설정상태 확인
$ tgtadm --lld iscsi -o show -m target
Target 1: iqn.test.storage
    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:
    ACL information:
 
- 설정한 target에 볼륨지정
$ tgtadm  --lld iscsi -o new -m logicalunit --tid 1 --lun 1 -b /dev/sda5
 
- 볼륨 등록 확인
$ tgtadm  --lld iscsi -o show -m target
Target 1: iqn.test.storage
    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:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 10619 MB, Block size: 512
            Online: Yes
            Removable media: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sda5
            Backing store flags:
    Account information:
    ACL information:
 
- target 접근 제한 적용
$ tgtadm --lld iscsi --op bind --mode target --tid 1 --initiator-address 192.168.100.10
 
- target에 계정등록
$ tgtadm  --lld iscsi --op new --mode account --user test --password iscsitest
 
- 등록한 계정리스트 확인하기
$ tgtadm  --lld iscsi --op show --mode account
Account list:
   test
 
- 등록한 볼륨에 계정 연동하기
$ tgtadm --lld iscsi --op bind --mode account --tid 1 --user test
 
- 볼륨과 계정연동 확인
$ tgtadm --lld iscsi --op show --mode target
Target 1: iqn.test.storage
    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:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 10619 MB, Block size: 512
            Online: Yes
            Removable media: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sda5
            Backing store flags:
    Account information:
       test
    ACL information:
       192.168.100.10
 
- 등록한 target을 설정파일로 저장하기(기존파일은 백업 수행)
$ mv /etc/tgt/targets.conf /etc/tgt/targets.conf_ori
$ tgt-admin --dump > /etc/tgt/targets.conf
 
- 생성된 파일 정보 확인
$ cat /etc/tgt/targets.conf
default-driver iscsi
<target iqn.test.storage>
        backing-store /dev/sda5
        incominguser test iscsitest
       # 패스워드 지정시, 12자~16자 위안에서 설정
       initiator-address 192.168.100.10
</target>
 
- target 재시작
$ /etc/init.d/tgtd restart
Stopping SCSI target daemon: Stopping target framework daemon
                                                          [  OK  ]
Starting SCSI target daemon: Starting target framework daemon
 
- 패키지 설치
$ yum install -y iscsi-initiator-utils
 
- 서비스 활성화 후 실행
$ /etc/init.d/iscsi start
$ /etc/init.d/iscsid start
$ chkconfig iscsi on; chkconfig iscsid on;
 
- target에서 지정한 인증정보 적용하기
$vi /etc/iscsi/iscsid.conf
#node.session.auth.username = username
#node.session.auth.password = password
#discovery.sendtargets.auth.username = username
#discovery.sendtargets.auth.password = password
# 4군데 주석풀고 지정한 계정입력
 
- iscsid 서비스 재시작
$ /etc/init.d/iscsid restart
Stopping iSCSI daemon:                                     [  OK  ]
Starting iSCSI daemon:                                     [  OK  ]
 
- target 정보 확인
$ iscsiadm --mode discovery --type sendtargets --portal 192.168.10.10 (target서버ip)
#192.168.10.10:3260,1 iqn.test.storage (정상적일 경우, 해당 정보가 출력되며, 기타 문제가 발생할 경우 "iscsiadm: No portals found" 메시지를 뿌린다.
 
- target 서버 연결
$ iscsiadm --mode node --targetname iqn.test.storage --portal 192.168.10.10 -l -n node.startup -v automatic
 
- 디스크 연결정보 확인
$ fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1452     3172837+  82  Linux swap / Slaris
/dev/sda4            1453        2610     9301635    5  Extended
/dev/sda5            1453        2610     9301603+  83  Linux
Disk /dev/sdb: 10.6 GB, 10618804224 bytes
64 heads, 32 sectors/track, 10126 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdb doesn't contain a valid partition table
 
 
 # 기존에 없던 /dev/sdb 장비 출력확인 되었으면, /dev/sdb장치 파티션 구성하여 사용하면 됨.
 
 
 
 
- 부팅후 활성화를 위해 적용
$ vi /etc/fstab
...
/dev/sdb1               /data                   ext3    _netdev         0 0
 
No comments to display
No comments to display