为了在一台服务器上虚拟出多个Ubuntu server,用于集群。考虑了几个方案,Vmware因为价格被排除,VirtualBox不错,不过KVM由于是Linux内核层的,性能更好。优先考虑使用。
首先在一台实验机器上安装Ubuntu 12.04 amd64 server。升级系统补丁以及内核。hostname是kvmhost. IP是10.112.18.177. 主板上已经打开了虚拟化功能。
好。现在开始安装kvm。
sudo -s 切换到root权限。
用下面的命令检查cpu是否支持虚拟化:
root@kvmhost:~# 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 acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpid
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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpid
什么都不显示的话,就不能玩了。还好,我可以继续了。
现在安装kvm和kvmbuilder脚本。这个脚本用来创建基于Ubuntu的虚拟机。
apt-get install ubuntu-virt-server python-vm-builder kvm-ipxe
将当前root用户加入到kvm和libvirtd组
adduser `id -un` libvirtd
adduser `id -un` kvm
退出后,再登录。
运行下面的命令检查kvm是否安装成功。
root@kvmhost:~# virsh -c qemu:///system list
Id Name State
----------------------------------
没有错误信息。安装没问题。
下面设置网络,保证网络中的其他主机能够访问到kvm管理的虚拟机。
可能需要安装bridge-utils,我的实验机安装完操作系统的时候已经有了。没有的运行命令:
apt-get install bridge-utils
编辑/etc/network/interface文件,编辑前我的文件如下:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
修改为:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface (disable)
#auto eth0
#iface eth0 inet dhcp
# The primary network interface for kvm
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 10.112.18.177
network 10.112.18.0
netmask 255.255.255.0
broadcast 10.112.18.255
gateway 10.112.18.1
dns-nameservers 8.8.8.8 8.8.4.4
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
重新启动网络服务
/etc/init.d/networking restart
然后检查一下网络配置
root@kvmhost:/etc/network# ifconfig
br0 Link encap:Ethernet HWaddr d0:67:e5:ef:5a:0a
inet addr:10.112.18.177 Bcast:10.112.18.255 Mask:255.255.255.0
inet6 addr: fe80::d267:e5ff:feef:5a0a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:58 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5961 (5.9 KB) TX bytes:3662 (3.6 KB)
eth0 Link encap:Ethernet HWaddr d0:67:e5:ef:5a:0a
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:67318 errors:0 dropped:0 overruns:0 frame:0
TX packets:33515 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:91560174 (91.5 MB) TX bytes:2626976 (2.6 MB)
Interrupt:17
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: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)
virbr0 Link encap:Ethernet HWaddr 56:21:fd:02:02:35
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)
重新启动计算机.
reboot
重新登录上去。第一部分结束。
分享到:
相关推荐
Ubuntu12.04 nginx python uwsgi Django安装步骤
ubuntu12.04安装及配置过程详解
ubuntu12.04安装mysql---黑佳伦.pdf
Ubuntu 12.04下如何安装MySQL ,我按照这文档,已经成功在ubuntu 12.04安装成功mysql!
Ubuntu Server 12.04安装图解,附件中为安装过程中全部截图,可按照图中所选择部分安装
Ubuntu12.04下的JDK安装,首先到官网上下载jdk-7u51-linux-x64.tar.gz。
乌班图系统Ubuntu 12.04安装教程.docx
ubuntu12.04安装与桌面配置过程详解
ubuntu12.04安装QQ2015的方法
win7下U盘安装ubuntu12.04双系统教程 亲测实现
Ubuntu12.04下Ns2.35安装步骤,完美安装,可实现相关协议的开发和研究。
在Ubuntu12.04环境下安装JDK7
用 VMware 安装 Ubuntu 12.04详细过程图解
ubuntu12.04安装snort文档
Ubuntu 12.04 菜鸟完全使用教程让你用最快的速度熟悉使用Ubuntu 12.04!
zabbix2.03在ubuntu12.04上的安装(最新)
在ubuntu 12.04 上完成的git服务器搭建步骤。
VMWare8.0安装Ubuntu12.04教程,傻瓜式安装教程,很详细
libc6 for ubuntu 12.04 所有依赖的库都打包 .
Ubuntu12.04菜鸟使用手册合集+Ubuntu标准教程Ubuntu12.04菜鸟使用手册合集+Ubuntu标准教程Ubuntu12.04菜鸟使用手册合集+Ubuntu标准教程Ubuntu12.04菜鸟使用手册合集+Ubuntu标准教程Ubuntu12.04菜鸟使用手册合集+...