QEMU后端存储设置之ISCSI后端

本文主要介绍如何在Debian中安装iscsi-target,过程主要分三步,安装服务并启动,创建存储块,最后发布给客户端。

1.1 set up iscsi-target

 

1.1.1 Install essential softwares

sudo apt-get install iscsitarget iscsitarget-dkms

iscsitarget & iscsitarget-dkms, the main packages to support iscsi service.

1.1.2 Start up iscsi-target service

- change /etc/default/iscsitarget

ISCSITARGET_ENABLE=true

- reboot iscsitarget service

sudo service iscsitarget restart

- set iscsitarget service as an auto-boot service

sudo update-rc.d iscsitarget enable 

- disable auto-boot if you want:

sudo update-rc.d iscsitarget disable

1.2 Create new volumes for iscsi-target

Iscsi-target could use different type volumes, like Image file, real disk partition, LVM partition and RAID partition. Here I am using the LVM partition since it is more flexible comparing with other types.

1.2.1 LVM

To use LVM, we will need an volume group first, it's based on physical volume. Then we could create the logical volume from volume group, and the logical volume will be used by iscsi-target.

- Sometimes, you installed the OS with a LVM support, then you could get a volume group at the boot time, and the logical volume is what you only need.

sudo lvcreate -L  -n  

- Sometimes, you installed the OS on physical driver, that's fine, below is what you need do.

sudo apt-get install lvm2 // install lvm first
sudo pvcreate   // make sure you have a separate partition
sudo vgcreate    // create the volume group based on physical partition 
sudo lvcreate -L  -n    

1.2.2 Real Partition

You could use /dev/sda* or /dev/hda* directily.

1.2.3 Image file

dd if=/dev/zero of=test.img bs=1M count=1000

This will create a image file with size 1G, or you could change to the size you want.

1.3 Export new volume to client

- modify the configuration file for iscsi-target

vim /etc/iet/ietd.conf

- add configuration for new volume

Target  #iqn address for initiator
Lun  Path=,Type= #volume information, local image file and partition use fileio and LVM or RAID volume use blockio.
initiator-address  #initiator ip address
incominguser      # authentication

Below is an example:

Target iqn.2015-12.hlinux.server:target0 
Lun 0 Path=/dev/hLinux-vg/iscsi-001,Type=blockio 
initiator-address 15.244.209.199 
incominguser hlinux secrete 

- restart iscsi-target service

sudo service iscsitarget restart

你可能感兴趣的:(Storage,QEMU)