ISCSI on CentOS

From PrgmrWiki

on the server (target)

yum install iscsi-initiator-utils
yum install scsi-target-utils
/etc/init.d/tgtd start
[root@larry vblade]# tgtadm --lld iscsi --op new --mode target --tid 1 -T larry:storage.disk2.teste 
 [root@larry ~]#  tgtadm --lld iscsi --op new --mode target --tid 1 -T larry:storage.disk2.teste
 [root@larry ~]# tgtadm --lld iscsi --op show --mode target
 Target 1: larry:storage.disk2.teste
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
    Account information:
    ACL information:
[root@larry ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /var/vblade/first 
[root@larry ~]# tgtadm --lld iscsi --op show --mode target
Target 1: larry:storage.disk2.teste
   System information:
       Driver: iscsi
       State: ready
   I_T nexus information:
   LUN information:
       LUN: 0
           Type: controller
           SCSI ID: deadbeaf1:0
           SCSI SN: beaf10
           Size: 0 MB
           Online: Yes
           Removable media: No
           Backing store: No backing store
       LUN: 1
           Type: disk
           SCSI ID: deadbeaf1:1
           SCSI SN: beaf11
           Size: 6442 MB
           Online: Yes
           Removable media: No
           Backing store: /var/vblade/first
   Account information:
   ACL information:


# wide open... insecure
[root@larry vblade]# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

on the client( initiator)

yum install iscsi-initiator-utils

/etc/init.d/iscsi start

[root@curly ~]# iscsiadm -m discovery -t sendtargets -p 69.12.128.193 
69.12.128.193:3260,1 larry:storage.disk2.teste
[root@curly ~]# iscsiadm --mode node --targetname larry:storage.disk2.teste --portal 69.12.128.193:3260 --login


Now, type dmesg and it shows you /dev/sdc... but only a moron uses /dev/sdX to access shared storage, so we will access it via /dev/disk/by-path/ - in this case,

/dev/disk/by-path/ip-69.12.128.193:3260-iscsi-larry:storage.disk2.teste-lun-1