购买美国VPS
(1)Centos5.5安装
升级开启SELinux(如果你的SELinux被禁用,virt-install将不会正常工作) system-config-securitylevel-tui
(2)kvm安装
(a)检查CPU是否支持硬件虚拟化-运行命令
egrep '(vmx|svm)' --color=always /proc/cpuinfo(如果输出的结果包含 vmx,CPU是 Intel;如果包含 svm,CPU是 AMD。如果什么也没显示,则系统不支持虚拟化的处理。)
(b)安装KVM和virtinst(一个创建虚拟机的工 具),我们运行
yum install kvm kmod-kvm qemu libvirt python-virtinst
然后重新启动系统:Reboot
使用下列命令检查KVM是否成功安装
virsh -c qemu:///system list
将会显示如下结果:
[root@server1 ~]# virsh -c qemu:///system
listId Name State
----------------------------------
[root@server1 ~]#
如果在这里显示的是一个错误的信息,说明有些东西出现了问题。
(c)下面我们需要在我们的服务器上设置一个网桥,就可以使我们的虚拟机从其他主机中读取数据。
要做到这一点,我们安装bridge-utils工具
yum install bridge-utils...
并且配置一个网桥从
/etc/sysconfig/network-scripts/ifcfg-eth0
参考BOOTPROTO, BROADCAST, IPADDR, NETMASK和NETWORK等值来创建文件/etc/sysconfig/network-scripts/ifcfg-br0 :vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
BROADCAST=192.168.0.255
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
修改/etc/sysconfig/network-scripts/ifcfg-eth0 as follows (取消注释BOOTPROTO, BROADCAST, IPADDR, NETMASK, 和NETWORK 最后添加 BRIDGE=br0):
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+
DEVICE=eth0
#BOOTPROTO=static
#BROADCAST=192.168.0.255
HWADDR=00:10:A7:05:AF:EB
#IPADDR=192.168.0.100
#NETMASK=255.255.255.0
#NETWORK=192.168.0.0
ONBOOT=yes
BRIDGE=br0
重新启动网络...
/etc/init.d/network restart...
运行ifconfig现在应该显示网桥(br0):
[root@server1 ~]# ifconfig
br0 Link encap:Ethernet HWaddr 00:10:A7:05:AF:EB
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::210:a7ff:fe05:afeb/64
Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0 RX bytes:1160 (1.1 KiB) TX bytes:14875 (14.5 KiB) eth0 Link encap:Ethernet HWaddr 00:10:A7:05:AF:EB
inet6 addr: fe80::210:a7ff:fe05:afeb/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13662 errors:7 dropped:160 overruns:4 frame:0 TX packets:11646 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:15144608 (14.4 MiB) TX bytes:1379942 (1.3 MiB) Interrupt:74 Base address:0xcc00 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:38 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0 RX bytes:4308 (4.2 KiB)
TX bytes:4308 (4.2 KiB) virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:9987 (9.7 KiB)