虚拟机调优
目的
修改虚拟机配置文件:配置虚拟机的CPU、内存、网卡。
方法
- 编辑虚拟机配置文件。
以虚拟机vm1为例。
1
virsh edit vm1
- 该命令为打开vm1的配置文件,后续步骤均在此基础上完成,修改完成后按“Esc”键,输入:wq!,按“Enter”保存并退出编辑即可。
- 配置文件需重启虚拟机生效:
1 2
virsh shutdown vm1 virsh start vm1
- 设置vCPU与物理CPU绑定。
1 2 3 4 5 6 7 8
<vcpu placement='static' cpuset='0-3'>4</vcpu> <cputune> <vcpupin vcpu='0' cpuset='0'/> <vcpupin vcpu='1' cpuset='1'/> <vcpupin vcpu='2' cpuset='2'/> <vcpupin vcpu='3' cpuset='3'/> <emulatorpin cpuset='0-3'/> </cputune>
脚本中参数说明如表1所示。
- 设置
NUMA 绑定。1 2 3 4 5 6 7 8 9
<numatune> <memnode cellid='0' mode='strict' nodeset='0'/> </numatune> <cpu mode='host-passthrough' check='none'> <topology sockets='1' cores='4' threads='1'/> <numa> <cell id='0' cpus='0-3' memory='12582912' unit='KiB'/> </numa> </cpu>
脚本中参数说明如表2所示。
- 设置PCIe网卡直通。
1 2 3 4 5
<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address domain='0x0000' bus='0x82' slot='0x00' function='0x0'/> </source> </hostdev>
其中,“domain”、“bus”、“slot”和“function”是对应物理网卡的信息,可以执行lspci或者ethtool -i 网卡名命令查看。
1
lspci
输出如下结果,只需关注最左侧的数字:
1
“82:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)”
网卡的bus-info是16进制数,由82:00:0可以看出,bus为0x82,slot为0x00,function为0x0,domain为0x0000。
- 设置静态大页。
父主题: Memcached调优