kvm熱添加和熱遷移

a.熱添加磁盤linux

1.建立磁盤web

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

2.附加磁盤設備dom

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

3.格式化磁盤spa

mkfs.xfs /dev/vdb

4.掛載code

mount /dev/vdb /data

磁盤擴容orm

1.卸載掛載磁盤blog

umount /dev/vdb

2.分離磁盤設備內存

virsh detach-disk web01 vdb

3.增長磁盤大小ci

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

 4.掛載it

mount /dev/vdb /data

5.從新分配磁盤空間

xfs_growfs /dev/vdb

 

b.熱添加網卡

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>

 

c.熱添加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

 

d.熱添加內存

安裝參數

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
相關文章
相關標籤/搜索