Chinaunix首页 | 论坛 | 博客
  • 博客访问: 279940
  • 博文数量: 56
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 642
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-16 15:11
文章分类

全部博文(56)

文章存档

2017年(6)

2015年(3)

2014年(41)

2013年(6)

我的朋友

分类: 虚拟化

2014-07-29 16:03:02


Server configuration:


1.Install iscsi-initiator-utils package.


# yum -y install iscsi-target-utils

# service tgtd restart

 

2.Define iSCSI target on Server.

 

    tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2014-07.com.redhat:demo-test

 

3.Show all targets

 

    tgtadm --lld iscsi --op show --mode target

 

4.Add logical unit to target id which is associated with targetname.

 

    tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdc1

 

eg:# tgtadm --lld iscsi --op show --mode target

Target 1: iqn.2014-07.com.example:demo-test

    System information:

        Driver: iscsi

        State: ready

    I_T nexus information:

    LUN information:

        LUN: 0

            Type: controller

            SCSI ID: IET     00020000

            SCSI SN: beaf20

            Size: 0 MB, Block size: 1

            Online: Yes

            Removable media: No

            Prevent removal: No

            Readonly: No

            Backing store type: null

            Backing store path: None

            Backing store flags:

        LUN: 1

            Type: disk

            SCSI ID: IET     00020001

            SCSI SN: beaf21

            Size: 10742 MB, Block size: 512

            Online: Yes

            Removable media: No

            Prevent removal: No

            Readonly: No

            Backing store type: rdwr

            Backing store path: /dev/sdc1

            Backing store flags:

    Account information:

    ACL information:

        ALL

 

You can configure it in targets.conf configuration file.

# cat /etc/tgt/targets.conf

    backing-store /dev/sdc1

 

# service tgtd restart

 

Client configuration:


1.Install iscsi-initiator-utils package.


# yum -y install iscsi-target-utils

# service tgtd restart


2.Use iscasiadm to discovery and login to iSCSI targets:

   Discover targets at a given IP address:
        iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.10 --discover

 

   Login, must use a node record id found by the discovery:
        iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260 --login

 

   Logout:
        iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260 --logout

 

   List node records:
        iscsiadm --mode node

 

   Display all data for a given node record:
        iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260

 

Example to use iscsi storage to install guest with qcow2 format:

Server:

# qemu-img create -f qcow2 -o preallocation=full qcow2-8G.img 8G

Formatting 'qcow2-8G.img', fmt=qcow2 size=8589934592 encryption=off cluster_size=65536 preallocation='full'


# cat /etc/tgt/targets.conf

    backing-store /var/lib/libvirt/images/qcow2-8G.img


# service tgtd restart

Stopping SCSI target daemon:                               [  OK  ]

Starting SCSI target daemon:                               [  OK  ]

 

Client:

# iscsiadm --mode discoverydb --type sendtargets --portal 10.66.7.56 --discover

10.66.7.56:3260,1 iqn.2014-07.com.example:tzheng-qcow2

 

# qemu-img info iscsi://10.66.7.56:3260/iqn.2014-07.com.example:tzheng-qcow2/1

image: iscsi://10.66.7.56:3260/iqn.2014-07.com.example:tzheng-qcow2/1

file format: qcow2

virtual size: 8.0G (8589934592 bytes)

disk size: unavailable

cluster_size: 65536

Format specific information:

    compat: 0.10

 

# Launch virt-manager,create a iscsi pool.

# virsh pool-dumpxml iscsi

  iscsi

  6d293ea0-eed4-5ba6-3e0f-212ae50f5ed5

  8591507456

  8591507456

  0

 

   

   

 

 

    /dev/disk/by-path

   

      0755

      -1

      -1

   

 

 

Then use virt-manager to install a new guest using the volume in iscsi pool,set it's format as qcow2.

# virsh dumpxml iscsi-test


 
 
 
 
 

 

Notice:

For qcow2 format image,you should add preallocation=full parameter,else iscsi will only discovery actual size of the

阅读(1439) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~