kvm学习笔记
1、通过virt管理工具创建虚拟机
qemu-img create -f qcow2 -o size=50G,preallocation="metadata" /kvm/images/centos6.qcow2 创建磁盘文件
查看KVM列表:virsh list --all
启动KVM:virsh start centos01
关闭KVM:virsh shutdown centos01
强制关闭KVM:virsh destroy centos01
暂停KVM:virsh suspend centos01
恢复KVM:virsh resume centos01
克隆KVM:virt-clone -o centos01 -n centos02 -f /data1/centos02.img
编辑KVM配置:virsh edit centos01
删除VNC端口:
virsh edit centos01,打开xml后,删除下面的配置:
1
2
3
|
< graphics type = 'vnc' port = '5910' autoport = 'no' listen = '0.0.0.0' > < listen type = 'address' address = '0.0.0.0' /> </ graphics > |
设置KVM开机自动启动:vrish autostart centos01
3、KVM配置文件(http://libvirt.org/formatdomain.html)
/etc/libvirt 当一个KVM虚拟机配置好后,就会在/etc/libvirt/qemu目录中生成xml格式的文件
关闭虚拟机后修改相关配置文件,service libvirtd restart重新启动libvirtd服务器后配置文件生效
/var/lib/libvirt 默认镜像等存储目录
/var/log/libvirt 日志存储位置
The following files are required to manage and debug KVM problems:
- /etc/libvirt/ - Main configuration directory.
- /etc/libvirt/qemu/ - Virtual machine configuration directory. All xml files regarding VMs are stored here. You can edit them manually or via virt-manager.
- /etc/libvirt/qemu/networks/ - Networking for your KVM including default NAT. NAT is only recommended for small setup or desktops. I strongly suggest you use bridged based networking for performance.
- /etc/libvirt/qemu/networks/default.xml - The default NAT configuration used by NAT device virbr0.
- /var/log/libvirt/ - The default log file directory. All VM specific logs files are stored here.
- /etc/libvirt/libvirtd.conf - Master libvirtd configuration file.
- /etc/libvirt/qemu.conf - Master configuration file for the QEMU driver.