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