KVM 基本硬件容量扩容
在工作当中如果虚拟机的容量不够使用 如何添加呢?CPU添加
cpu添加有两种方式:
1 创建虚拟机的时候可以添加
# virt-install --help | grep cpu
--vcpus=VCPUS Number of vcpus to configure for your guest. Ex:
--vcpus 5
--vcpus 5,maxcpus=10
--vcpus sockets=2,cores=4,threads=2
安装的时候手动可以添加
--vcpus 5:添加5个虚拟vcpu 当前
--vcpus 5,maxcpus=10:当前CPU为5 最大CPU设置为10
2 创建好的 可以编辑文件更改
更改前内容
<domain type='kvm'>
<name>CentOS-6.5-x86_64</name>
<uuid>e9258e70-6372-9820-2f2f-cb713c74e2fc</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
更改后的内容
# virsh list --all
Id Name State
----------------------------------------------------
2 CentOS-6.5-x86_64 running
# virsh edit CentOS-6.5-x86_64
Domain CentOS-6.5-x86_64 XML configuration edited.
<domain type='kvm'>
<name>CentOS-6.5-x86_64</name>
<uuid>e9258e70-6372-9820-2f2f-cb713c74e2fc</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='auto' current="1">4</vcpu>
更改为当前1vcpu 最大可获得4vcpu
更改完之后需要重启虚拟机
CentOS7 支持热添加
#virsh setvcpus name 3 --live
热添加总数不能超过最大CPU
内存添加
# virsh edit CentOS-6.5-x86_64
更改前
<domain type='kvm'>
<name>CentOS-6.5-x86_64</name>
<uuid>e9258e70-6372-9820-2f2f-cb713c74e2fc</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='auto' current='1'>4</vcpu>
更改后
<domain type='kvm'>
<name>CentOS-6.5-x86_64</name>
<uuid>e9258e70-6372-9820-2f2f-cb713c74e2fc</uuid>
<memory unit='KiB'>4048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='auto' current='1'>4</vcpu>
更改为最大4G重启虚拟机
查看内存
# virsh qemu-monitor-command CentOS-6.5-x86_64 --hmp --cmd info balloon
balloon: actual=1024
内存热添加
# virsh qemu-monitor-command CentOS-6.5-x86_64 --hmp --cmdballoon 2048
页:
[1]