Chinaunix首页 | 论坛 | 博客
  • 博客访问: 242296
  • 博文数量: 33
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 480
  • 用 户 组: 普通用户
  • 注册时间: 2019-01-22 08:36
个人简介

专注虚拟化性能优化,硬件显卡网卡虚拟加速,面向容器的轻量虚拟化开发 永远的Linux Geeker!

文章分类

全部博文(33)

分类: 虚拟化

2019-01-27 06:01:57

本文主要介绍如何在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* directly.

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
阅读(5801) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~