zoukankan      html  css  js  c++  java
  • kvm热添加和热迁移

    热添加磁盘

    1.创建磁盘

    qemu-img create -f qcow2 web01-add01.qcow2 5G

    2.附加磁盘设备

    virsh attach-disk web01 /opt/web01-add01.qcow2 vdb --live --cache=none --subdriver=qcow2

    3.格式化磁盘

    mkfs.xfs /dev/vdb

    4.挂载

    mount /dev/vdb /data

    磁盘扩容

    1.卸载挂载磁盘

    umount /dev/vdb

    2.分离磁盘设备

    virsh detach-disk web01 vdb

    3.增加磁盘大小

    qemu-img resize web01-add01.qcow2 +3G

     4.挂载

    mount /dev/vdb /data

    5.重新分配磁盘空间

    xfs_growfs /dev/vdb

    热添加网卡

    virsh attach-interface web01 --type network  --model  virtio --source default    #添加nat模式网卡
    virsh attach-interface web01 --type bridge  --model  virtio --source br0    #添加桥接网卡

    或修改配置文件

    virsh edit web01
    
        <interface type='bridge'>
          <mac address='52:54:00:45:02:55'/>
          <source bridge='br0'/>
          <model type='virtio'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
        <interface type='network'>
          <source network='default'/>
          <model type='virtio'/>
        </interface>

    热添加CPU

    安装参数

    virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web01 --memory 1024 --vcpus 1,maxvcpus=4 --disk /opt/web01.qcow2,format=qcow2,size=10 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole

    添加CPU

    virsh setvcpus web01 --count=2

    热添加内存

    安装参数

    virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web01 --memory 1024,maxmemory=4096 --vcpus=1,maxvcpus=4 --disk /opt/web01.qcow2,format=qcow2,size=10 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0  --noautoconsole

    添加内存

    virsh setmem web01 2G
  • 相关阅读:
    Apache Struts 2.3.12 GA?
    emacs配置《转》
    vim配置
    vim插件
    git使用
    ubuntu常用设置
    Eclipse如何关联已经clone的Git项目
    变量名、对象引用(指针)与堆栈
    Web项目转换为groovy项目的步骤
    日志 20071208(SvcUtil.exe,高并发网站架构)
  • 原文地址:https://www.cnblogs.com/omgasw/p/10597817.html
Copyright © 2011-2022 走看看