Friday, June 19, 2009

Manual scripts for performing the functions of VBS

We'll have a series of documents explaining the design and implementation of the Virtual Block Store (VBS) system.

This post presents the basic manual steps to complete the VBS functions: create a new logical volume, attach it to some Xen DomU VM, detach it from the VM, create a snapshot of it, delete the snapshot, and delete the volume. The manual scripts are based on existing softwares, including LVM (Logical Volumen Manager), ISCSI, and Xen.

Test steps for creating, attaching and detaching volumes:
1) create a new volume on the volume server:
lvcreate -n gxmVol01 -L32M /dev/vg
2) export a new iscsi target:on the volume server
ietadm --op new --tid=2 --params Name=iqn.2009-03.edu.iu.cgl:cglch.lun0
ietadm --op new --tid=2 --lun=0 --params Path=/dev/vg/gxmVol01
3) discover and login the new iscsi target from a Xen dom0:
iscsiadm --mode discovery --type sendtargets --portal 192.168.1.254:3260
iscsiadm --mode node --targetname iqn.2009-03.edu.iu.cgl:cglch.lun0 --portal 192.168.1.254:3260 --login
After log-in, check the disk directory for the newly created ISCSI device: ls /dev/disk/by-path
4) do block-attach in Xen dom0 to attach the iscsi block device to a domU:
xm block-attach ttylinux phy:/dev/disk/by-path/ip-192.168.1.254:3260-iscsi-iqn.2009-03.edu.iu.cgl:cglch.lun0-lun-0 /dev/sdb w
5) to detach a volume from a domU, do xm block-detach in dom0:
xm block-detach ttylinux /dev/sdb
Note: don't do "xm block-attach" while the block device is mounted on the corresponding domU VM. If there is no xenconsole connected to the VM when the block-detach happens, you will get an error the next time you try to connect to the VM through xenconsole, and it's probable that you'll never be able to login to the VM again by xenconsole. So always remember to do umount before block-detach.
6) logout from the iscsi target in dom0:
iscsiadm --mode node --targetname iqn.2009-03.edu.iu.cgl:cglch.lun0 --portal 192.168.1.254:3260 --logout
7) delete the iscsi target from the volume server:
ietadm --op delete --tid=2
8) create a snapshot of a volume:
lvcreate --size 32m --snapshot --name gxmSnap01 /dev/vg/gxmVol1
9) delete the volume or snapshot:
lvremove /dev/vg/gxmVol1

No comments: