环境说明:
硬件:需要在BIOS内开启虚拟化支持;各硬件开启方式不同,这块大家自行百度。
系统:CentOS最小化安装;升级软件补丁,内核和系统版本不升级;关闭SELinux和防火墙。
安装部署:
1、查看系统CPU是否支持VT功能:grep -E ‘(vmx|svm)’ /proc/cpuinfo(CentOS6系列命令:grep -E –color=auto “(vmx|svm)” /proc/cpuinfo)#结果中有vmx(Intel)或svm(AMD)字样,就说明CPU的支持的。
[root@boron3 ~]# grep -E '(vmx|svm)' /proc/cpuinfo flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat
2、安装KVM管理工具:yum install qemu-kvm qemu-kvm-tools libvirt libvirt-client libvirt-python virt-install virt-manager
[root@boron3 ~]# yum install qemu-kvm qemu-kvm-tools libvirt libvirt-client libvirt-python virt-install virt-manager -y 以下安装过程省略......
3、启动libvirtd服务(此服务用来管理KVM)并设置服务自启动:systemctl start libvirtd && systemctl enable libvirtd
[root@boron3 ~]# systemctl start libvirtd && systemctl enable libvirtd
4、配置KVM网络桥接:
virsh iface-bridge enp1s0f0 br0 –no-stp #创建桥接接口br0并把本地接口enp1s0f0(大家根据各自设备的实际名称相应修改)桥接至接口br0上及不开启STP功能
systemctl restart network #重启网络服务使配置生效
[root@boron3 ~]# virsh iface-bridge enp1s0f0 br0 --no-stp;systemctl restart network Created bridge br0 with attached device enp1s0f0 error: Failed to start bridge interface br0 error: internal error: failed to create (start) interface br0: failed to execute external program - Running 'ifup enp1s0f0' failed with exit code 4: Error: Connection activation failed: Can not find a master for System enp1s0f0: Master connection not found or invalid
有出错信息不管,只要远程连接没中断即可
e)此时查看桥接状态也属正常
[root@boron3 ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.00266cf10d84 no enp1s0f0 virbr0 8000.525400e8dbad yes virbr0-nic
f)查看IP信息可以看出,原本本地接口enp1s0f0的IP信息也变更到了桥接网卡上。
[root@boron3 ~]# ip a 2: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000 link/ether 00:26:6c:f1:0d:84 brd ff:ff:ff:ff:ff:ff 4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:26:6c:f1:0d:84 brd ff:ff:ff:ff:ff:ff inet 172.16.99.157/24 brd 172.16.99.255 scope global noprefixroute dynamic br0 valid_lft 515sec preferred_lft 515sec inet6 fe80::226:6cff:fef1:d84/64 scope link noprefixroute valid_lft forever preferred_lft forever
此时KVM环境算是基本部署好了,推荐系统重新启动下。
5、利用相关客户端软件SSH远程连接此服务器后执行命令virt-manager使用GUI图形化管理界面来管理KVM服务器
[root@boron3 ~]# virt-manager [root@boron3 ~]# libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast