Libvirt虚拟化管理及计算环境的规划及部署

本文介绍了如何使用Libvirt进行虚拟化管理,并重点讲解了利用startwind配置iSCSI服务器来实现共享磁盘存储的步骤,为计算环境规划和部署提供指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

存储采用iSCSI磁盘存储,需要提前准备iSCSI服务器共享磁盘。
本实验采用startwind配置iSCSI共享存储。
参考🔗:https://cloud.tencent.com/developer/article/1863279

**NAT模式**
<network> 
        <name>cxx_nat</name>
        <bridge name="virbr0" />
        <forward mode="nat"/>
         <ip address="192.168.1.1" netmask="255.255.255.0"> //配置宿主机与虚拟机相连接口的ip地址,此地址用于NAT转换后的ip地址
         </ip>
		 <dhcp> //DHCP功能是桥给虚拟机分配ip地址,此地址需要与接口ip地址在同一个网段
	     <range start="192.168.1.2" end="192.168.1.25" />
	    </dhcp>
   //宿主机转换的NAT地址池,一般使用宿主机的ip地址而不使用此地址池。使用此地址池中的ip用于转换时,需要公司向ISP申请一段ip地址用于nat转换,在公网上,ISP会发布关于此段公网ip的回路由信息,此时NAT转换的ip才能回到公司。
	//<nat>
	//<address start='1.2.3.4' end='1.2.3.10'/>
	//</nat>   
 </forward>
 **桥模式**
 <network>
	<name>cxx-bridge</name>
	<forward mode="bridge"/>
	<bridge name="br0"/>
 </network>
**资源池配置**
<pool type="iscsi"> 
    <name>cxx_iscsi</name>
	<source>
	    <host name='192.168.25.132' port='3260'/> //ISCSI服务器ip地址,以及默认端口3260
		<device path="iqn.2008-08.com.starwindsoftware:wyh-pc-cxx"/>//利用startwind搭建的共享iSCSI存储的path,如图
		
	</source>
	<target>
		<path>/dev/disk/by-path</path>
	</target>
</pool>
**虚拟机配置** 
<domain type='kvm'> 
     <name>cxx</name>  //域名-虚拟机名称
     <uuid>f5b8c05b-9c7a-3211-49b9-2bd635f7e2aa</uuid>
     <memory>524288</memory>  //内存大小,以K为单位
     <currentMemory>524288</currentMemory>
     <vcpu>2</vcpu> //虚拟CPU个数
     <os>
       <type arch='x86_64' machine='pc'>hvm</type> //x86_64架构的hvm(全虚拟化)虚拟机
       <boot dev='cdrom'/> //从光盘启动
       <boot dev='hd'/> //从硬盘启动,若没有此配置,则每次启动虚拟机都会进入安装界面
    </os>
    <features>
      <acpi/>
    </features>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>  //供virsh使用
    <devices>
//调用的资源池中的虚拟磁盘
    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw'/> //默认raw格式
      <source pool='cxx_iscsi' volume='unit:0:0:0'/>//指定存储池名以及卷名
      <target dev='hda' bus='ide'/>
    </disk>
//此种方式指定的磁盘需要自己手动进行管理(libvirt不帮忙进行管理),所以此处不使用
      <disk type="file" device="disk">  //镜像OS磁盘路径
        <driver name="qemu" type="raw"/>
        <source file="/opt/cxx_centos6.qcow2"/> 
        <target dev="vda" bus="virtio"/>
        <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
      </disk>
//指定虚拟机操作系统的路径
      <disk type="file" device="cdrom">  //镜像OS路径
        <driver name="qemu" type="raw"/>
        <source file="/cxx/cxx_virtualcomputer/CentOS-6.5-x86_64-bin-DVD1.iso"/>
        <target dev="hdb" bus="ide"/>
        <readonly/>
        <address type="drive" controller="0" bus="1" target="0" unit="0"/>
      </disk>
//指定虚拟机调用的资源池内的网络资源
      <interface type='network'> 
		//type参数可选:network、bridge、ethernet
		//选用network时,则会调用虚拟网络中的相关配置,其他方式需要自己创建相应东西,例如网桥。
		//所以此处选用调用network内的网络
        <source network='cxx_nat'/> //source参数的名字对应你需要选择的资源池内的网络中的配置的名字,此处对应nat方式中的名字
        <mac address="00:0c:30:81:5a:14"/>
	<video>
      <model type='vga' vram='16384' heads='1'>
      <acceleration accel3d='no' accel2d='no'/>
      </model>
   </video>
      </interface>
//输入输出设备以及设置图形输出
      <input type='mouse' bus='ps2'/>
      <graphics type='vnc' port='5942' autoport="no" listen='0.0.0.0'/> //图形界面参数
      <console type='pty'>  // 串口配置
        <target port='0'/>
      </console>
    </devices>
  </domain> 

在这里插入图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值