• kvm qemu创建虚拟机


    1. 安装虚拟化服务

    yum -y install qemu-kvm qemu-system libvirt virt-manager

    2. 配置网络桥接

    2.1 修改配置文件:/etc/sysconfig/network-scripts/ifcfg-br0

    DEVICE=br0
    ONBOOT=yes
    TYPE=Bridge
    IPADDR=10.18.254.234
    NETMASK=255.255.254.0
    GATEWAY=10.18.254.254
    BOOTPROTO=static
    NAME=br0

    2.2 修改配置文件:/etc/sysconfig/network-scripts/ifcfg-eno1

    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=eno1
    UUID=5dbb88d7-9d31-4696-821c-ab227991d7f1
    DEVICE=eno1
    ONBOOT=yes
    BRIDGE=br0

    3. 编写xml配置文件创建虚拟机

    domain type='kvm'>
    <name>centos2</name>
    <memory>1048576</memory>
    <currentMemory>1048576</currentMemory>
    <vcpu>2</vcpu>
    
    <os>
        <type arch='x86_64' machine='pc'>hvm</type>
        <boot dev='cdrom'/>
    </os>
    
    <features>
        <acpi/>
        <apic/>
        <pae/>
    </features>
    
    <clock offset='localtime'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    
    <devices>
        <emulator>/usr/libexec/qemu-kvm</emulator>

          <disk type='file' device='cdrom'>
          <source file='/root/shiyawei/CentOS-7-x86_64-Minimal-1810.iso'/>
          <target dev='hdb' bus='ide'/>
          </disk> 

         <disk type='file' device='disk'>
         <driver name='qemu' type='qcow2'/>
         <source file='/root/shiyawei/test2.qcow2'/>
         <target dev='sda' bus='scsi'/>
         </disk>

        <interface type='bridge'>
            <source bridge='br0'/>
            <mac address="6c:92:bf:4d:e2:aa"/>
        </interface>
    
        <input type='mouse' bus='ps2'/>
        <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'/>
    </devices>
    </domain>

    4. 运行虚拟机文件并启动

    virsh define centos_config2.xml
    virsh start centos

    5. 查看虚拟机是否创建成功

    virsh list --all
    ps -ef|grep centos

     6. 安装好操作系统后,更改xml文件中的 <boot dev='hd'> 将系统另外一块盘开启,这样避免反复重装系统

  • 相关阅读:
    盒子模型之边框border
    CSS优先级特性之权重叠加
    CSS三大特性:层叠性、继承性、优先级
    行高
    单行文本垂直居中
    !important
    【DP专题】——[USACO13OPEN]照片Photo
    1:n Oberserver模式
    025_递归算法详解
    字符串移动问题
  • 原文地址:https://www.cnblogs.com/syw-home/p/13671251.html
Copyright © 2020-2023  润新知