关键字:kvm、libvirt、virt-manager、debian
时间:2018年8月
前言
libvirt是linux下管理虚拟化的一套工具。
virt-manager是基于libvirt的图形界面管理程序,可以管理本机的libvirt,也可以远程管理其他安装有libvirt的物理机。
环境
宿主机环境Debian 9,Gnome或其他图像界面。由于virt-manager为图形界面程序,所以必须安装图形界面才能使用。
安装
root@debian:# apt-get install virt-manager
注:virt-manager依赖libvirt相关包,因此libvirt会被自动安装。
配置
root@debian:~# vim /etc/network/interfaces.d/br0 auto br0 iface br0 inet static address 172.17.1.101/20 gateway 172.17.0.1 bridge_ports enp0s25 bridge_waitport 0 bridge_fd 0 :wq root@debian:~# vim /etc/network/interfaces ... source /etc/network/interfaces.d/* ... auto lo iface lo inet loopback :wq root@debian:~# systemctl restart network-manager root@debian:~# vim /etc/libvirt/qemu.conf ... #user = "root" user = "root" ... #group = "root" group = "root" ... :wq root@debian:~# systemctl restart libvirtd
注意:
1、网卡须配置成bridge模式,否则虚拟机无法被局域网中其他主机ping通。
2、如果不修改qemu.conf文件中的user和group,在创建虚拟机时会出现’unsupported configuration: CPU mode ‘custom’ for x86_64 kvm domain on x86_64 host is not supported by hypervisor’。
图像界面使用
运行virt-manager。
创建虚拟机时,网卡设置时,“Network source”选择“Specify shared device name”,然后“Bridge name”填写“br0”。
shell使用
root@debian:~# virsh Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # help virsh # list --all virsh # start vm1 virsh # quit root@debian:~#