本文共 2588 字,大约阅读时间需要 8 分钟。
配置CPU
virsh edit CentOS-7-x86_64 修改cpu从静态1个到动态2个,只用1个<vcpu placement='static'>1</vcpu>→ <vcpu placement='auto' current="1">2</vcpu>关闭、启动虚拟机后cat /proc/cupinfoprocessor 0 代表1个热添加cpu到2个,contos7才支持,只支持热添加,不支持热减少
virsh setvcpus CentOS-7-x86_64 2 --livecat /proc/cupinfo
processor 1 代表2个查看cpu工作情况[root@kvm1 ~]# cat /proc/interrupts CPU0 CPU1 0: 145 0 IO-APIC-edge timer1: 10 0 IO-APIC-edge i80426: 3 0 IO-APIC-edge floppy8: 0 0 IO-APIC-edge rtc09: 1 0 IO-APIC-fasteoi acpi10: 0 0 IO-APIC-fasteoi uhci_hcd:usb3, uhci_hcd:usb411: 26 0 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb2, virtio312: 15 0 IO-APIC-edge i804214: 535 0 IO-APIC-edge ata_piix15: 0 0 IO-APIC-edge ata_piix24: 0 0 PCI-MSI-edge virtio2-config25: 5675 0 PCI-MSI-edge virtio2-req.026: 0 0 PCI-MSI-edge virtio0-config27: 459 0 PCI-MSI-edge virtio0-input.028: 1 0 PCI-MSI-edge virtio0-output.029: 0 0 PCI-MSI-edge virtio1-config30: 5 0 PCI-MSI-edge virtio1-virtqueuesNMI: 0 0 Non-maskable interruptsLOC: 25713 2829 Local timer interruptsSPU: 0 0 Spurious interruptsPMI: 0 0 Performance monitoring interruptsIWI: 1073 1 IRQ work interruptsRTR: 0 0 APIC ICR read retriesRES: 6 48 Rescheduling interruptsCAL: 0 350 Function call interruptsTLB: 0 2 TLB shootdownsTRM: 0 0 Thermal event interruptsTHR: 0 0 Threshold APIC interruptsDFR: 0 0 Deferred Error APIC interruptsMCE: 0 0 Machine check exceptionsMCP: 2 1 Machine check pollsERR: 0MIS: 0PIN: 0 0 Posted-interrupt notification eventPIW: 0 0 Posted-interrupt wakeup event配置内存
virsh edit CentOS-7-x86_64 修改最大内存和当前内存,内存可以热添加和热减少<memory unit='KiB'>2048576</memory><currentMemory unit='KiB'>1048576</currentMemory>查看当前内存
virsh qemu-monitor-command CentOS-7-x86_64 --hmp --cmd info balloon设置内存为600Mvirsh qemu-monitor-command CentOS-7-x86_64 --hmp --cmd balloon 600硬盘
全镜像模式raw:全占用,性能好稀疏模式qcow2:用多少,占用多少,支持压缩,快照功能。openstack首先查看硬盘占用root@kvm ~]# cd /opt[root@kvm opt]# qemu-img info CentOS7-x86_64.rawimage: CentOS7-x86_64.rawfile format: rawvirtual size: 10G (10737418240 bytes)disk size: 1.2G网络编辑虚拟机网卡修改为桥接,让外部可以访问命令添加网桥br0brctl addbr br0查看网桥brctl show将eth0加入br0brctl addif br0 eth0删除原eth0的ipip addre del dev eth0 10.0.0.111/24设置br0的ipifconfig br0 10.0.0.111/24 upvirsh edit Centos6.5
修改<interface type='default'> 改为<interface type='bridge'>
<source network='default'/> 改为<source bridge='br0'/>
在物理机中eth0→新增BRIDGE=br0br0→TYPE=BridgeNAME=br0DEVICE=br0删除虚拟机
virsh undefine Centos6.5关闭虚拟机电源virsh destroy Centos6.5挂起虚拟机virsh suspend Centos6.5恢复virsh resume Centos6.5转载于:https://blog.51cto.com/13491150/2052818