Centos7安裝KVM,并使用virt-manager圖形化工具管理虛擬機(jī)
1、關(guān)閉防火墻和selinux,并檢查cpu是否支持虛擬化
????systemctl stop firewalld
????systemctl stop iptables
????systemctl disable firewalld
????systemctl disable iptables
????getenforce
????setenforce 0
????grep -Ei 'vmx|svm' /proc/cpuinfo
如果有過濾出vmx或svm關(guān)鍵字就代表支持虛擬化,vmx是Intel的CPU,svm是AMD的CPU。
2、安裝kvm、網(wǎng)橋、圖形化工具
????yum install -y libcanberra-gtk2 qemu-kvm qemu-kvm-tools? libvirt libvirt-cim libvirt-client libvirt-java.noarch? libvirt-python libiscsi? dbus-devel? virt-clone tunctl virt-manager libvirt libvirt-python python-virtinst dejavu-lgc-sans-fonts
????yum groupinstall "X Window System" "Fonts"
3、配置網(wǎng)卡
????cd /etc/sysconfig/network-scripts/
????cp ifcfg-em1 ifcfg-br0
????vi ifcfg-em1
????????TYPE=Ethernet
????????BOOTPROTO=dhcp
????????DEFROUTE=yes
????????NAME=em1
????????DEVICE=em1
????????ONBOOT=yes
????????IPADDR=192.168.1.7
????????NETMASK=255.255.255.0
????????GATEWAY=192.168.1.1
????????BRIDGE=br0
????vi ifcfg-br0
????????TYPE=Bridge
????????BOOTPROTO=dhcp
????????DEFROUTE=yes
????????NAME=br0
????????DEVICE=br0
????????ONBOOT=yes
????????IPADDR=192.168.1.7
????????NETMASK=255.255.255.0
????????GATEWAY=192.168.1.1
安裝上面模板修改完網(wǎng)卡配置文件,重啟網(wǎng)絡(luò)服務(wù)
????systemctl restart network
????ifconfig
看到em1上的ip跑到了br0上面,網(wǎng)卡配置完畢
4、啟動(dòng)KVM服務(wù)
檢查KVM模塊是否加載
????lsmod |grep kvm
????????kvm_intel? ? ? ? ? ? 148081? 0
????????kvm? ? ? ? ? ? ? ? ? 461126? 1 kvm_intel
啟動(dòng)服務(wù)
????systemctl start libvirtd
檢查服務(wù)進(jìn)程
????ps aux |grep libvirtd
????????root? ? 22277? 3.7? 0.0 1007720 15044 ?? ? ? Ssl? 15:25? 0:00 /usr/sbin/libvirtd
????????root? ? 22571? 0.0? 0.0 112708? 976 pts/1? ? S+? 15:25? 0:00 grep --color=auto libvirtd
查看網(wǎng)卡
????brctl show
????????br0 8000.c81f66f387a8 no em1 橋接網(wǎng)卡
????????virbr0 8000.525400383c91 yes virbr0-nic NAT模式網(wǎng)卡
5、使用圖形化工具管理kvm虛擬機(jī)
????virt-manager