首页 > 代码库 > kvm安装

kvm安装

 

 

基础环境:

192.168.1.67                  super67 

硬件cpu需要支持:Intel VT-x 技术  

本实验使用虚拟机VMware Workstation上的虚拟机

操作系统:CentOS6.5

 

物理机确保开启cpu虚拟化技术(进入bois设置)

 

VMware Workstation的设置:

 技术分享

 

检查cpu是否支持硬件虚拟化技术(Intel->vmx  AMD->svm)

[root@super67 ~]# grep -E "(vmx|svm)" /proc/cpuinfo --color

检查是否支持64位:

[root@super67 ~]# grep lm /proc/cpuinfo --color

 

检查内核是否编译kvm模块:

[root@super67 ~]# grep -i "kvm" /boot/config-2.6.32-431.el6.x86_64

CONFIG_KVM_CLOCK=y

CONFIG_KVM_GUEST=y

CONFIG_HAVE_KVM=y

CONFIG_HAVE_KVM_IRQCHIP=y

CONFIG_HAVE_KVM_EVENTFD=y

CONFIG_KVM_APIC_ARCHITECTURE=y

CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y

CONFIG_KVM=m

CONFIG_KVM_INTEL=m

CONFIG_KVM_AMD=m

 

从内核中装载kvm:

[root@super67 ~]# lsmod |grep kvm

[root@super67 ~]# modprobe kvm

[root@super67 ~]# modprobe kvm_intel

[root@super67 ~]# lsmod |grep kvm

kvm_intel              54285  0

kvm                   333172  1 kvm_intel

 

安装kvm及一些管理工具:

[root@super67 ~]# yum install -y kvm virt-manager libvirt qemu-kvm qemu-kvm-tools -y

 

启动管理API:

[root@super67 ~]# /etc/init.d/libvirtd start

Starting libvirtd daemon:                                  [  OK  ]

[root@super67 ~]# chkconfig libvirtd on

 

建立桥接设备,然后把接口添加进来,让kvm虚拟机可以上网:

[root@super67 ~]# yum install -y bridge-utils

 

修改eth0配置:

[root@super67 network-scripts]# cat ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

IPV6INIT=no

USERCTL=no

HWADDR=00:0c:29:8d:5c:df

BRIDGE="br0"

 

修改桥配置:

[root@super67 network-scripts]# cat ifcfg-br0

DEVICE="br0"

TYPE="Bridge"

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

IPADDR=192.168.1.67

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

DNS1=114.114.114.114

IPV6INIT=no

USERCTL=no

HWADDR=00:0c:29:8d:5c:df

DNS2=8.8.8.8

 

重启网络:

[root@super67 ~]# /etc/init.d/network restart

 

[root@super67 ~]# ifconfig br0

br0       Link encap:Ethernet  HWaddr 00:0C:29:8D:5C:DF 

          inet addr:192.168.1.67  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe8d:5cdf/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:112 errors:0 dropped:0 overruns:0 frame:0

          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:8151 (7.9 KiB)  TX bytes:10688 (10.4 KiB)

 

[root@super67 ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:8D:5C:DF 

          inet6 addr: fe80::20c:29ff:fe8d:5cdf/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:4340 errors:0 dropped:0 overruns:0 frame:0

          TX packets:3717 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:398809 (389.4 KiB)  TX bytes:2072653 (1.9 MiB)

 

查看桥接信息:

[root@super67 ~]# brctl show

bridge name    bridge id        STP enabled    interfaces

br0         8000.000c298d5cdf       no           eth0

virbr0            8000.52540015e279      yes          virbr0-nic

 

使用图形化管理界面管理:

[root@super67 ~]# virt-manager

 

技术分享

 

技术分享

 

kvm安装