Kvm虚拟化

Kvm之一:虚拟化环境

2017-01-13  本文已影响114人  词穷又词贫

Centos7 Kvm 环境安装

1、关闭防火墙与selinux
systemctl stop firewalld.service    #关闭防火墙
systemctl disable firewalld.service     #禁止防火墙开机自启动
setenforce 0    #关闭selinux
sed -i 's/=enforcing/=disabled/' /etc/selinux/config    #关闭selinux,重启生效
2、检查虚拟化环境
[root@node71 ~]# egrep '(vmx|svm)' --color=always /proc/cpuinfo
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi ept vpid xsaveopt
[root@node71 ~]# lsmod | grep kvm
kvm_intel             162153  0 
kvm                   525259  1 kvm_intel
[root@node71 ~]# 
3、准备网络虚拟化(实际环境应该是采用openvswitch)
yum install bridge-utils -y
[root@node71 ~]# cp /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-br0
[root@node71 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0 
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.2.109
NETMASK=255.255.0.0
GATEWAY=192.168.0.1
DNS1=192.168.0.1
[root@node71 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736 
TYPE=Ethernet
NAME=eno16777736
DEVICE=eno16777736
ONBOOT=yes
BRIDGE=br0
[root@node71 ~]# systemctl restart network.service
[root@node71 ~]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.000c2930cac9   no      eno16777736
virbr0      8000.525400995698   yes     virbr0-nic
[root@node71 ~]# 
4、安装虚拟化软件
yum -y install libvirt bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v libguestfs-tools -y
[root@node71 ~]# systemctl start libvirtd.service
[root@node71 ~]# systemctl enable libvirtd.service
[root@node71 ~]# systemctl status libvirtd.service
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since 一 2016-10-10 16:52:02 CST; 4min 17s ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 5193 (libvirtd)
   CGroup: /system.slice/libvirtd.service
           ├─2131 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─2133 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           └─5193 /usr/sbin/libvirtd

10月 10 16:52:02 node71 systemd[1]: Starting Virtualization daemon...
10月 10 16:52:02 node71 libvirtd[5193]: 2016-10-10 08:52:02.799+0000: 5193: info : libvirt version: 1.2.17, package: 13.el7_2.5 (CentOS BuildSystem <http://bugs.centos.o....centos.org)
10月 10 16:52:02 node71 libvirtd[5193]: 2016-10-10 08:52:02.799+0000: 5193: warning : virGetHostname:667 : getaddrinfo failed for 'node71': 未知的名称或服务
10月 10 16:52:02 node71 systemd[1]: Started Virtualization daemon.
10月 10 16:52:03 node71 dnsmasq[2131]: read /etc/hosts - 2 addresses
10月 10 16:52:03 node71 dnsmasq[2131]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
10月 10 16:52:03 node71 dnsmasq-dhcp[2131]: read /var/lib/libvirt/dnsmasq/default.hostsfile
10月 10 16:56:14 node71 systemd[1]: Started Virtualization daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@node71 ~]# rpm -qf /usr/lib/systemd/system/lib
libstoragemgmt.service  libvirtd.service        libvirtd.socket         libvirt-guests.service  
[root@node71 ~]# rpm -qf /usr/lib/systemd/system/libvirtd.service 
libvirt-daemon-1.2.17-13.el7_2.5.x86_64
[root@node71 ~]# 
[root@node71 ~]# virsh list --all
 Id    名称                         状态
----------------------------------------------------

[root@node71 ~]# ln -sv /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
"/usr/bin/qemu-kvm" -> "/usr/libexec/qemu-kvm"
[root@node71 ~]# 
上一篇下一篇

猜你喜欢

热点阅读