> CentOS > CentOS教程 >

CentOS下kvm安装配置

根据个人实际情况修改文件,在此只是记录本人的工作环境;

1,安装系统需要的文件

yum -y install kvm kmod-kvm kvm-qemu-img
yum -y install bridge-utils tunctl

 

2,创建ifcf-br0文件vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
HWADDR=F4:6D:04:40:90:47
TYPE=Bridge
IPADDR=192.168.1.22
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no

 

3,修改系统网卡配置文件ifcfg-eth3 ,修改内容如下:

DEVICE=eth3
HWADDR=F4:6D:04:40:90:47
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no

 

 

 

4,修改/etc/qemu-ifup

#!/bin/sh
set -x
bridge=br0
interface=$1
/sbin/ip link set $interface up
/usr/sbin/brctl addif $bridge $interface

 

 

 

5,修改/etc/qemu-ifdown

#!/bin/sh
set -x
bridge=br0
interface=$1
ifconfig $interface down
tunctl -d $interface

 

6,/etc/init.d/network restart

 

 

如果配置正常,连通设备后

1,创建虚拟器

qemu-img create -f qcow2 linux-6-x86_64.img 10G

2,安装虚拟机

/usr/libexec/qemu-kvm –m 1024 -hda ./linux-6-x86_64.img -localtime -net nic,macaddr=DE:AD:BE:EF:F0:01 -net tap  -cdrom  /opt/release/centos-6-x86_64-CD.iso -boot d -vnc :1

3,运行虚拟机

/usr/libexec/qemu-kvm -m 1024 -hda ./linux-6-x86_64.img -localtime -net nic,macaddr=DE:AD:BE:EF:F0:01 -net tap -vnc :1

(责任编辑:IT)