?
?
在工作當中如果虛擬機的容量不夠使用 如何添加呢?
?
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 --allId 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 --cmd balloon 2048
?