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 <size> -n <logical volume name> <volume group name>

- 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 <physical partition>  // make sure you have a separate partition
sudo vgcreate <volume group name> <physical partition>  // create the volume group based on physical partition 
sudo lvcreate -L <size> -n <logical volume name> <volume group name>  

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 <initiator-address> #iqn address for initiator
Lun <lun-number> Path=<path-to-volume>,Type=<volume-type> #volume information, local image file and partition use fileio and LVM or RAID volume use blockio.
initiator-address <initiator-ip-address> #initiator ip address
incominguser <target-user>  <target-password>   # 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

认真的柯南

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值