콘텐츠로 이동


Centos6에서 iscsi 연결하기

[![image.png](http://wiki.igoni.kr/uploads/images/gallery/2026-02/scaled-1680-/Wzjimage.png)](http://wiki.igoni.kr/uploads/images/gallery/2026-02/Wzjimage.png)
perplexity에서 생성한 AI이미지

서버구성

  1. 패키지 설치 shell $ yum install -y scsi-target-utils libibverbs libibverbs-devel librdmacm librdmacm-devel
  2. 데몬 실행 및 서비스 활성화 후 실행 shell $ chkconfig tgtd on; /etc/init.d/tgtd start $ chkconfig --list | grep tgtd tgtd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

  3. target이름 설정 ```shell $ tgtadm --lld iscsi -o new -m target --tid 1 -T iqn.test.storage

    #iqn.test.storage이 값은 임의 변경 가능하고, 물리적인 디스크와 직접 연결하는 부분이 아님 2. target설정상태 확인shell $ 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: 3. 설정한 target에 볼륨지정shell $ tgtadm  --lld iscsi -o new -m logicalunit --tid 1 --lun 1 -b /dev/sda5 4. 볼륨 등록 확인shell $ 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: 5. target 접근 제한 적용shell $ tgtadm --lld iscsi --op bind --mode target --tid 1 --initiator-address 192.168.100.10 6. target에 계정등록shell $ tgtadm  --lld iscsi --op new --mode account --user test --password iscsitest 7. 등록한 계정리스트 확인하기shell $ tgtadm  --lld iscsi --op show --mode account Account list:    test 8. 등록한 볼륨에 계정 연동하기shell $ tgtadm --lld iscsi --op bind --mode account --tid 1 --user test 9. 볼륨과 계정연동 확인shell $ 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 10. 등록한 target을 설정파일로 저장하기(기존파일은 백업 수행)shell $ mv /etc/tgt/targets.conf /etc/tgt/targets.conf_ori $ tgt-admin --dump > /etc/tgt/targets.conf 11. 생성된 파일 정보 확인shell $ cat /etc/tgt/targets.conf

    default-driver iscsi         backing-store /dev/sda5         incominguser test iscsitest        # 패스워드 지정시, 12자~16자 위안에서 설정        initiator-address 192.168.100.10 12. target 재시작shell $ /etc/init.d/tgtd restart Stopping SCSI target daemon: Stopping target framework daemon                                                           [  OK  ] Starting SCSI target daemon: Starting target framework daemon ```

클라이언트 설정

  1. 패키지 설치 shell $ yum install -y iscsi-initiator-utils
  2. 서비스 활성화 후 실행 shell $ /etc/init.d/iscsi start $ /etc/init.d/iscsid start $ chkconfig iscsi on; chkconfig iscsid on;​
  3. target에서 지정한 인증정보 적용하기 shell $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군데 주석풀고 지정한 계정입력
  4. iscsid 서비스 재시작 shell $ /etc/init.d/iscsid restart Stopping iSCSI daemon:                                     [  OK  ] Starting iSCSI daemon:                                     [  OK  ]
  5. target 정보 확인 shell $ 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" 메시지를 뿌린다.
  6. target 서버 연결 shell $ iscsiadm --mode node --targetname iqn.test.storage --portal 192.168.10.10 -l -n node.startup -v automatic
  7. 디스크 연결정보 확인 ```shell $ 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장치 파티션 구성하여 사용하면 됨.

    8. 부팅후 활성화를 위해 적용 shell $ vi /etc/fstab ... /dev/sdb1               /data                   ext3    _netdev         0 0

클라이언트와 서버 구성 작업

  1. iscsi 사용 중단 ```shell $ iscsiadm  -m node -T iqn.test.storage -p 192.168.10.10 -u Logging out of session [sid: 1, target: iqn.test.storage, portal: 192.168.10.10,3260]

    Logout of [sid: 1, target: iqn.test.storage, portal: 192.168.10.10,3260] successful. 2. 영구적 연결 해제shell $ iscsiadm  -m node -T iqn.test.storage -p 192.168.10.10 -o delete 3. target에 연결세션 확인shell $ tgtadm --lld iscsi --op show --mode session --tid 1 --sid 1 ```







작성일: 2026년 7월 15일 ,  마지막 업데이트: 2026년 7월 15일