Thursday 12 April 2012

iscsi server side configuration in rhel6

[root@station1 Desktop]# yum install -y scsi*
[root@station1 Desktop]# yum install -y libibver*
[root@station1 Desktop]# yum install -y libml*
[root@station1 Desktop]# yum install -y librdmacm*
[root@station1 Desktop]# yum install -y perl-Config-General

create an empty partition (in my practise its sda4). dont convert it to linuxlvm system. just create a partition write and save it and follow the steps

[root@station1 Desktop]# pvcreate /dev/sda4
  Writing physical volume data to disk "/dev/sda4"
  Physical volume "/dev/sda4" successfully created
[root@station1 Desktop]# vgcreate vg_ranji /dev/sda4
  Volume group "vg_ranji" successfully created
[root@station1 Desktop]# vgdisplay
  --- Volume group ---
  VG Name               vg_ranji
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               40.50 GiB
  PE Size               4.00 MiB
  Total PE              10369
  Alloc PE / Size       0 / 0  
  Free  PE / Size       10369 / 40.50 GiB
  VG UUID               D8N5om-uk36-XPRR-elwS-PVNk-VmcM-IrGPYH
  
[root@station1 Desktop]# lvcreate -n lv_lun0 -L 40G vg_ranji
  Logical volume "lv_lun0" created
[root@station1 Desktop]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_ranji/lv_lun0
  VG Name                vg_ranji
  LV UUID                JuJdn2-pRTl-FURv-HlBD-n3KA-wUQZ-KcHCWD
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                40.00 GiB
  Current LE             10240
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@station1 Desktop]# vim /etc/tgt/targets.conf

 37
 38 <target iqn.2012-26.com.example:ranji.lun0>           ----------> remove # add edit these lines
 39     backing-store /dev/vg_ranji/lv_lun0
 40     initiator-address 10.65.62.30
 41 </target>
 42
[root@station1 Desktop]# chkconfig tgtd on
[root@station1 Desktop]# service tgtd restart
Stopping SCSI target daemon: not running                   [FAILED]
Starting SCSI target daemon:                               [  OK  ]


[root@station1 Desktop]# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2012-26.com.example:ranji.lun0
    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: 42950 MB, Block size: 512
            Online: Yes
            Removable media: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/vg_ranji/lv_lun0
            Backing store flags:
    Account information:
    ACL information:
        10.65.62.30
[root@station1 Desktop]# yum install -y iscsi*
[root@station1 Desktop]# chkconfig iscsid on

dont chkconfig iscsi on because it wont start up when system boots we have to start it manually after system boots

[root@station1 Desktop]# service iscsid start
[root@station1 Desktop]# service iscsi start

first test in server itself with the following steps

[root@station1 Desktop]# iscsiadm --mode discovery --type sendtargets --portal 10.65.62.30
10.65.62.30:3260,1 iqn.2012-26.com.example:ranji.lun0
[root@station1 Desktop]# cat /proc/partitions
major minor  #blocks  name

   8        0  156290904 sda
   8        1     512000 sda1
   8        2   30720000 sda2
   8        3          1 sda3
   8        4   42475860 sda4
   8        5    1951866 sda5
   8        6   48829536 sda6
   8        7   29296640 sda7
   8        8     487424 sda8
   8        9    1998848 sda9
 253        0   41943040 dm-0
[root@station1 Desktop]# iscsiadm --mode node --targetname iqn.2012-26.com.example:ranji.lun0 --portal 10.65.62.30 --login
Logging in to [iface: default, target: iqn.2012-26.com.example:ranji.lun0, portal: 10.65.62.30,3260] (multiple)
Login to [iface: default, target: iqn.2012-26.com.example:ranji.lun0, portal: 10.65.62.30,3260] successful.
[root@station1 Desktop]# cat /proc/partitions
major minor  #blocks  name

   8        0  156290904 sda
   8        1     512000 sda1
   8        2   30720000 sda2
   8        3          1 sda3
   8        4   42475860 sda4
   8        5    1951866 sda5
   8        6   48829536 sda6
   8        7   29296640 sda7
   8        8     487424 sda8
   8        9    1998848 sda9
 253        0   41943040 dm-0
   8       32   41943040 sdc           -----------> after login u could see a new partition sdc
[root@station1 Desktop]# iscsiadm --mode node --targetname iqn.2012-26.com.example:ranji.lun0 --portal 10.65.62.30 --logout
Logging out of session [sid: 6, target: iqn.2012-26.com.example:ranji.lun0, portal: 10.65.62.30,3260]
Logout of [sid: 6, target: iqn.2012-26.com.example:ranji.lun0, portal: 10.65.62.30,3260] successful.
[root@station1 Desktop]# cat /proc/partitions
major minor  #blocks  name

   8        0  156290904 sda
   8        1     512000 sda1
   8        2   30720000 sda2
   8        3          1 sda3
   8        4   42475860 sda4
   8        5    1951866 sda5
   8        6   48829536 sda6
   8        7   29296640 sda7
   8        8     487424 sda8
   8        9    1998848 sda9
 253        0   41943040 dm-0


No comments:

Post a Comment