1.环境准备
2.安装KVM软件
3.配置桥接网卡
4.创建虚拟机(Ubuntu, winxp)
1. 环境准备
1) 两台计算机,一台是操作计算机Client, 一台是服务器Server
Client: 笔记本电脑, Win7旗舰版,64位,内网ip: 192.168.1.101
Server(Host): 服务器, Ubuntu 12.04LTS 64位,2核CPU,4G内存,内网ip:192.168.1.10,
2) 在server启动时,进入BIOS中开起CPU虚拟化的支持
进入BIOS中,在config –> CPU选项中
Intel(R) Virtualization Technology (Enabled)
Intel(R) VT-d Feature (Enabled)
不同BIOS菜单稍有不同。
3) Server上,先安装Openssh-server,Client才能连接
~ sudo apt-get install openssh-server
Clinet通过Putty回家连接Server。
注:以下的所有操作都通过SSH进行。
4) Server系统环境
~ uname -a
Linux conan 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
~ cat /etc/issue
Ubuntu 12.04.2 LTS \n \l
5) 查看CPU的虚拟化支持
~ egrep 'svm|vmx' /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 lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida dtherm tpr_shadow vnmi flexpriority
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 lm constant_tsc arch_perfmon pebs bts nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida dtherm tpr_shadow vnmi flexpriority
我机器是intel的CPU,可以查看vmx的标识
6) Server上,配置ubuntu下载源sources.list,我用的是sohu源。
~ sudo vi /etc/apt/sources.list
deb precise main restricted
deb-src precise main restricted
deb precise-updates main restricted
deb-src precise-updates main restricted
deb precise universe
deb-src precise universe
deb precise-updates universe
deb-src precise-updates universe
deb precise multiverse
deb-src precise multiverse
deb precise-updates multiverse
deb-src precise-updates multiverse
deb precise-backports main restricted universe multiverse
deb-src precise-backports main restricted universe multiverse
deb precise-security main restricted
deb-src precise-security main restricted
deb precise-security universe
deb-src precise-security universe
deb precise-security multiverse
deb-src precise-security multiverse
deb precise main
deb-src precise main
#更新源
~ sudo apt-get update
2. 安装KVM软件
1) Server上,安装KVM及virt管理软件
~ sudo apt-get install kvm qemu
~ sudo apt-get install virtinst Python-libvirt virt-viewer virt-manager
在ubuntu上安装,真的很简单。
3. 配置桥接网卡
1) 在这里我们使用网卡桥接的方式
~ sudo apt-get install bridge-utils
2) 查看网卡的设置
~ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1c:25:a1:99:fc
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21c:25ff:fea1:99fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:736674 errors:0 dropped:0 overruns:0 frame:0
TX packets:1098750 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:63783787 (63.7 MB) TX bytes:1540374899 (1.5 GB)
Interrupt:20 Memory:fc200000-fc220000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1156 errors:0 dropped:0 overruns:0 frame:0
TX packets:1156 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:114090 (114.0 KB) TX bytes:114090 (114.0 KB)
virbr0 Link encap:Ethernet HWaddr be:65:ec:88:86:3d
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
3) 已有的网卡
eth0是直接插入网线的以太网卡,
lo是本地网络,本机内部资源
virbr0是刚才我们装完KVM后,自己生成的虚拟网卡
4) 网卡桥接
我们增加一个叫br0的虚拟网卡,让这个网卡可以和eth0以太网的网卡做桥接