User Tools

Site Tools


public:iscsi:logout

log out of iSCSI targets

For a complete logout of an iSCSI device - especially by keeping other active iSCSI connections - it is necessary to end all related device connections step by step in the right order. This affects all devices related to the iSCSI connection. Because of the complexity of the logout process and the participation of many different devices a separate section was dedicated to the process.

Remove LVM device connection

At first all processes have to be finished that access iSCSI devices. On KVM hosts this can be running vhosts. When partitions or LVM partitions on iSCSI devices are mounted, they have to be unmounted. On KVM hosts this can affect snapshots.

Afterwards all LVM devices on iSCSI devices will be set to inactive. The activity flags of the LVM devices are always related to the current KVM host. It is possible without problems to deactivate LVM devices in one host that are still in use on other hosts.

root@kvm55:~# lvs
  LV              VG           Attr   LSize   Origin …
  images          vg           -wi-ao 200.00g
  lv_dbslave5501  vg           -wi-a-  20.00g
  lv_dbserver5501 vg3_dbserver -wi-ao   4.98g
  lv_nas5501      vg3_nas      -wi-ao 499.98g

root@kvm55:~# lvchange –an /dev/vg3_dbserver/lv_dbserver5501
root@kvm55:~# lvchange –an /dev/vg3_nas/lv_nas5501

root@kvm55:~# lvs
  LV              VG           Attr   LSize   Origin …
  images          vg           -wi-ao 200.00g
  lv_dbslave5501  vg           -wi-a-  20.00g
  lv_dbserver5501 vg3_dbserver -wi---   4.98g
  lv_nas5501      vg3_nas      -wi--- 499.98g
root@kvm55:~# vgs
  VG           #PV #LV #SN Attr   VSize   VFree
  vg             1   2   0 wz--n-   1.79t 1.58t
  vg3_dbserver   1   1   0 wz--n-   4.98g    0 
  vg3_nas        1   1   0 wz--n- 499.98g    0 

root@kvm55:~# vgchange –an /dev/vg3_dbserver
  0 logical volume(s) in volume group „vg3_dbserver“ now active
root@kvm55:~# vgchange –an /dev/vg3_nas
  0 logical volume(s) in volume group „vg3_nas“ now active

root@kvm55:~# vgs
  VG           #PV #LV #SN Attr   VSize   VFree
  vg             1   2   0 wz--n-   1.79t 1.58t
  vg3_dbserver   1   1   0 wz--n-   4.98g    0 
  vg3_nas        1   1   0 wz--n- 499.98g    0 

The command vgs does not display the changes of the volume group changes:

root@kvm55:~# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/dm-2  vg3_nas      lvm2 a-   499.98g    0 
  /dev/dm-4  vg3_dbserver lvm2 a-     4.98g    0 
  /dev/sda4  vg           lvm2 a-     1.79t 1.58t

root@kvm55:~# pvchange –xn /dev/dm-2
  Physical volume „dev/dm-2“ changed
  1 physical volume changed / 0 physical volumes not changed
root@kvm55:~# pvchange –xn /dev/dm-4
  Physical volume „dev/dm-4“ changed
  1 physical volume changed / 0 physical volumes not changed
root@kvm55:~# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/dm-2  vg3_nas      lvm2 --   499.98g    0 
  /dev/dm-4  vg3_dbserver lvm2 --     4.98g    0 
  /dev/sda4  vg           lvm2 a-     1.79t 1.58t

Please note: The command pvchange uses the option -x while the other commands use the option -a. Furthermore the command pvchange needs the DM device as option ('/dev/dm-2' or '/dev/dm-4', respectively).

Remove DM devices

With the commands related to LVM it is not possible to disable LVM devices completely. When logging out of iSCSI after the actions mentioned above, LVM commands like pvs, vgs, lvs and so on cannot be executed anymore.

As last resort all DM devices have to be removed before. But it has to be made sure to only remove the devices related to the iSCSI device to be removed. When removing the wrong device data loss may occur. Usually the command dmsetup does not allow to remove still active devices.

root@kvm55:~# dmsetup ls
vg-images                    (252:0)
vg-lv_dbslave5501            (252:1)
350002ac21d632071            (252:2)
vg3_dbserver-lv_dbserver5501 (252:3)
350002ac21d622071            (252:4)
vg3_nas-lv_nas5501           (252:5)

In the example above the DM devices No. 2, 3, 4 and 5 have to be removed. The order of removal is important: First the LVM partitions are removed (devices 3 and 5), then the physical devices can be removed (devices 2 and 4).

root@kvm55:~# dmsetup remove /dev/dm-5
root@kvm55:~# dmsetup remove /dev/dm-3
root@kvm55:~# dmsetup remove /dev/dm-4
root@kvm55:~# dmsetup remove /dev/dm-2

While removing the DM devices 2 and 4 the multipath devices also disappeared.

root@kvm55:~# multipath –l
(no output)

Log out of iSCSI

After the preparations descibed above log-out of iSCSI will be possible:

root@kvm55:~# iscsiadm –m node –T iqn.2000-05.com.3pardata:24820002ac002071 –u
Logging out of session [sid: 3, target: iqn.2000-05.com.3pardata:24820002ac002071, portal: 192.168.1.139,3260,482]
Logout of [sid: 3, target: iqn.2000-05.com.3pardata:24820002ac002071, portal: 192.168.1.139,3260,582]:successful

root@kvm55:~# iscsiadm –m node –T iqn.2000-05.com.3pardata:25820002ac002071 -u
Logging out of session [sid: 4, target: iqn.2000-05.com.3pardata:25820002ac002071, portal: 10.48.2.10,3260,482]
Logout of [sid: 4, target: iqn.2000-05.com.3pardata:25820002ac002071, portal: 10.48.2.11,3260,582]:successful

previous chapter | contents

public/iscsi/logout.txt · Last modified: 2016/12/16 20:38 by T Kornack