设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
注册
快捷导航
平台
Portal
论坛
BBS
文库
项目
群组
Group
我的博客
Space
搜索
搜索
热搜:
shell
linux
mysql
本版
用户
LinuxSir.cn,穿越时空的Linuxsir!
»
论坛
›
Linux 发行版讨论区 —— LinuxSir.cn
›
Gentoo Linux
›
KVM
返回列表
查看:
1349
|
回复:
5
KVM
[复制链接]
suran
suran
当前离线
积分
145
IP卡
狗仔卡
发表于 2010-9-3 17:32:48
|
显示全部楼层
|
阅读模式
1.安装要求
检查CPU是否支持虚拟化
/proc/cpuinfo
intel vmx
amd svm
emerge
app-emulation/qemu-kvm
sys-apps/usbutils
net-misc/bridge-utils
sys-apps/usermode-utilities
gpasswd -a <your_user_name> kvm
2.内核配置
[*] Virtualization --->
--- Virtualization
Kernel-based Virtual Machine (KVM) support
<M> KVM for Intel processors support
<M> KVM for AMD processors support
Device Drivers --->
[*] Network device support --->
Universal TUN/TAP device driver support
Networking support --->
Networking options --->
<*> 802.1d Ethernet Bridging
<*> 802.1Q VLAN Support
复制代码
3.创建一个虚拟机磁盘
qemu-img create -f qcow2 guet.img 10G
还可以先来创建一个快照
qemu-img snapshot -c snapshot1 guest.img
4.启动脚本
注:这个配合qemu-ifup启动,如使用《虚拟网桥》中的方法2按需重新配置
#!/bin/sh
KVM_CMD=/usr/bin/qemu
MACHINE=pc
DAEMON="-daemonize"
HOST=192.168.0.252
SMP=2,cores=2
TAP=2
NET="-net nic -net tap,ifname=tap$TAP,script=/etc/qemu/qemu-ifup"
#CDROM="-cdrom /home/shom/sfot/DEEPIN-LITEXP-6.2.iso -boot d"
MEM=512
DISK=/home/shom/kvm/xp0.img
#SNAPSHOT="-snapshot"
test -n "$1" && TAP=$1
test -n "$DISK" && HDA="-drive file=$DISK,cache=writeback,boot=on" || HDA="-hda $2"
shift 2
OTHER=$@
RUN_CMD="sudo $KVM_CMD -M $MACHINE -smp $SMP $NET -m $MEM $HDA $CDROM $SNAPSHOT -enable-kvm -daemonize -rtc base=localtime -clock rtc"
echo "运行命令:$RUN_CMD"
$RUN_CMD
if test $? = 0; then
echo "KVM 运行成功,$HOST:$TAP ..."
exit 0
else
echo "KVM 运行失败,请检查命令行是否有错误!"
exit 1
fi
# -m 内存大小
# -rtc base=localtime 使用主机时间
# -clock 选择时钟,优先使用HPET -> RTC
# -M 系统类型
# -snapshot数据不保存到磁盘映像
# -smp 设置CPU
# -drive 设定虚拟机文件 cache=writeback 缓存方式 boot=on 可启动介质
# -boot 启动选项 c 为硬盘 d 光驱
# -no-acpi 关闭acpi
# -enable-kvm 开启kvm虚拟化
# -name 设置guest标示
复制代码
5.虚拟网桥
注:可能在大多数(可能全部)无线设备不能工作,应该是这些设备不知道桥接吧
方法1:使用脚本创建网桥
注:配置完成后,如果不想重启就停止net.eth0;然后执行/etc/ini.t/net.br0
#!/bin/sh
switch=$(/sbin/route |awk '/^default / { print $8 }')
#/usr/bin/tunctl -u shom -t $1
/sbin/ifconfig $1 0.0.0.0 up
/sbin/brctl addif ${switch} $1
复制代码
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d. To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
bridge_br0="eth0"
brctl_br0=( "setfd 0" "sethello 0" "stp off" )
config_br0=( "192.168.0.8/24" )
routes_br0=( "default via 192.168.0.1" )
dns_domain_br0="domain.local"
dns_servers_br0="202.102.224.68 202.102.227.68"
dns_search_br0="domain.local"
config_eth0=("null")
复制代码
cd /etc/init.d
ln -s net.lo net.br0
rc-update add net.br0 default
rc-update del net.eth0
复制代码
方法2:手动配置网桥
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d. To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
bridge_br0="eth0 tap0 tap1 tap2 tap3"
brctl_br0=( "setfd 0" "sethello 0" "stp off" )
rc_need_br0="net.tap0 net.tap1 net.tap2 net.tap3"
config_br0=( "192.168.0.8/24" )
routes_br0=( "default via 192.168.0.1" )
dns_domain_br0="domain.local"
dns_servers_br0="202.102.224.68 202.102.227.68"
dns_search_br0="domain.local"
config_tap0=( "null" )
tuntap_tap0="tap"
tunctl_tap0="-u shom"
mac_tap0="52:54:00:12:34:56"
config_tap1=( "null" )
tuntap_tap1="tap"
tunctl_tap1="-u shom"
mac_tap1="52:54:00:12:34:57"
config_tap2=( "null" )
tuntap_tap2="tap"
tunctl_tap2="-u shom"
mac_tap3="52:54:00:12:34:58"
config_tap3=( "null" )
tuntap_tap3="tap"
tunctl_tap3="-u shom"
mac_tap3="52:54:00:12:34:59"
config_eth0=("null")
复制代码
cd /etc/init.d
ln -s net.lo net.br0
ln -s net.lo net.tap0
ln -s net.lo net.tap1
ln -s net.lo net.tap2
ln -s net.lo net.tap3
rc-update add net.br0 default
rc-update del net.eth0
brctl addbr br0
ifconfig br0 192.168.0.8 netmask 255.255.255.0 up
tunctl -b -u -t tap0
brctl addif br0 tap0
ifconfig tap0 up 0.0.0.0 promisc
复制代码
相关链接
KVM
http://en.gentoo-wiki.com/wiki/KVM#Required_packages
http://www.linux-kvm.org/page/Main_Page
HPET
http://www-01.ibm.com/support/docview.wss?uid=swg21443045
http://blog.fpmurphy.com/2009/07/linux-hpet-support.html
TUN/TAP
http://www.ibm.com/developerworks/cn/linux/l-tuntap/index.html
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
显身卡
suran
suran
当前离线
积分
145
IP卡
狗仔卡
楼主
|
发表于 2010-9-3 17:37:49
|
显示全部楼层
为什么不让用html?
USB和VLAN,NAT,VDE支持部分还没用到,等到用的时侯再补充
回复
支持
反对
使用道具
举报
显身卡
tlze
tlze
当前离线
积分
655
IP卡
狗仔卡
发表于 2010-9-3 20:55:07
|
显示全部楼层
也在用着KVM,先回复后再慢慢参考学习。
回复
支持
反对
使用道具
举报
显身卡
jsun
jsun
当前离线
积分
1061
IP卡
狗仔卡
发表于 2010-9-3 23:10:46
|
显示全部楼层
对于guest为xp,kvm、xen和virtualbox、vmware比感觉如何?我只想知道桌面应用的结果,不考虑大量guest的情况。
回复
支持
反对
使用道具
举报
显身卡
athlon_r
athlon_r
当前离线
积分
994
IP卡
狗仔卡
发表于 2010-9-7 16:57:02
|
显示全部楼层
用libvirt 来管理也不错 省去手动很多麻烦。
回复
支持
反对
使用道具
举报
显身卡
johe
johe
当前离线
积分
274
IP卡
狗仔卡
发表于 2010-9-9 09:25:13
|
显示全部楼层
支持一下,过几天准备安装KVM
回复
支持
反对
使用道具
举报
显身卡
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
注册
本版积分规则
发表回复
回帖后跳转到最后一页
浏览过的版块
SuSE Linux
Redhat/Fedora/CentOS Linux
Linux 程序设计专题讨论
Mandriva Linux
开源软件专题讨论
BSD 讨论专题
Archlinux讨论区
shell进阶应用、shell编程
服务器架设、应用、维护
Copyright © 2002-2023
LinuxSir.cn
(http://www.linuxsir.cn/) 版权所有 All Rights Reserved.
Powered by
RedflagLinux!
技术支持:
中科红旗
|
京ICP备19024520号
快速回复
返回顶部
返回列表