kvm vm使用sheepdog存储空间

你的名字 2023-08-17 16:56 232阅读 0赞

1.安装环境

  1. DELL R710 \*2
  2. Centos 6.4
  3. Centos 6.0VM
  4. libvirt 1.1.1
  5. qemu 0.13.50

2.安装libvirt

通过源码安装libvirt,安装libvirt依赖包

  1. yum install libxml2-devel device-mapper-devel libdevmapper python-devel libpciaccess-devel libnl-devel

安装libvirtd

  1. tar -zxvf libvirt-1.1.1.tar.gz
  2. ./configure --with-storage-sheepdog
  3. make
  4. make install

设置libvirtd

  1. mkdir -p /usr/local/var/lock/subsys
  2. cp /etc/rc.d/init.d/functions /usr/local/etc/rc.d/init.d/
  3. cp /usr/local/sbin/libvirtd /usr/sbin/
  4. cp /usr/local/etc/rc.d/init.d/libvirt* /etc/init.d/

启动libvirtd

  1. service libvirtd start

编写libvirtd.xml文件

  1. <domain type='qemu'>
  2. <name>centos6</name>
  3. <uuid>c7a5fdbd-cdaf-9455-926a-d65c16db1809</uuid>
  4. <memory>219200</memory>
  5. <currentMemory>219200</currentMemory>
  6. <vcpu>2</vcpu>
  7. <os>
  8. <type arch='x86_64' machine='pc'>hvm</type>
  9. <boot dev='hd'/>
  10. </os>
  11. <devices>
  12. <emulator>/usr/local/bin/qemu-system-x86_64</emulator>
  13. <disk type='file' device='disk'>
  14. <source file='/tmp/images/centos6.img'/>
  15. <target dev='hda'/>
  16. </disk>
  17. <disk type='network'>
  18. <driver name="qemu" type="raw" io="threads" />
  19. <source protocol="sheepdog" name="myvol">
  20. <host name="10.10.200.228" port="7000"/>
  21. </source>
  22. <target dev="hdb" bus="ide"/>
  23. <address type='drive' controller='0' bus='1' unit='0'/>
  24. </disk>
  25. <interface type='bridge'>
  26. <source bridge='br0'/>
  27. <model type='rtl8139'/>
  28. </interface>
  29. <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
  30. </devices>
  31. </domain>

3.sheepdog创建vdi

有两种方式创建vdi,一种是通过qemu-img来创建

  1. qemu-img create sheepdog:test 40G

另外一种,通过编写libvirtd的xml文件进行创建volume

首先创建pool,编写pool.xml

  1. vi pool.xml
  2. <pool type="sheepdog">
  3. <name>mysheeppool</name>
  4. <source>
  5. <name>mysheeppool</name>
  6. <host name='10.10.200.228' port='7000'/>
  7. </source>
  8. </pool>

创建pool

  1. virsh pool-create pool.xml

创建volume,编写volume.xml

  1. <volume>
  2. <name>myvol</name>
  3. <key>sheep/myvol</key>
  4. <source>
  5. </source>
  6. <capacity unit='bytes'>53687091200</capacity>
  7. <allocation unit='bytes'>53687091200</allocation>
  8. <target>
  9. <path>sheepdog:myvol</path>
  10. <format type='unknown'/>
  11. <permissions>
  12. <mode>00</mode>
  13. <owner>0</owner>
  14. <group>0</group>
  15. </permissions>
  16. </target>
  17. </volume>

创建volume

  1. virsh vol-create mysheeppool vol.xml

查看sheepdog vdi

  1. [root@euca-clc images]# dog vdi list
  2. Name Id Size Used Shared Creation time VDI id Copies Tag
  3. 10.10.200.228:7000:test1.img 0 10 GB 0.0 MB 0.0 MB 2013-08-21 13:32 24baa2 2
  4. test 0 40 GB 0.0 MB 0.0 MB 2013-08-21 13:18 7c2b25 2
  5. myvol 0 50 GB 0.0 MB 0.0 MB 2013-08-21 13:55 b54274 2

4.启动VM

启动vm

  1. virsh create libvirtd.xml

在这里sheepdog是作为vm的数据盘使用,通过vnc可以查看到新添加磁盘sdb

Center

发表评论

表情:
评论列表 (有 0 条评论,232人围观)

还没有评论,来说两句吧...

相关阅读

    相关 KVM磁盘空间调整

    KVM磁盘空间调整 使用KVM构建虚拟化平台是一个把Linux机器快速搭建虚拟化平台的优秀工具,如果前期规划问题,导致磁盘空间不够用,通过可视化工具无法实现磁盘的动态扩展