|
|
一、Xen简介- Y+ E6 V+ p C, E. ?/ Z
0 S& P; D1 G6 k
1、Xen简介
3 t5 p; S* Z- g" T2 K) d$ m( L% v
Xen 英国剑桥大学研发,开源的VMM,是一种类型 1 虚拟机管理程序,它创建系统资源的逻辑池,使许多虚拟机可共享相同的物理资源。7 W) z N2 ~* U" T5 |
6 Q/ _/ w$ ^6 ~ Xen 是一个直接在系统硬件上运行的虚拟机管理程序。Xen 在系统硬件与虚拟机之间插入一个虚拟化层,将系统硬件转换为一个逻辑计算资源池,Xen 可将其中的资源动态地分配给任何操作系统或应用程序。在虚拟机中运行的操作系统能够与虚拟资源交互,就好象它们是物理资源一样。2 @( n6 n9 `( \" H
U8 m7 J: k) v- Y" u3 V( Z" G0 H- {9 w d
! z" C8 r; n! Y8 I0 R3 i Xen 架构
6 c2 Y& u. D$ R$ @% ]0 B
: {6 [; z$ A5 X) x Xen 运行 3 个虚拟机。每个虚拟机与其他虚拟机都独自运行一个来宾操作系统和应用程序,同时共享相同的物理资源。: {- I8 [6 k3 r0 J/ C2 y' N2 I
. c& N6 H" z0 H1 \* x6 a: N/ w2、Xen的组件/ n/ s3 J& c3 a7 K) S: s
, G# c2 x( } ]# H$ `
1)Xen Hypervisor
; a( t. q" m4 Q. a& o( O
1 V6 Q( F4 ~8 @ 分配cpu、内存、interrupt(中断)
( b) \8 l& \0 w7 \% i9 M7 U" A0 Z5 `9 Z4 I' g
2)Dom0
4 v& V% G+ Q! c! G
: P0 _4 {5 T* s" Q9 A 特权域,I/O分配:
9 H$ {# n& Z6 @/ ], k1 H6 m9 q, v: m7 Z, S+ A4 e
网络设备:net-front(guestOS),net-backend& y, k( V( t9 c2 W
7 v2 \. o1 e0 R9 K 块设备:block-front(guestOS),block-backend# m7 e w# y4 M( C1 m \0 H
. s7 Q/ L V; S2 K
linux kernel:2.6.37支持Dom0 原始支持! L p1 X. G8 m1 ~4 @
0 \$ p7 N6 c" u) l$ j# F* }% c: i# |
3.0对关键特性进行了优化* d! A9 v$ }$ f/ j4 ~) N
0 h# w C3 S+ \1 a% x7 ]& L 提供管理DomU工具栈,用于实现对虚拟机进行添加,启动,快照,停止,删除等操作
3 q9 N: {4 D& u! ~* E
& F* w: B9 W, U, _( y& s( x 3)Domu
. i& D: R4 T: e) @
! Q9 c# T1 ^" ^) a8 \ 非特权域,无权直接访问硬件资源3 a- k$ F. m; c9 l3 E
% ~+ T; a4 w* _) ` 根据其虚拟化方式实现的方式,有多种类型) I% U+ r, I+ J( }: l, a2 ~
5 q; C: v) [% u8 a
PV:半虚拟化7 [: ]: b8 n: Y) _0 t
6 K9 A5 \: h6 ]! E HVM:完全虚拟化
, z O# o# E* _4 S7 E* q
2 d' L9 U# x# Q- S' x PV on HVM:I/O半虚拟化但cpu完全虚拟化1 V+ I7 K: E4 B
1 J; K& ?3 Y, ?0 JXen的PV技术:不依赖于CPU的HVM特性,但要求GuestOS的内核作出修改以知晓自己运行于PV环境,
3 t; [0 u3 ^. |, p. Q
7 {- V: |& {$ u* }1 S2 M 运行于DomU中的OS:linux(2.6.24+),NetBSD,FreeBSD,OpenSolaris
. |# }9 i" [; ~$ d5 K- X" v8 _1 `( ]+ P8 g) b/ C _
Xen的HVM技术:依赖于Intel VT或AMD AMD-V,还要依赖于Qemu来模拟IO设备
9 i, s# F$ R5 \1 W* N) s) L. h- p+ C- X9 f0 e* Y) r+ u
运行于DomU中的OS:几乎所有支持此X86平台的OS
/ t; ]. Z& a) @2 N
1 ~, J! Q9 |+ o: H4 ZPV on HVM:CPU为HVM模式运行,IO设备为PV模式运行
3 Y" _& ~5 g/ s8 b9 U5 L
3 ?4 \! V* ]) ? 运行于DomU中的OS:只要OS能驱动PV接口类型的IO设备:net-front,block-front' \ T) O( ?; k% _
3 h( \: N6 s/ ^- T3 }' c, Y7 @2 g
$ ^" {7 X' S0 @# L: a
) V) _# {# W2 _2 _ Q+ k# l5 b8 t4 s- j+ f$ \. O+ R+ g; ?) p
/ ~! z' W" v, Q& w# e+ w) l: A
9 ^' s* D' H. K! g% K: y) m$ Q+ R, ^# z' r, {
, g( u* `. ^( e, {2 F/ Y7 u" O! y( f# p* S1 p! y
3、CentOS对Xen的支持# W! X0 ? K: p; ]; h1 g
# Q, q" `6 H8 RRHEL 5.7-:默认的虚拟化技术为xen
: r1 a6 r7 }3 h& W/ [/ n3 w4 S: V3 f; f5 }8 W$ J% b
kernel version:2.6.18 不能运行在Dom0上,要运行Dom0上需要安装补丁,RHEL提供了安装补丁后的内核 kernel-xen:$ w* c- f0 _; F% z
) ?- g4 H4 M. B$ o7 a* Y% z
5.8:同时支持Xen和kvm
; a* {2 i( K$ y2 k) d: J9 v
# [- H, U6 M6 o: Q* E- w: u9 C 6+:仅支持kvm
9 E5 D: j+ t, o# ^, L s' B2 }: e1 I/ J. d# N; P
Dom0:不支持
6 I( K: l! t- c. H- F
1 M$ S% H7 g% J* E( Y- x/ ] DomU:支持
9 F3 N) v% M) j5 z" w% g z5 F7 T1 A; [9 E% E- Y
那如何在CentOS6上使用Xen?
. A/ Z8 s1 a' F9 h7 [; B$ m* {$ B2 F c: i- b% t N; n
1)编译3.0以上版本的内核,启动对Dom0的支持
6 S0 y: Q( Y# p: [0 [ L) K; {; ^. g% {& Y6 g& _
2)编译Xen程序; f# d `0 H) l
+ I( }& `) ~, c! L& }: h- a
制作好相关程序包的项目:& q, Z- f) o# b2 ~ T" t, P/ f) H
# ]1 F! V p- H- Vxen made easy& H9 l7 G3 i0 ~, j; L; h
# @1 a/ F% ~1 @1 b6 Kxen4centos:xen官方提供,每个centos镜像站中已经提供了,
1 S4 Q' I5 J1 U4 b, W
# J. x8 V8 A# o: a- S2 n0 ~5 y
+ B$ i0 t2 K! D' c6 ~5 C/ u
7 J' B# O3 }0 E) a* l! d/ A我们可以自定义一个yum源
2 w- y) H9 x7 b
* U% K$ z& e: z' |; {[root@BAIYU_175 ~]# cd /etc/yum.repos.d/2 z" D! O& e, L: ^* U, h" i
[root@BAIYU_175 yum.repos.d]# ls& U1 z+ k* e- O( p
bak Centos-6.repo epel-6.repo Xen-6.repo Xen-6.repo.orig
& w7 Z) K: q3 @4 x[root@BAIYU_175 yum.repos.d]# vi Xen-6.repo
5 m8 v' ]! `" X$ _[root@BAIYU_175 yum.repos.d]# cat Xen-6.repo! M) ^: K# V7 _
# CentOS-Base.repo+ S, r& f" x1 |% c9 J
#7 z5 F* G* G- Z
# The mirror system uses the connecting IP address of the client and the7 D3 O# D3 M! `7 K# X: P
# update status of each mirror to pick mirrors that are updated to and
" {/ f1 P7 p& R6 i# geographically close to the client. You should use this for CentOS updates d( [! m6 T! V( n( ]
# unless you are manually picking other mirrors.6 Y3 [6 L! w3 H: c* m9 l
#5 r* R( p: H. ]" l
# If the mirrorlist= does not work for you, as a fall back you can try the : X+ t" `! t: @' F2 e! n
# remarked out baseurl= line instead.
6 h8 \8 {- j* |( \( m) X: r#
$ J/ B, b- b% E3 ~" T! x1 e#
$ m% i# I& A* B+ G9 Q
3 i3 m6 r- k4 v- d[Xenbase]
- n9 M$ o, b0 M9 p7 X4 C* R% L# vname=CentOS-$releasever - Base - mirrors.aliyun.com7 v9 f- x# j2 i# g& r- s0 p: S$ t
failovermethod=priority) `+ d# |# `5 m$ k/ d' N
baseurl=http://mirrors.aliyun.com/centos/6/virt/x86_64/xen-46' z( l! m3 n- \$ r7 [& {
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
! X0 X, M6 Z l& V& O4 n8 {#gpgcheck=1
9 p7 }- H. A8 x# t8 R# v#gpgkey=9 r3 b" S. g' U* ]- N f6 v) E/ ]) D
1., t$ i6 k0 T! ^' ~) j% v. B
5 J( I( {& W' a
: B7 q" v( I; X/ Y7 A2 K依赖关系解决9 c! C! \% |. ]% k9 F8 M
1 l1 ]8 m4 x. p; F/ x4 O6 v================================================================================================================0 G7 D6 k0 X( u k- m5 h! a$ S
软件包 架构 版本 仓库 大小
) M" i5 ~" g( p" E7 U0 y================================================================================================================7 J% L! p* Q& j6 K- \
正在安装:8 ^4 M" b9 r5 w8 P+ c) Z
xen x86_64 4.6.1-11.el6 Xenbase 111 k1 V* `) F: n" [$ x9 v7 X$ C( y3 N
为依赖而安装:
) M$ i8 |. K+ w# S1 e9 D: V SDL x86_64 1.2.14-7.el6_7.1 base 193 k. {2 C0 ]9 F& [9 K
glusterfs x86_64 3.7.5-19.el6 base 392 k
) a+ l% d0 h* E; W- ~! |( K6 K y glusterfs-api x86_64 3.7.5-19.el6 base 56 k% ?! V+ V: x3 t0 ?
glusterfs-client-xlators x86_64 3.7.5-19.el6 base 942 k
8 Y g: d+ Q1 X$ B: L# r, j' U glusterfs-libs x86_64 3.7.5-19.el6 base 303 k$ j8 r! H% w+ R, H
kernel x86_64 3.18.34-20.el6 Xenbase 37 M
: b( ~ L `+ R( c* q) z- | libxslt x86_64 1.1.26-2.el6_3.1 base 452 k
* N+ ?2 }8 ` l# M3 N, { mesa-dri-drivers x86_64 11.0.7-4.el6 base 4.1 M1 ~ O# r/ N& ^/ K) z" a5 U1 m6 |
mesa-dri-filesystem x86_64 11.0.7-4.el6 base 17 k# v. k, H7 K4 G8 k; j/ z
mesa-dri1-drivers x86_64 7.11-8.el6 base 3.8 M3 o3 s, i$ W! S& E! v7 ]. w
mesa-libGL x86_64 11.0.7-4.el6 base 142 k, }0 x! ~8 L2 W. @
mesa-private-llvm x86_64 3.6.2-1.el6 base 6.5 M, Z& r3 w5 Z* i" w# K+ n
python-lxml x86_64 2.2.3-1.1.el6 base 2.0 M @! e. \* z6 U6 N( m4 `
qemu-img x86_64 2:0.12.1.2-2.491.el6 base 836 k/ Z! K1 m6 v, X3 X, `
usbredir x86_64 0.5.1-3.el6 base 41 k k0 P$ v/ R2 i, Q
xen-hypervisor x86_64 4.6.1-11.el6 Xenbase 927 k
' n2 G& o( ^. Z* z& h xen-libs x86_64 4.6.1-11.el6 Xenbase 532 k
- \' i; ?9 W f xen-licenses x86_64 4.6.1-11.el6 Xenbase 85 k3 m7 m, `" J. S4 [5 ~# ~) A, f
xen-runtime x86_64 4.6.1-11.el6 Xenbase 16 M
6 h2 V: M% |4 L I yajl x86_64 1.0.7-3.el6 base 27 k( [- Q5 v8 Z& Y; B
为依赖而更新:" K" }) O( U: A
kernel-firmware noarch 3.18.34-20.el6 Xenbase 6.4 M
6 j+ b! f9 \* @: a! s, u libdrm x86_64 2.4.65-2.el6 base 136 k6 A7 a8 d, Q( M8 E( G
7 { `6 u1 g7 y- K/ D& v q
事务概要
2 u7 K% a8 t5 O9 Y) n$ r) U2 [# ]================================================================================================================6 u2 v; z( E3 C" L4 |
Install 21 Package(s)
( A& t) W" p9 ^+ ?) E1 hUpgrade 2 Package(s)
6 g! ?9 ~( G% \' W. }) {' [
) q. C0 p4 N$ z5 B1 B: z% q
( \' e }2 x; ]* r然后修改/etc/grub.conf配置文件
1 G. j3 F6 c; e& _; d" \7 A" \$ t! { I N
[root@BAIYU_175 ~]# cat /etc/grub.conf
4 j3 s/ V+ x1 r( k0 s# grub.conf generated by anaconda+ J0 S6 B$ K, _2 E/ w, l! H
#2 E7 n" ~7 H: \+ s# b
# Note that you do not have to rerun grub after making changes to this file
6 |) a9 C3 f- z& v% M( f5 {# NOTICE: You have a /boot partition. This means that
1 _) d2 }) n: Y# all kernel and initrd paths are relative to /boot/, eg.- c9 X: Y: w, ]
# root (hd0,0)
2 f" ]! c4 G( m" ~ Y8 Z( V# kernel /vmlinuz-version ro root=/dev/sda2
4 ]9 y& D. K6 N# n/ s! }# initrd /initrd-[generic-]version.img
* F; ?" X: t5 z% }. S4 r#boot=/dev/sda
1 L. Q5 y$ c$ I7 N/ n8 X- Rdefault=01 E. {( t0 _2 `; Q
timeout=5) ~4 A* B5 j3 q `% w. ^& c& h
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz% D' v2 y e, d4 }
hiddenmenu2 G( Z6 }! m+ m% c( i
title (3.18.34-20.el6.x86_64)
9 ^. x, l0 C! v1 X G- j, K1 S( q3 B root (hd0,0)
/ M' ]. c$ h+ Q2 w3 j: ~- q kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin/ P" u4 M& s n1 S/ ?( U
module /vmlinuz-3.18.34-20.el6.x86_64 ro root=UUID=d393efa7-a8b5-4758-bbf5-2eaead07f8c3 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=zh_CN.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_NO_LVM crashkernel=auto rhgb quiet rd_NO_DM rhgb quiet
. f; a3 @/ o2 i# z module /initramfs-3.18.34-20.el6.x86_64.img
5 @" ^& Y H& A' y- a# Otitle CentOS 6 (2.6.32-573.el6.x86_64)
/ k5 n* O$ v% p root (hd0,0)4 J& L% E* R$ R2 v6 w4 G% W
kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=UUID=d393efa7-a8b5-4758-bbf5-2eaead07f8c3 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_NO_LVM crashkernel=auto rhgb quiet rd_NO_DM rhgb quiet0 G0 \6 o( B! {% g' ~
initrd /initramfs-2.6.32-573.el6.x86_64.img
# q# |: x0 T1 D% q0 e[root@BAIYU_175 ~]#
5 h6 } o6 @& R3 j
& q9 e( r- E. x0 P# X `# J( @7 P" C& H8 q1 ~" i0 U' L
然后重启5 }3 f5 H5 r5 h
# }6 M' m: J# M' G" C8 M0 M4 f" w
[root@BAIYU_175 ~]# uname -r) E% a9 C, c2 w9 N
3.18.34-20.el6.x86_64' [. A' h6 S9 o8 }7 d
[root@BAIYU_175 ~]# xl list #查看运行的虚拟机,注意此时我们操作的是Dom0,虚拟化平台已经安装完毕,可以创建虚拟机了,- h. q0 P. T8 c. O
Name ID Mem VCPUs State Time(s)
! x7 N6 @4 k' q) g EDomain-0 0 1024 2 r----- 36.7+ T+ m2 e8 _ ]2 s
1.
# `% d& K/ p4 D* V* q4 u2.
, O, I. K# c) \1 r4 [6 F# d3.9 C8 \' n9 N( e3 T
4.
3 F- v, R+ T- L5.
1 f1 _: ?% n9 U1 G- n5 m9 I4、Xen的管理工具栈3 \" C- {8 l( |! g" }. v! ^- c
. A* F) S9 G4 o% c$ @
xm/xend:在Xen Hypervisor的Dom0中要启动xend服务,重量级' S4 P$ s6 q, [2 T/ r3 i! k
8 X: N, S9 G" O8 k
xm:命令行管理工具,有诸多子命令:. Z* ~; P5 w$ b# L& O7 H
" r4 _( l& D) p5 D create,destroy,stop,pause...
/ Y$ |2 J9 o3 Y) g8 x Q
! r; R5 `) ~0 Exl:libxenlight提供的Xen的轻量化工具,Xen 4.2 xm和xl同时提供,4.3 xm提示被废弃,& `# n& a9 w' g4 _
) o9 ~- c9 p" q8 M6 N* i, Vxe/xapi:提供了对Xen管理的api,因此多用于cloud环境: Xen Server, XCP: Q E- ]9 Q6 O- Q. b% f5 Z
& c( ~' I; `7 G3 C- w" E6 }1 a avirsh/libvrit: python语言研发 ! p" F; v/ h% D G$ X3 Y* E
) ~" g$ e& `2 Y: t
在每一个hyper上安装libvrit库,并启动libvritd服务,就可以用virsh管理它们
1 t0 M5 ^" _ x7 Y5 t8 p! S3 {, g+ b3 S8 [. j7 }8 v
, d; }8 k3 h7 c' d% D9 C8 z
) M* b! L5 l& Y: r( O5、XenSrore- k/ U, F9 b: j( |, P
3 k8 i3 Y1 Y" W3 E 为各Domain提供的共享信息存储空间:有着层级结构的名称空间:位于Dom0
! ~- v7 w5 c B2 ~% |, @1 o& j2 z
9 k" p( K4 V/ V+ h; ?2 P4 Z4 J) Y1 d$ n$ G! j6 B% p
/ a' G& l) z) u! r2 p+ i二、Xen的使用
$ q' w6 f1 u) Z; x8 c% F X; \9 K) L2 Y; ^& h& z1 D; t# o( y
1、xl命令详解. x2 }: O3 y. C7 o3 @& ]
- ~9 g0 C5 A& S# t[root@BAIYU_175 ~]# xl
+ _# j# T& T, c+ l7 w& K' q- ?Usage xl [-vfN] <subcommand> [args]$ z. D% M) y, j7 W; B
4 }, j8 a; S' m+ t b/ U1 H; W
xl full list of subcommands: #子命令完整列表
" g) D7 z* f# Y* e/ Y' ]& L
8 m; c: K3 m" Z ~7 I create Create a domain from config file <filename>' K1 c* u% r" D1 W
config-update Update a running domain's saved configuration, used when rebuilding the domain after reboot./ r. o3 I8 q2 B4 Z& J: a3 I& C
WARNING: xl now has better capability to manage domain configuration, avoid using this command when possible; ^1 o: L9 A1 I
list List information about all/some domains #列出所有或某个Dom的信息
8 N8 ?, _$ U, _ T destroy Terminate a domain immediately #之间关掉虚拟机的电源4 m% g* P) D* ~4 }
shutdown Issue a shutdown signal to a domain #正常关机
1 ~5 P. @# r% Y reboot Issue a reboot signal to a domain #正常重启/ r5 ?; ?; x1 Z/ C9 }3 K- ^
pci-attach Insert a new pass-through pci device #增加一个pci设备,热插拔
& a4 E, X& Y& C# _9 P( e pci-detach Remove a domain's pass-through pci device #拆除一个pci设备,热插拔
$ p$ E3 l$ l5 P" M! @8 D pci-list List pass-through pci devices for a domain #查看虚拟机pci设备,除了网卡,查看网卡有专门的命令$ U4 O5 E6 u" `: z+ i$ _5 W8 o
pci-assignable-add Make a device assignable for pci-passthru$ Z( l6 B- P4 g; {8 x, x
pci-assignable-remove
" |4 R" U6 T* o' G' h Remove a device from being assignable/ o6 C( s" m' b1 U f
pci-assignable-list List all the assignable pci devices
" ?& M. i; M. q pause Pause execution of a domain #暂停虚拟机,保存在内存中
: j' `7 F. _& Y" y/ T, i unpause Unpause a paused domain #解除暂停. Y$ }. [3 m- B- c
console Attach to domain's console #连接虚拟机的控制台
0 Q, `+ w) ^( j3 E6 s vncviewer Attach to domain's VNC server.& k/ u: f9 u% `6 p- u. S
save Save a domain state to restore later 4 p. p* z. m8 D' C- x0 V; L c
#将DomU的内存中的数据转至指定的磁盘文件中,相当于挂起. P4 [' N j5 q9 u# z$ ?5 y
migrate Migrate a domain to another host#将虚拟机迁移到另一台物理机上
' B6 _1 V) ]: V$ E restore Restore a domain from a saved state
( O. ?" k# r4 u+ H2 w #从指定磁盘文件中恢复DomU的内存数据,
* i3 C: s3 A4 a+ {7 C migrate-receive Restore a domain from a saved state8 k6 Q7 m& R3 n7 }( _
dump-core Core dump a domain #转存内核?
8 U2 M7 T4 M. { cd-insert Insert a cdrom into a guest's cd drive #插入光盘
! u0 k5 m3 ?( }6 h4 x# p cd-eject Eject a cdrom from a guest's cd drive #弹出光盘( b$ i* @) n1 s& u& m% G
mem-max Set the maximum amount reservation for a domain& [8 {5 R% S5 V% P$ g% O
#内存最大上限( H. d) g' k* @( ?
mem-set Set the current memory usage for a domain8 s( V/ I9 C5 j
#内存大小
# G5 }8 ?2 G* }8 r" I9 s. Z+ H button-press Indicate an ACPI button press to the domain' U ~' B. x9 T: W& ?' {
vcpu-list List the VCPUs for all/some domains #显示虚拟cpu
8 D9 u' q5 J% E, `4 P$ D$ t vcpu-pin Set which CPUs a VCPU can use
# ^( ~# G5 E7 j! d vcpu-set Set the number of active VCPUs allowed for the domain/ b4 A0 x! L6 H1 S* y
vm-list List guest domains, excluding dom0, stubdoms, etc.- j2 k$ L( l D: s/ g. I( B
info Get information about Xen host" [; |9 F' Y4 J* K$ u. _/ ^/ ], f
sharing Get information about page sharing
6 I& y- E+ h/ W3 l& V- { sched-credit Get/set credit scheduler parameters
B7 g+ I, H4 U8 p sched-credit2 Get/set credit2 scheduler parameters
2 a4 K9 F; ^4 V sched-rtds Get/set rtds scheduler parameters/ w' L( T( U3 `: e
domid Convert a domain name to domain id( D% Y: m& q+ n% X- k
domname Convert a domain id to domain name8 @9 W5 a4 R0 p1 M9 x1 @
rename Rename a domain #重命名7 k R' I8 {4 P
trigger Send a trigger to a domain
& o7 x7 U. U" ~+ q& j sysrq Send a sysrq to a domain
, C) O6 V# v4 E+ D( e( \, v debug-keys Send debug keys to Xen
# b+ i7 Y+ C/ }. j) c dmesg Read and/or clear dmesg buffer #虚拟机启动时的引导信息
9 @$ w& j" C) }) n2 y; H* J1 L top Monitor a host and the domains in real time
5 x! ]# K! s: b: Q- v network-attach Create a new virtual network device; V! T! I' j! j+ K1 {* n/ ]2 e
network-list List virtual network interfaces for a domain
* i( b, N- ]! D0 Y network-detach Destroy a domain's virtual network device, \+ v: `# y: s( n9 O8 l, P) {
channel-list List virtual channel devices for a domain
: s- u2 B/ M9 X: L, b- V block-attach Create a new virtual block device #增加一块硬盘% p) J% `* }9 s
block-list List virtual block devices for a domain#查看硬盘1 s9 B) z& M. h- \( N: ]' d
block-detach Destroy a domain's virtual block device #删除一块硬盘3 ]( |9 Z) F/ V3 `5 g
vtpm-attach Create a new virtual TPM device1 ]& B. z) A: U6 o7 l4 ]6 H
vtpm-list List virtual TPM devices for a domain
- [ E- R! w! b4 M0 H, ^- f$ h4 C vtpm-detach Destroy a domain's virtual TPM device- _/ F+ S* ?0 @" g* C
uptime Print uptime for all/some domains
8 q; c0 s3 F4 b8 N3 r claims List outstanding claim information about all domains
: t2 r1 A; y; L# L- P tmem-list List tmem pools
+ Q3 y# U# Z, f$ F8 O" C tmem-freeze Freeze tmem pools
. Z- v. G9 Z! X7 O; K; [( {7 Z/ X tmem-thaw Thaw tmem pools1 b4 `: m3 q3 V% X
tmem-set Change tmem settings
) @! [$ x( J. b2 ^ tmem-shared-auth De/authenticate shared tmem pool
# G5 e3 N' t1 Y$ l* W tmem-freeable Get information about how much freeable memory (MB) is in-use by tmem* W0 y2 G( C4 c- ?7 x: f
cpupool-create Create a new CPU pool! I8 x. B5 {6 X1 K+ M) D. w
cpupool-list List CPU pools on host
/ p3 j* F) {( B9 a; F6 g) g% ~ cpupool-destroy Deactivates a CPU pool3 W4 v- I1 ^4 _* f) D% o& c. Y
cpupool-rename Renames a CPU pool
; ^1 v% x; D! K4 q cpupool-cpu-add Adds a CPU to a CPU pool) F/ c" Y" p1 N) g) `4 m8 Y
cpupool-cpu-remove Removes a CPU from a CPU pool
) e* m' l+ E7 m: E cpupool-migrate Moves a domain into a CPU pool6 Y/ s/ [8 R! q. {" w4 E
cpupool-numa-split Splits up the machine into one CPU pool per NUMA node; B$ ^ d9 w9 U, j+ f, P( T m/ @) K' K
getenforce Returns the current enforcing mode of the Flask Xen security module
- f# Y: I& K. M8 [3 u* x! K/ y setenforce Sets the current enforcing mode of the Flask Xen security module. ]- y% K3 p/ x
loadpolicy Loads a new policy int the Flask Xen security module* Z/ W- B4 U5 G0 q$ ~0 q$ d ]
remus Enable Remus HA for domain
- C" X# a# X3 p devd Daemon that listens for devices and launches backends g/ K9 j4 K* L: N0 w. c/ _
psr-hwinfo Show hardware information for Platform Shared Resource
/ o: e& J$ D* d/ z* d" \ psr-cmt-attach Attach Cache Monitoring Technology service to a domain
& e0 i; ]6 a6 V$ |; k% ] psr-cmt-detach Detach Cache Monitoring Technology service from a domain4 I# K1 |) {& y$ ~0 |/ i8 N
psr-cmt-show Show Cache Monitoring Technology information
0 b& z- A9 F" i% N! o/ F# i psr-cat-cbm-set Set cache capacity bitmasks(CBM) for a domain
* ]' u d6 |$ V' r' F, x: a psr-cat-show Show Cache Allocation Technology information
' U8 N$ l8 o* t) i5 b
, ^! D3 h6 M5 d |' T1 m' _' W* q4 H. L- c6 n ~7 B: q4 v- U
1)xl list 显示Domain的相关信息8 U- A3 y, d6 U V& I0 _6 k# C
" z, ?. b! G9 h2 ^
[root@BAIYU_175 ~]# xl list
7 A$ F3 F, U) T% v8 QName ID Mem VCPUs State Time(s) 运行时间# P5 B, s/ L+ L& t9 u S
Domain-0 0 1024 2 r----- 65.25 y, p9 ^% }5 R$ n# B# t# i
1.) c5 t0 X: E) Z* K4 B
2.
1 V( f' Y( I( ~; v3.
( J- f c$ E' Y7 G, P; c, S# h& Kxen虚拟机状态:
4 w6 Z% J3 c: }9 w; ?& s; ?8 L Q% R5 i' L Z
r: running
8 ?3 I0 m9 X% E7 G! z/ M2 D" u9 k+ w) B8 C Y
b: 阻塞 ~6 { o- O) y
7 u f. ]! ?/ N6 G' t# D
p: 暂停 #并不等同挂起,数据都在内存中没有保存在磁盘中9 ?/ ~2 Q+ E/ [' U+ ~$ D" ^6 U
0 N3 e6 x9 ?$ T) t# ks: 停止 ## g( C3 S, ~4 B! e# C8 g' C
2 n8 y4 i/ L3 k* h8 B( ~c: 崩溃& S, h1 U( l N( L, a! O
3 r7 w( \% I9 N' x, A- Zd: dying, 正在关闭的过程中- k2 `2 P: f) ~1 z# L" A F
' y u0 {6 ?" L, O$ }) v
3 F6 \" G0 |* W( J! @. }9 K# O9 b, `! w
1 w' s1 a- ?) b2 W7 f1 u9 w
xl的其它常用命令
7 |. n+ n/ U, U. Z, _2 x0 c
; F8 W3 H. U6 M0 x" U% rshutdown: 关机
9 t; S: r9 P6 ~- V% m b4 g; w5 d( [
4 ~( q3 j- Q6 H. V" H/ ~reboot:重启
5 O& @( }: ]* |8 v2 p7 W6 H
0 i/ B3 R1 n. O+ J/ H5 \, Epause: 暂停 x( L. v* `9 O2 B {3 U- ?& H
* ~% \4 M: v9 F
unpause: 解除暂停
7 L- ?# ?4 Q6 { A- ^# U# o# |$ z- H7 U1 M: I5 @8 b, i
[root@BAIYU_175 ~]# xl pause -h4 o' {7 A2 f# e$ p; v
Usage: xl [-vf] pause <Domain>
9 \1 P* \1 t: Z6 P7 C" e9 x3 h+ v! T. M: ?
Pause execution of a domain.
7 C" d2 A8 i% v. e3 @* ^. F" m/ k, k1 B9 r2 P7 ?+ L0 z
[root@BAIYU_175 ~]# xl pause --help t6 P# w: j0 V# q1 J
Usage: xl [-vf] pause <Domain>' T, q( `* ~ f. |
2 F' K+ Z# C6 i1 Y+ E! X& J
Pause execution of a domain.
- z0 M3 \+ G" j( W" }! N0 r- q2 L8 H" D. m
[root@BAIYU_175 ~]# xl pause anyfish-001
3 y- R' ]% d% Q2 j: N4 U# ~[root@BAIYU_175 ~]# xl list
4 Q0 {) ~( }& h$ D7 }Name ID Mem VCPUs State Time(s)
8 v/ Z; C6 y L1 X. TDomain-0 0 1024 2 r----- 125.8
2 G; t# Q5 @) X; c9 V& [% o& M0 i3 Yanyfish-001 10 256 2 --p--- 4.2
# F7 m% D6 n. `# `anyfish-002 12 256 2 -b---- 8.7
$ e" |- n8 ~0 `" f; v4 g4 S7 h5 K1 r' R' n% g z3 g5 w1 j; b
5 U" T. Y" k3 d. K5 y; S' e [' j
save: 将DomU的内存中的数据转存至指定的磁盘文件中; { B. V: p9 s; R
m& V2 C* _2 a7 m7 j
xl [-vf] save [options] <Domain> <CheckpointFile> [<ConfigFile>]
- ^3 s m, ]0 R' W/ d* [/ x5 J& c% ?, r) @8 T2 O2 N! @3 h+ `
restore: 从指定的磁盘文件中恢复DomU内存数据;: N8 R# L% J7 e' r T
3 e+ E% | V- ?: l# X
xl [-vf] restore [options] [<ConfigFile>] <CheckpointFile>
- }$ {: c& H" F/ f) G Z- _" D7 h
- B% O. A" p7 e$ k[root@BAIYU_175 ~]# xl save help
1 r! |) _: E' Z# X! @8 e'xl save' requires at least 2 arguments.
* z/ ]. ^* T3 F4 B
5 x2 m+ |2 [& u4 rUsage: xl [-vf] save [options] <Domain> <CheckpointFile> [<ConfigFile>]& J0 ]" D9 N; g! i* ]* J
8 _" T u$ g& k' x' O% M4 o
Save a domain state to restore later.
1 U" Q7 D1 B# G! d% F' @
6 x! ~8 {5 X" FOptions:+ D: Q3 l! J1 X
0 x4 c6 U9 s0 C& _-h Print this help.7 D: ^0 W" u# X$ N
-c Leave domain running after creating the snapshot.! V4 z3 X7 s* O( ]
-p Leave domain paused after creating the snapshot.
8 B$ M7 f1 I& K6 [- w) v! Q9 U8 `6 E; m
[root@BAIYU_175 ~]# xl save anyfish-002 /tmp/anyfish-002
5 D; w4 U1 U1 N9 [$ g2 TSaving to /tmp/anyfish-002 new xl format (info 0x3/0x0/1024)
3 b: Q8 D0 T$ ]: mxc: info: Saving domain 12, type x86 PV
9 U6 @) V: {. w& O" H# f: {xc: Frames: 65536/65536 100%) M+ C, A: [+ T: \: q; S- z
xc: End of stream: 0/0 0%
" w( N' H; J8 a2 t+ d% u+ i+ S' ^6 H
[root@BAIYU_175 ~]# xl restore /tmp/anyfish-002
& D- Z1 ` i1 i/ OLoading new save file /tmp/anyfish-002 (new xl fmt info 0x3/0x0/1024)* U5 R5 `4 k( q5 S
Savefile contains xl domain config in JSON format
# [' J( U: R) G, E6 ? iParsing config from <saved>
6 c* \0 h% n2 R/ m# K) x7 \" sxc: info: Found x86 PV domain from Xen 4.6 d- n( W5 k# G) r
xc: info: Restoring domain
4 i0 s& P6 v) ~8 m* ixc: info: Restore successful
3 k' I4 G- I! w8 f+ X# y2 hxc: info: XenStore: mfn 0x22a3a, dom 0, evt 1, [6 j1 G. V4 w) Q; Z& H
xc: info: Console: mfn 0x22a39, dom 0, evt 24 k# U* l6 A! K5 p% \6 T1 C; c
3 h) w% f6 S3 B% l& D+ K" G( s; ~' Q0 ^$ N
* s7 G R+ Q+ T" e- A+ I& b, N
vcpu-list 列出虚拟cpu
1 o% ~" @: B% a4 ]" Z$ M5 {* M$ ^; E6 G' a
vcpu-pin 把虚拟cpu固定在物理核心上
9 n$ I5 i0 B2 U9 v8 v; I0 r0 ]: ?6 t8 i; Z/ q& A
vcpu-set 设置虚拟机的活跃vcpu的个数, L+ i& B( i6 l6 ]3 N) k- I" J. T
4 u; u6 p6 s$ h3 w( C0 G+ ~
[root@BAIYU_175 ~]# xl vcpu-list -h/ e4 K% h) ~4 k! X1 K
Usage: xl [-v] vcpu-list [Domain, ...]
" Q7 Z4 G" v% w+ n
% n8 V3 R/ L) ^List the VCPUs for all/some domains.! ~, v7 z$ t1 z2 L
" ]( ^1 e, V% l9 V }2 j4 E% C
[root@BAIYU_175 ~]# xl vcpu-list
: Z3 D) t. ]# Y- A, A8 QName ID VCPU CPU State Time(s) Affinity(亲和) (Hard / Soft)5 p8 g1 V8 w/ Y9 o4 O5 S+ t. S
Domain-0 0 0 0 -b- 236.4 0 / all
# [1 Q5 W6 ~* \7 {( VDomain-0 0 1 1 r-- 310.0 1 / all
9 s! L/ G. A3 I8 i, @$ eanyfish-002 17 0 2 -b- 8.9 all / all
/ }! P% `5 E C9 z( Uanyfish-002 17 1 0 -b- 10.5 all / all
3 f2 ]/ f1 C) [3 s a2 l' a4 Hanyfish-001 18 0 3 -b- 10.1 all / all
; V1 {4 F, {5 J: }6 w2 T7 Fanyfish-001 18 1 2 -b- 10.8 all / all7 O% G# U+ j; X( r9 s- j4 e7 \
#运行在哪个物理核心上
9 r2 a7 v( O3 r7 J$ x# M* Q) m" z2 u% K+ `
# x9 x9 g B, u9 d2 x( m
, k# h9 q$ \6 O& O3 n- }2 g l( d6 w* x. _. k. p1 f5 a8 X
info: 当前xen hypervisor的摘要信息
1 [' W7 n. n( Q7 q% l3 t: ~! H) {
- i8 K% ^9 w1 q4 c" `5 t' Odomid! x2 n/ p) ~! v% k
8 f h- i# r7 Z/ w& Sdomname3 L- {; a% b! s" _* q6 {$ U
m2 N9 K$ q- d" i& X% {
( J v- Q2 _) r$ V; j+ [1 \4 W/ K ?+ f0 S# X5 m
top: 查看domain资源占用排序状态的命令* I" W/ U4 b: z! |) Y8 I& E
8 G" Y \/ V8 H7 {$ N/ P! l+ t$ s/ U$ z* y8 _8 v' f: H$ E6 v8 F
, R- [8 s, `0 T1 q7 Fnetwork-list: 查看指定域使用网络及接口;
: Y7 G1 T+ c8 C# J# g
1 Z3 A' ?' H# m) Q- J4 R; Unetwork-attach:热插
$ H4 s" }) n+ f1 |) g& t
$ y1 m, b+ ^' h6 gnetwork-detach:热拔. N, K" l1 _2 h f
& f2 g& r( l; ]6 Z9 L3 q( @7 |1 r+ `% F0 i% K! t: D3 r
; B* S; I5 f( D8 i, Bblock-list: 查看指定域使用的块设备的列表;
1 L; }1 W. j7 F9 f1 c9 B* D( I
) a8 `) R' ]& b2 ublock-attach
; K( [5 A. s9 J) F# J- E- [" v
8 a3 F. c& V% Bblock-detach
7 Y8 g) |4 p( F; F J; j: ^6 V8 _) O- y8 P
% p- o& k) ^3 s& y5 ]& g
- [4 D; b0 L6 V: O3 ~uptime: 运行时长
! D, b- S' \8 y( _/ X/ t1 z/ t7 Y& ]
: ?" I7 G2 f6 Q4 z, P8 |9 d
# a* i$ O0 d4 @) f' q* [+ P& R' ^* }
三、如何创建xen pv模式9 `2 j- }8 }2 i4 X6 @
( a+ Z0 s( F7 C9 j8 D' A 1)kernel #DomU的内核文件可以放在Dom0中也可以放在DomU中
, c5 x# X3 n+ y! ~" e
} e! S! t# _0 v# t% l8 M 2)initrd或initramfs / i( I% P: _$ p! k8 _
; f- \3 H* K! x, e% T: X7 F
3)DomU内核模块9 C3 Y. ]$ J4 Z; Q
4 ]9 n- I7 P# r 4)根文件系统8 B( l6 D( }3 V0 N/ J
) Y* ~3 w8 s3 j 5)swap设备
2 j. P' D; G/ _: C, X( G9 x! f5 F/ K6 ?4 b$ I5 M/ @+ c7 n' S2 C7 ^7 F$ b
将上述内容定义在DomU的配置文件$ t. x5 t8 t" V
W I: z- h! W3 q6 N9 M注意:xm与xl启动DomU使用的配置文件略有不同;
$ C% j8 M$ p: K" T w* W% @+ c3 C3 A: Z7 @5 F
xl.conf是xl命令的通用配置文件
% i2 B8 O0 z$ G7 f G
T- e) F! y* G6 v( p" d xl.cfg是启动某个DomU虚拟机的配置文件$ z6 X; J; H9 S8 c% o3 J3 P6 m# T
' h ?+ F' o* B. }5 c; W9 ?
对于xl而言,其创建DomU使用的配置指令可通过“man xl.cfg”获取( q$ l7 n! C, ]0 a: L
3 ?& f! l6 {" R1 \+ Z常用指令:8 X& V% Y, h' u! y. @4 o: n6 @
# d0 ?! y1 }( C& N4 g9 ]name: 域惟一的名称6 l- o8 `8 F L; g; a9 G; |+ Q, J
9 _* p! }+ [' t" X# v
builder:指明虚拟机的类型,generic表示pv,hvm表示hvm
5 D- P/ i2 i& r& r" w3 ]1 g
* }9 h& U3 g1 p% n vcpus:虚拟cpu个数;
( C8 b* u4 H: _$ ~$ R* p- \3 I
: b: ~2 u5 Y* s& Q& ]0 Mmaxcpus:最大虚拟cpu个数
" ~3 ]' Z! ]& m. w. n2 u7 j! G# u0 O5 A/ C& k
cpus:vcpu可运行于其上物理CPU列表5 U- ?% ~( H; _! V# W* s0 C
) j# r, C. i9 n& y8 nmemory=MBYTES: 内存大小
4 P+ B* B: w4 r4 |/ n2 C1 y8 _" j/ g
maxmem=MBYTES:可以使用的最大内存空间
% s$ K8 F7 ~( L8 x+ A5 _( F4 i; m- c* {* }+ f7 ?
on_poweroff:指明关机时采取的action# {% [. v* y2 R' }
8 l( Q9 Y8 @, K V" `* S7 \destroy 断电, restart 重启, preserve 保留域
9 j' b! f% ]# ?' i$ X* z8 R. C6 A# p% \. e: [
on_reboot="ACTION": 指明“重启”DomU时采取的action
% s/ \2 F: P: u9 E& ^2 l8 H
: q6 l2 K, h, p6 A! u% Ton_crash="ACTION":虚拟机意外崩溃时采取的action
0 {. q0 Y3 I7 E; B" N% F' U2 H h/ y {! Q6 K9 j
uuid:DomU的惟一标识; #不是必选项' O2 M' v6 z8 H* ~: w
% d% S9 `) ]- K) Z( B+ zdisk=[ "DISK_SPEC_STRING", "DISK_SPEC_STRING", ...]: 指明磁盘设备,列表,
$ a& {; U0 H' V( ~! V8 F) b; R8 R# k, X# l2 v+ ^
vif=[ "NET_SPEC_STRING", "NET_SPEC_STRING", ...]:指明网络接口,列表,
, U6 C$ e0 S6 r3 {; l" y( F- V& j m. {; \5 q! |0 Q+ c
vfb=[ "VFB_SPEC_STRING", "VFB_SPEC_STRING", ...]:指明virtual frame buffer(显示设备),列表;
- ^" ~1 c4 j" y( p& v" j, r+ @
pci=[ "PCI_SPEC_STRING", "PCI_SPEC_STRING", ... ]: pci设备的列表
% L9 h8 y/ b/ ~4 A. q) r! J6 ^" K
! c2 P" H2 k% h! U# ?+ c) a; ~ F( G9 v3 {2 W" [& a. d; i
9 K, D4 q9 O# u+ ^
PV模式专用指令:0 g7 b4 {- g$ a+ }2 J. Y: c$ M; A. b4 w
/ C$ h+ D2 V7 L8 V
kernel="PATHNAME":内核文件路径,此为Dom0中的路径;
* X2 ` V9 z/ U3 v( }7 A/ ]
: y( y, l6 j- o G* P; \. Framdisk="PATHNAME":为kernel指定内核提供的ramdisk文件路径;
6 ~1 `$ v" i/ ^7 P. }4 t6 u2 O* Q/ u' M+ ~2 Q
root="STRING":指明根文件系统;
, l3 l" C M5 C6 W. M
2 ]" [( [5 e$ x" C, textra="STRING":额外传递给内核引导时使用的参数;
3 A! d2 c* |2 n- i, ^; k
' J% w& N' c2 t+ Q7 o2 J6 C; L, U! z; z/ g
) ?# K( _3 _* o& Y bootloader="PROGRAM":如果DomU使用自己的kernel及ramdisk,此时需要一个Dom0中的应用程序来实现其bootloader功能;4 t C3 K" }- W- P' }
2 B/ ~" d k9 x$ c& b1 o
1 l6 X! C" N. T, V) M
0 l% G* i5 l5 o, D. ]
磁盘参数指定方式:
7 r+ A: {+ j! T$ M5 G- g% ?6 Q$ N: s+ q. O. B* s
官方文档:http://xenbits.xen.org/docs/unst ... k-configuration.txt
7 m; ~% l! i8 B! c j1 H9 f9 k. P( C5 L( K0 |9 ]% l6 W- t4 ?4 M
[<target>, [<format>, [<vdev>, [<access>]]]]8 K* \7 v. M& h# y5 x
2 I. |+ E; f7 q2 X ?5 H3 v$ _6 k<target>表示磁盘映像文件或设备文件路径:/p_w_picpaths/xen/linux.img,/dev/myvg/linux: a, t2 U% R4 v2 R O4 ~" e5 Z
- Q. ?8 O. T) Z. O: L; S4 i2 a) H. h<format>表示磁盘格式,如果映像文件,有多种格式,例如raw, qcow, qcow2
4 l, G- I4 N! h3 T M% I2 u/ d. _; E7 |4 p, h
vdev: 此设备在DomU被识别为硬件设备类型,支持hd[x], xvd[x], sd[x]
8 t. c2 y* S$ d; p2 L. R
2 Z4 j# O3 b, e- j) ^access: 访问权限,% F) l3 l" x7 ~* e ]6 ?- d
) ~" @* e% n* B% _1 ero, r: 只读
3 o3 J# o/ c! z( {; ~
, ~# o, E' N; q+ |3 {8 r. brw, w: 读写" I0 s" B6 j. S
% s) }) T9 I2 _9 V/ k例如:
) C o( D& W. P" O/ p5 H5 n2 P% s& }9 H
disk=[ "/p_w_picpaths/xen/linux.img,raw,xvda,rw", ]
% m& g# c: y" z& U- u3 W k* G( x: E# U+ M/ }0 X' K. O
4 X6 k5 J7 G+ p$ R4 x# s# @( P7 W
# @8 a% i4 `8 y# j4 N" A
使用qemu-img管理磁盘映像:1 f' `% s/ P/ G' l5 X1 K1 C4 j
" S |% T! _$ ]8 h& D9 J9 bcreate [-f fmt] [-o options] filename [size]
( ?5 f0 q {% k$ u0 V" w/ l- v' |3 G/ u( m, R1 f- S8 @! r- D
-f 指明创建磁盘的格式0 H' W! _# p. Y$ B$ T
& N7 N. _6 k" Y' n' x; h0 z -o 特定格式支持的选项
/ o: f( s% Z4 m4 v9 o6 V# q. f# \
5 Y) @8 e& R/ P* ?可创建sparse格式的磁盘映像文件,慢慢扩展到指定的大小
' R8 M: |6 h* V3 Y
8 m: [1 w3 ]7 R" I4 @% @' t. y; b% Z7 f1 ~# Q0 c4 ~$ N5 M' q
; H' v H, p/ X3 f4 |7 P
2、创建一个pv格式的vm
' a' p( j/ [$ e
7 k4 S8 O1 N, P7 N' x! G(1) 准备磁盘文件: u* Y. ]7 M* ?2 a
5 U6 P7 u( P' e* j5 R7 i. `0 i qemu-img create -f raw -o size=2G /p_w_picpaths/xen/busybox.img
( b! f1 Q$ u, ^/ w t; s# y
5 T$ s' }( e: Y5 g; k mke2fs -t ext2 /p_w_picpaths/xen/busybox.img9 z# f m0 x% R" L0 m6 n/ ]9 h: h
* ^" m8 ?" q% ][root@BAIYU_175 ~]# mkdir /p_w_picpaths/xen/busybox.img -pv" s3 z! d v7 x
mkdir: 已创建目录 "/p_w_picpaths"9 O9 D- G q, L. J6 d
mkdir: 已创建目录 "/p_w_picpaths/xen"
; q0 A' |' J3 m3 l. Nmkdir: 已创建目录 "/p_w_picpaths/xen/busybox.img"8 ?- }9 S" C$ \. p& O$ B
[root@BAIYU_175 ~]# qemu-img create -f raw -o size=2G /p_w_picpaths/xen/busybox.img
7 p% y; a4 }% OFormatting '/p_w_picpaths/xen/busybox.img', fmt=raw size=2147483648
% |8 w5 A9 I* b[root@BAIYU_175 ~]# ls /p_w_picpaths/xen/
3 w, U" a6 ?! Mbusybox.img# L6 D; n- }. p3 Y3 e
[root@BAIYU_175 ~]# ll /p_w_picpaths/xen/. _. f7 @$ F% ^0 m% v
总用量 0, h. J) D$ e/ Q' b0 b
-rw-r--r-- 1 root root 2147483648 7月 14 23:52 busybox.img" n _. R9 b* q+ Z- M* C8 i6 ? h
# Q, n2 g. b+ w9 Q
1 }9 g8 m- z* v8 h, m0 I
b" D ]; `- {' p: w: q+ c- u* p& _[root@BAIYU_175 xen]# mke2fs -t ext2 busybox.img #为什么要用ext2格式?9 H! @ |/ l9 x+ F- J7 j
: O7 Z- ^9 R8 g" `$ }, j
[root@BAIYU_175 xen]# du -sh busybox.img
8 n3 p% w T9 V3 F2 ]9 g% x97M busybox.img
' ^6 `, E5 q0 X& u3 J
9 E$ p( X* U" p( {- x+ ~% Z! f) T/ d; F) h% `
1 x" c. I# F! _1 h9 {+ d
[root@BAIYU_175 xen]# mount -o loop /p_w_picpaths/xen/busybox.img /mnt- K& t" \9 K9 I! _: u
[root@BAIYU_175 xen]# ls /mnt
3 T# Q8 e5 |# O* vlost+found
& d3 c+ q$ s8 B) g8 z
8 D, s$ H( C2 {5 _% g& o
7 S% N. E% T; d+ b6 B1 ` ~8 O6 e- ]2 `) \: W9 V
(2) 提供根文件系统
* Z) M7 Z0 D2 D0 x/ I# A( W% W4 s/ p. p, X+ w
编译busybox,并复制到busybox.img映像中3 P, t* b$ ?5 e& P/ U
7 G0 J; l5 ]! X2 K
cp -a $BUSYBOX/_install/* /mnt7 d: j; O# ?* \" S# O
1 u2 B( y( |3 v4 ]. P/ I
mkdir /mnt/{proc,sys,dev,var}7 ?9 Z. O U# ^3 {
' n& W# F! V8 w; v& S+ H+ K[root@BAIYU_175 busybox-1.22.1]# yum groupinstall "Development tools" "Server Platform Development" #安装编译过程中可以用到的包
$ u( V+ F9 F) D* U0 o4 l3 c! I' J. _[root@BAIYU_175 busybox-1.22.1]# yum install glibc-static #为了方便移植busybox,把busybox编译成静态链接格式,不让它依赖额外的其它库,需要依赖这个包
( C, c; Y, I4 }4 D9 N[root@BAIYU_175 busybox-1.22.1]# make menuconfig
: g) ?1 U2 ^& u+ D$ i* {% R1.0 G. j, f# S+ V9 w( d! S$ K$ b8 e
2.
% G" \; \5 o) e& \: S3.8 W) @+ n. v& `# l O
' o: x" ]4 J' y) r7 N3 X6 P) H$ Z `* G6 F0 ^: {* D% i3 u
勾选编译成静态链接格式
6 y1 f8 q1 H' o+ D' S
6 N5 p I! ^4 c[root@BAIYU_175 busybox-1.22.1]# make
& T4 O& Z0 c: g[root@BAIYU_175 busybox-1.22.1]# make install
5 L* I8 F" G( r$ E+ W- w# `1 u1 j* D. D% u- D
[root@BAIYU_175 busybox-1.22.1]# ls. Y$ `2 w7 I' N" ]2 @& `4 L& h W7 ^0 G
AUTHORS Makefile.flags applets busybox_unstripped debianutils include miscutils scripts
i/ Z; H: V2 n* o9 CConfig.in Makefile.help applets_sh busybox_unstripped.map docs init modutils selinux6 u$ s% ]( ~0 w
INSTALL README arch busybox_unstripped.out e2fsprogs libbb networking shell4 ^( o) }' z" o
LICENSE TODO archival configs editors libpwdgrp printutils sysklogd
6 x. d2 v5 R, a3 pMakefile TODO_unicode busybox console-tools examples loginutils procps testsuite
$ B- M3 D9 }9 d9 vMakefile.custom _install busybox.links coreutils findutils mailutils runit util-linux
, e+ t# r0 f) C[root@BAIYU_175 busybox-1.22.1]# ls _install/ #默认安装的目录
% G& E( T7 V1 o8 F$ e( xbin linuxrc sbin usr5 S( S/ W% ? s
& c$ j# a) O$ f3 e: [. i
( _/ j4 Q3 Q& d e复制文件到/mnt目录下7 p2 F% o Z7 [- }4 p
$ J+ j6 }9 z4 o3 ^
[root@BAIYU_175 busybox-1.22.1]# cp -a _install/* /mnt
( k1 d; n0 s4 T0 d: e[root@BAIYU_175 busybox-1.22.1]# ls /mnt
4 @) U' V- a6 L- k8 pbin linuxrc lost+found sbin usr
/ q' s7 X! [% `- x) w[root@BAIYU_175 busybox-1.22.1]# cd /mnt$ Z+ ~: j# w& S8 y* f l: K7 o
[root@BAIYU_175 mnt]# mkdir proc sys dev etc var boot home
: c- ^7 m+ o/ u X6 ^' A5 e[root@BAIYU_175 mnt]# ll
# |$ V: T3 M: p( jtotal 56
4 y# N% h" c$ K. w& zdrwxr-xr-x 2 root root 4096 Jul 15 12:22 bin
( [$ }" C6 J) j3 ]drwxr-xr-x 2 root root 4096 Jul 15 12:25 boot- m9 J9 J& d6 x* {, l+ O! W
drwxr-xr-x 2 root root 4096 Jul 15 12:25 dev #一定需要
5 d* s5 V$ [3 M$ Q, v2 r! vdrwxr-xr-x 2 root root 4096 Jul 15 12:25 etc #一定需要
% z8 {0 g \1 Q4 S/ Odrwxr-xr-x 2 root root 4096 Jul 15 12:25 home
. B4 e& V2 }+ N! E: L/ plrwxrwxrwx 1 root root 11 Jul 15 12:22 linuxrc -> bin/busybox6 z' v8 \3 l$ E& m8 g* P! D
drwx------ 2 root root 16384 Jul 15 11:01 lost+found
$ H2 Q8 \$ A( c! K; J0 G3 ~) mdrwxr-xr-x 2 root root 4096 Jul 15 12:25 proc #一定需要6 |/ A9 M, S; ^7 Q( f
drwxr-xr-x 2 root root 4096 Jul 15 12:22 sbin: f; J9 ~6 S0 T5 R
drwxr-xr-x 2 root root 4096 Jul 15 12:25 sys #一定需要
& c" `9 c' \, Z. E, _" Ddrwxr-xr-x 4 root root 4096 Jul 15 12:22 usr3 o5 I6 `+ ?) ?3 b5 c
drwxr-xr-x 2 root root 4096 Jul 15 12:25 var
' A4 M% V: P' D" N. ? G* V) L r6 m( j+ V4 E2 I& y9 z
[root@BAIYU_175 mnt]# chroot /mnt /bin/sh( D: b" v- G$ }
/ # ls2 \' A0 H& l! ]3 G3 l
bin dev home lost+found sbin usr$ i! ~ j. `- ?- c+ J0 B
boot etc linuxrc proc sys var# K- l n1 q; b: s4 v% b
/ # ls boot/
% {; Y5 q0 ^, V" ?; C3 K/ # ls dev" B4 F0 H4 {+ E# {1 A
/ # exit #能正常使用说明这个根文件系统创建成功
G# S8 ?3 q! X1 f6 A4 T7 R9 Z% N5 v, \& `9 b I7 f1 Q
5 \, J2 n; Z. A. L7 W" Z+ V v! s4 r' C$ V
(3) 提供配置DomU配置文件
& ~" i! t) A2 q X: I5 Q! b, I" V
name = "busybox-001"
' g9 M; {- s% t. L! d* _0 [+ ^
+ y' D* e3 W9 Y$ _) _5 e7 ^6 }& ?kernel = "/boot/vmlinuz"
& ^9 m3 b) |8 G* f6 \- K
3 M; x: Y+ t& b- y% xramdisk = "/boot/initramfs.img"
" @8 [3 { z0 d$ m9 \+ m* [' ^; w3 H
9 P2 `& C& r) i! I! vextra = "selinux=0 init=/bin/sh"
0 e; x: U; E1 K k5 u. o$ ~; U
$ A1 Y) V& c3 xmemory = 256
$ P' g' e- K4 S8 i+ E. H8 G( s0 m0 J# |1 }
vcpus = 2
+ k" { X' u+ \; c5 [& s
% F+ c5 Z' E W7 f# Q) Idisk = [ '/p_w_picpaths/xen/busybox.img,raw,xvda,rw' ]' q' M6 j: ]! _ _. }
! B8 R' S9 s5 U ]( sroot = "/dev/xvda ro"5 P G( `+ `; Y; _5 \, x# g; Z
; R% Z% R( R5 Z3 H
[root@BAIYU_175 ~]# cd /boot& J, C9 l4 k$ Z: Y
[root@BAIYU_175 boot]# ll
+ K! M; Z# _; w, A4 Etotal 76456
/ W2 R/ j6 S; U5 u-rw-r--r--. 1 root root 2585052 Jul 24 2015 System.map-2.6.32-573.el6.x86_64
* {0 c! @% p B) w2 @. p/ z-rw-r--r-- 1 root root 3208657 May 27 20:18 System.map-3.18.34-20.el6.x86_64
: r' \+ @% j, q1 j* u- E( G-rw-r--r--. 1 root root 107134 Jul 24 2015 config-2.6.32-573.el6.x86_64
# h' D# l% C! _ h6 ]" Z) p-rw-r--r-- 1 root root 155205 May 27 20:18 config-3.18.34-20.el6.x86_64$ @" X/ f7 y) }* b0 A4 t( P
drwxr-xr-x. 3 root root 4096 Oct 24 2015 efi- |# W/ e# P, ?: r* Y3 I
drwxr-xr-x. 2 root root 4096 Jul 14 23:47 grub
5 N, ~( D8 d! t5 ?-rw-------. 1 root root 27609239 Oct 24 2015 initramfs-2.6.32-573.el6.x86_64.img- X) N. ]: k" Q& v" k4 z8 X, m
-rw------- 1 root root 29366666 Jul 14 18:07 initramfs-3.18.34-20.el6.x86_64.img9 x3 @( G5 o# D }# w
-rw------- 1 root root 4330884 Jan 2 2016 initrd-2.6.32-573.el6.x86_64kdump.img& l, c( L: H2 T& E9 c$ b
drwx------. 2 root root 16384 Oct 24 2015 lost+found/ }. E) y6 ~0 C F. f* {
-rw-r--r--. 1 root root 205998 Jul 24 2015 symvers-2.6.32-573.el6.x86_64.gz- T- P" g- J4 v3 }0 W0 S
-rw-r--r-- 1 root root 285315 May 27 20:18 symvers-3.18.34-20.el6.x86_64.gz( Q' w! D0 e) s ~: ^0 k" H$ B1 n
-rwxr-xr-x. 1 root root 4220560 Jul 24 2015 vmlinuz-2.6.32-573.el6.x86_64; a- b5 Z: D# v, Y k) j: W! Z% Q
-rwxr-xr-x 1 root root 5267744 May 27 20:18 vmlinuz-3.18.34-20.el6.x86_64+ ~- @( @/ ?! ?1 k; W- l- H
-rw-r--r-- 1 root root 893598 May 26 18:58 xen-4.6.1-11.el6.gz
4 E* m) r" M4 W# Q" q+ v* u5 Clrwxrwxrwx 1 root root 19 Jul 14 18:06 xen-4.6.gz -> xen-4.6.1-11.el6.gz0 d6 v- a2 f6 {5 i# \
lrwxrwxrwx 1 root root 19 Jul 14 18:06 xen.gz -> xen-4.6.1-11.el6.gz# x. p% w9 P% ~! |( a# W
[root@BAIYU_175 boot]# ln -sv vmlinuz-2.6.32-573.el6.x86_64 vmlinuz
- r& c) v8 T( e& ^, _`vmlinuz' -> `vmlinuz-2.6.32-573.el6.x86_64'. f5 c: h/ ]9 n; A* N. k! z
[root@BAIYU_175 boot]# ln -sv initramfs-2.6.32-573.el6.x86_64.img initramfs.img1 z3 n Z! E N: O7 G5 }$ o
`initramfs.img' -> `initramfs-2.6.32-573.el6.x86_64.img'
& O: S) S, K: i[root@BAIYU_175 boot]# ll- A2 y9 g h5 P7 p* x, U
total 76456
$ C' m0 n4 _7 G% i-rw-r--r--. 1 root root 2585052 Jul 24 2015 System.map-2.6.32-573.el6.x86_64
* ]# m6 ~1 c* j1 x, |-rw-r--r-- 1 root root 3208657 May 27 20:18 System.map-3.18.34-20.el6.x86_64
7 k O6 Z, g: {# l-rw-r--r--. 1 root root 107134 Jul 24 2015 config-2.6.32-573.el6.x86_64
& G5 b3 M5 M$ G. M! \( Y; z0 O, f$ W-rw-r--r-- 1 root root 155205 May 27 20:18 config-3.18.34-20.el6.x86_644 w- J2 {5 A+ Y/ p0 y( o
drwxr-xr-x. 3 root root 4096 Oct 24 2015 efi! m! J+ e; @2 E8 g1 o" }
drwxr-xr-x. 2 root root 4096 Jul 15 13:57 grub1 S a3 v. W& A2 K% J, d
-rw-------. 1 root root 27609239 Oct 24 2015 initramfs-2.6.32-573.el6.x86_64.img
* e9 B5 u v2 x+ E-rw------- 1 root root 29366666 Jul 14 18:07 initramfs-3.18.34-20.el6.x86_64.img
8 }; F$ d( u9 m" G( E; Ulrwxrwxrwx 1 root root 35 Jul 15 13:59 initramfs.img -> initramfs-2.6.32-573.el6.x86_64.img
! [4 p. p3 z( X0 v' E& j5 O' R2 w-rw------- 1 root root 4330884 Jan 2 2016 initrd-2.6.32-573.el6.x86_64kdump.img, C* s' n( E8 W
drwx------. 2 root root 16384 Oct 24 2015 lost+found
( ]- ~# J6 ]0 y: N$ Z* [-rw-r--r--. 1 root root 205998 Jul 24 2015 symvers-2.6.32-573.el6.x86_64.gz: u5 c! o' t/ J, k/ |8 I4 W% U
-rw-r--r-- 1 root root 285315 May 27 20:18 symvers-3.18.34-20.el6.x86_64.gz
2 ]. O" Y4 ^4 n2 j; C4 blrwxrwxrwx 1 root root 29 Jul 15 13:57 vmlinuz -> vmlinuz-2.6.32-573.el6.x86_647 U! m5 j3 R7 m" X0 _! C# E
-rwxr-xr-x. 1 root root 4220560 Jul 24 2015 vmlinuz-2.6.32-573.el6.x86_64
7 F' i( s8 i" y! O) Y- F4 a-rwxr-xr-x 1 root root 5267744 May 27 20:18 vmlinuz-3.18.34-20.el6.x86_64
) v" c+ O9 @9 I- }/ H-rw-r--r-- 1 root root 893598 May 26 18:58 xen-4.6.1-11.el6.gz
3 T/ k& b8 `9 o2 o7 x2 G/ F1 w0 W9 S( }lrwxrwxrwx 1 root root 19 Jul 14 18:06 xen-4.6.gz -> xen-4.6.1-11.el6.gz; n0 H7 C+ M- W$ B$ p/ B, l
lrwxrwxrwx 1 root root 19 Jul 14 18:06 xen.gz -> xen-4.6.1-11.el6.gz
3 Z" h, J% Z4 x% Q3 K3 \7 h: D0 ~! c
, t5 R- k0 o1 \$ }; c3 S0 n) @/ Y
$ i* G, `# Q: |3 z* |根据xen给定的pv示例配置文件修改:, x' K* _: }( P1 [. o
' x7 h3 |, W$ n& y$ g[root@BAIYU_175 boot]# cd /etc/xen/( K# }/ q/ z+ a$ @ z9 b4 v
[root@BAIYU_175 xen]# ls7 h: m4 c+ Q: b+ c) q
auto cpupool scripts xl.conf xlexample.hvm xlexample.pvlinux- f. `' t0 g" B5 c0 S
[root@BAIYU_175 xen]# cp xlexample.pvlinux busybox
, }5 s* X: c2 `' o7 _4 W+ X+ ?" o4 i% P' s: M& _6 K# l
[root@BAIYU_175 xen]# grep -v '^#\|^$' busybox #修改后的配置参数& S- X! j( r. \$ {) z4 P6 f! m
name = "anyfish-001"
, H: H. q5 ~% u, `kernel = "/boot/vmlinuz"
6 L: C% }5 `% j( ?1 U/ O: cramdisk = "/boot/initramfs.img"
! D- b, C& a3 W" B# _# rextra = "selinux=0 init=/bin/sh"
8 g6 R( l$ a- t7 Qmemory = 521- d) C3 V: O0 T, {; ~2 X, t6 T- @
vcpus = 2/ F k6 m! t4 [7 Z! t" x
vif = [ '' ]/ }) L; p% R0 |, H/ U+ z
disk = [ '/p_w_picpaths/xen/busybox.img,raw,xvda,rw' ]
1 u. W. k& Y' ?2 `0 g9 Y2 L1 troot = "/dev/xvda ro"( B( p8 E }0 |4 x
/ ^% V7 ~% i9 e: I% s. ] W4 H E
" v4 }& I% H" x; L- q R
(4) 启动实例
+ f+ S# ^9 Z$ u% ~6 a7 Z( g8 E
1 j# i( |: u" r& B& \xl [-v] create <DomU_Config_file> -n4 w6 e1 _2 E. p3 {
8 Q" N% |4 N! O: b3 f0 O( a
xl create <DomU_Config_file> -c
! k8 c- X2 X( j; {
7 N+ X4 J% F+ j- [% D[root@BAIYU_175 xen]# xl help create
( [# @$ r/ ~- C; ^8 W' jUsage: xl [-vfN] create <ConfigFile> [options] [vars]- _- b0 o9 P2 y' m* \5 }% \
#-v 表示详细信息,
# m I) A0 |# Z. c' {4 U& J3 M% T -f 指定xl命令的配置文件/ C5 N. I3 B- R2 f: b0 @0 O
ConfigFile 是DomU的配置文件; F2 |! i+ q' S2 b% A
Create a domain from config file <filename>.0 d0 i3 I9 q% @$ a$ a- F/ J
& Q) p* E9 P# i0 w1 f! V
Options:
. d$ D8 r$ M7 l$ ~; |
3 y" O+ `+ R# a, _& p/ l& l+ j-h Print this help.
: m L& m( ^9 m5 q& {-p Leave the domain paused after it is created.4 ^( `9 D" G7 H/ }, t5 `
-c Connect to the console after the domain is created.) y2 \$ X; m' D @* m Z# y
-f FILE, --defconfig=FILE& l' I+ s: V+ s# F" b) [
Use the given configuration file.
7 L1 L" H; g0 n8 g7 C$ B. B-q, --quiet Quiet.
4 k) ~+ h b7 v c6 x% z2 ]- C; F-n, --dryrun Dry run - prints the resulting configuration #并不真正创建虚拟机,只是空跑一遍,就是测试咯,. L0 t; Y7 y$ Q: X* t! x, q# O0 f/ @
(deprecated in favour of global -N option).
; ^5 Y: q, w1 z' P' V y3 |-d Enable debug messages.
" G$ f+ ` j6 @: a) [; X! X H1 R-F Run in foreground until death of the domain.* \2 S) D" {7 l. n
-e Do not wait in the background for the death of the domain.$ l1 R9 Z$ h5 e( R1 W) U2 o4 S
-V, --vncviewer Connect to the VNC display after the domain is created.
! Z6 M, a! j7 c9 C! f-A, --vncviewer-autopass0 f+ C. t+ K: B7 |/ e; b' q; h
Pass VNC password to viewer via stdin.
2 u& N1 V S8 a% e( w' s
; N2 z7 C, G: r) N8 _1 D[root@BAIYU_175 ~]# umount /mnt
3 v& _# o* M% D* E[root@BAIYU_175 xen]# xl -v create /etc/xen/busybox
9 v; w% c/ v+ y6 i/ q& h& k& z[root@BAIYU_175 xen]# xl list1 [& k; `0 h& d5 _( B- w# r# a& m2 z
Name ID Mem VCPUs State Time(s)/ ?. d: q. D5 W
Domain-0 0 1024 2 r----- 85.7$ U) K# n/ d' Y
anyfish-001 24 256 2 -b---- 1.44 K% V3 I0 c0 [ z1 i X
[root@BAIYU_175 xen]# xl console anyfish-001 #连接虚拟控制台2 \3 |2 D% V8 M* x3 |; ?" V" o
/ # ls' i- T! P! E x3 |4 \2 E
bin dev home lost+found sbin usr
6 V3 e) x! T! s; Vboot etc linuxrc proc sys var 按crtl + ]退回到Dom0,输入exit会删除掉anyfish-001这个虚拟机
0 ?) |% q3 o! h5 E/ ~" u2 Z- ]' }) @: F- c4 Z
$ ~! X% f2 V `( P8 ]4 {9 \
(5)添加网卡
! b5 g! c6 d7 d0 u9 e' U/ Z6 E
4 I, {8 R0 Z% x6 P% Z' c如何配置网络接口?4 H0 d, K6 \* E M& v+ G, d
! |" m! ?0 [7 `+ F- j) W+ E) ^vif = [ '<vifspec>', '<vifspec>', ... ]7 z9 u# m. ~! q+ N8 A; i3 I
2 {; g! w7 p% h4 `) z
vifspec: [<key>=<value>|<flag>,]/ T5 b! F7 k- G2 a6 ?" k8 g0 y
9 ~6 m; E: f) Q
常用的key:# E5 n! A4 F( B9 l+ Q
; A; B k; q+ X4 c% Tmac=:指定mac地址,要以“00:16:3e”开头;5 h- r9 f5 B) R8 h( g: G& _8 z
7 {/ ^! T. x/ Nbridge=<bridge>:指定此网络接口在Dom0被关联至哪个桥设备上;2 X* D0 i/ T% I: P3 o; d; |' o# m
8 D, |+ [% Q4 Z% Omodel=<MODEL>: ! Y' `) N/ G; ^# q$ P( v
# q, K' r3 s0 O; o vifname=: 接口名称,在Dom0中显示的名称;. N- Q5 X9 `! {' b/ X! S C9 L! O
7 Q# r8 G- k4 ^+ I( f% X. B2 kscript=:执行的脚本;! \' |/ ^6 z9 m
0 |5 W' n: y5 l) A2 S
ip=:指定ip地址,会注入到DomU中;! }& e1 L. d% p
5 ~* Q6 K7 q$ X3 B; erate=: 指明设备传输速率,通常为"#UNIT/s"格式
c: F* U# }' c; z# \) S7 p' H
/ F7 X, t# @* qUNIT: GB, MB, KB, B for bytes." T4 s6 j6 e( e" | d
: z2 W, F7 O* X- P N1 x Gb, Mb, Kb, b for bits.0 Z1 X8 T9 Z$ G, d5 M& T5 A
E" G; J; J7 s+ G) Z) b
1)创建xenbr0
' a7 L( F8 E% q9 O5 l7 Z- t+ F: a
$ X) d! M1 g$ ?) r7 ~( u7 \ @! h! O# brctl addbr br0
, g2 p7 v6 B6 O' L/ I! S1 P
& x9 d5 t% V" O# brctl stp br0 on
2 Y2 }+ [8 a- C$ i# J/ [2 J4 u6 g
# ifconfig eth0 0 up
' l; z" e8 [& v! B
" M7 E. m* G0 ?. E! a* X# brctl addif br0 eth0
0 i, ^# r; w. j" L" x) z, h, C' F# O5 X; M( G& h5 K4 c8 M) v4 \
# ifconfig br0 IP/NETMASK up
3 f) A' ?: e' Y* ?" U! s
; }) w- ]* e1 {. R* S; W# route add default gw GW1 e# O! G* D6 a; V" v: A+ q, O
- \/ |+ z# ]; d3 r[root@BAIYU_175 ~]# brctl show
9 a: g5 C) D( w' h$ j/ Sbridge name bridge id STP enabled interfaces3 V% \$ l" K3 T# u) I+ A
xenbr0 8000.000c29efbbd4 yes eth08 c" m; ^) p* u4 W. ?0 T8 `
#在这步后,系统死机了,可能3.18的内核bridge功能有bug,用3.7.4版本的内核没问题8 o# L5 u6 W% \9 o- h$ D
1.7 L8 p! B# o. }0 C2 n
2.4 f7 L0 M# X& h
3.1 t4 N" q2 w3 h% e0 r
4.( C8 H% |$ a* r, X0 K' B# A
2)在配置文件/etc/xen/busybox中添天网卡相关配置,并复制驱动程序到DomU中
! C, x+ ^. L2 B' l+ u' U: d
( g9 X2 f) l' \: F( ^. o7 |9 r8 Evif = [ 'bridge=xenbr0' ]0 s9 c! b6 y4 T% J) j- X: W+ Y
1.
! ]$ O9 Z$ m2 b4 _/ p[root@BAIYU_175 ~]# cd /lib/modules/2.6.32-573.el6.x86_64/kernel/drivers/ #驱动文件的路径
& ^3 w! s T4 L5 w1 g( G- |- p0 ?3 X; e[root@BAIYU_175 drivers]# ls
& R) S% r% S8 T6 F: g& ^acpi char gpio infiniband mfd platform serial vhost. K0 U! @# o8 _& q
ata cpufreq gpu input misc power ssb video
: t6 h, z+ @# \atm crypto hid isdn mmc powercap staging virtio
8 }. u& `) G+ l4 B3 E7 v) q \auxdisplay dca hv leds mtd pps target watchdog% y8 ?( |- G- ~% X
bcma dma hwmon md net ptp thermal xen
' u; w& \$ u# @0 E/ Jblock edac i2c media parport regulator uio) @0 e: A3 Q$ Q) r
bluetooth firewire idle memstick pci rtc usb
1 c% A1 T" N% o% s9 J4 @cdrom firmware ieee802154 message pcmcia scsi uwb
' z# f: P3 p, g[root@BAIYU_175 drivers]# cd net/
/ D# N3 y; M: e5 r+ N3 d[root@BAIYU_175 net]# ls
0 b4 e; G8 _0 |3c59x.ko cnic.ko ifb.ko netxen r6040.ko tg3.ko
8 t+ @4 s" I1 e" O, e8139cp.ko cxgb3 igb niu.ko r8169.ko tlan.ko' ]! N5 s6 H% J0 O
8139too.ko cxgb4 igbvf ns83820.ko s2io.ko tulip
. E* N; _% c8 A3 h+ \! w5 q# L1 Y3 \8390.ko cxgb4vf ipg.ko pch_gbe sc92031.ko tun.ko3 Z2 ^! h( s; k1 Q) B( G+ i+ t! f& [
acenic.ko dl2k.ko ixgb pcmcia sfc typhoon.ko5 E4 M- M# t5 d
amd8111e.ko dnet.ko ixgbe pcnet32.ko sis190.ko usb7 ^, J% j$ }+ Z: s4 u
atl1c dummy.ko ixgbevf phy sis900.ko veth.ko' U3 D( }/ Q& n/ d
atl1e e1000 jme.ko ppp_async.ko skge.ko via-rhine.ko) l1 ]8 Y N! R2 ?% \ e
atlx e1000e macvlan.ko ppp_deflate.ko sky2.ko via-velocity.ko$ J' t5 T9 S! i4 r4 s+ x
b44.ko e100.ko macvtap.ko ppp_generic.ko slhc.ko virtio_net.ko" ^7 ^. g2 r3 z
benet enic mdio.ko ppp_mppe.ko slip.ko vmxnet39 h) r/ _, { H9 O& v) N, C" q
bna epic100.ko mii.ko pppoe.ko smsc9420.ko vxge) N4 P" S3 U9 Y8 x9 z6 X9 q+ Y
bnx2.ko ethoc.ko mlx4 pppol2tp.ko starfire.ko vxlan.ko
* g$ h* a! c& G0 P) C; Wbnx2x fealnx.ko mlx5 pppox.ko sundance.ko wan- m8 n- M- p8 ^% K
bonding forcedeth.ko myri10ge ppp_synctty.ko sungem.ko wimax
, e6 W, ]! w" _$ j8 h/ Z `% gcan hyperv natsemi.ko qla3xxx.ko sungem_phy.ko wireless9 @; v$ T4 Z9 y4 C: {
cassini.ko i40e ne2k-pci.ko qlcnic sunhme.ko xen-netfront.ko
6 o2 [ p' U7 d/ o, Vchelsio i40evf netconsole.ko qlge tehuti.ko
, C5 A; X* z9 T9 O1 Y; a) I[root@BAIYU_175 net]# modinfo xen-netfront.ko
}3 K6 d4 B4 A" Hfilename: xen-netfront.ko; s( v$ A+ N) E; U3 ~ m
alias: xennet; h2 E7 n# w/ E! i+ k* `
alias: xen:vif
' z9 }" N$ G0 K1 llicense: GPL' T. b; K) C: y8 n+ Y$ \! P- D
description: Xen virtual network device frontend/ \3 f- o8 n; W- x# E; u) O
srcversion: 5C6FC78BC365D9AF8135201
/ S( _: E5 o; R0 kdepends: #查看此模块依赖的模块,如果有要一起复制过去9 `5 s/ q3 S4 R% r6 Z; L
vermagic: 2.6.32-573.el6.x86_64 SMP mod_unload modversions
( e" p d9 l, S* v- V# {) C[root@BAIYU_175 net]# cp xen-netfront.ko /mnt/l
, @! R8 @: m) ilinuxrc lost+found/
; F+ ~* Z* j/ o5 C# ~[root@BAIYU_175 net]# cp xen-netfront.ko /mnt/l& [. ] q7 H- j' r2 j
linuxrc lost+found/ 7 f' J, ~5 `9 X0 r' D! A4 E7 w
[root@BAIYU_175 net]# mkdir -pv /mnt/lib/modules* H* q, K5 x0 d, S8 S2 g' H
mkdir: 已创建目录 "/mnt/lib"
% t7 Y9 n! ` q' K$ Umkdir: 已创建目录 "/mnt/lib/modules"( T, n5 _5 N3 F+ W& o
[root@BAIYU_175 net]# cp xen-netfront.ko /mnt/lib/modules
/ G5 R' y2 ?. K0 G( p1 amkdir: 已创建目录 "/mnt/lib/modules"
* d* G. i& A& S: ~ d% L& M[root@BAIYU_175 net]# cp xen-netfront.ko /mnt/lib/modules
8 b" L' u- P: Q8 u[root@BAIYU_175 net]# umount /mnt2 E# r9 C& V; h
[root@BAIYU_175 net]# xl create /etc/xen/busybox -c
% ~& j h# O0 @ \/ P& |+ D/ # insmod /lib/modules/xen-netfront.ko #手动装载驱动程序
" `$ ~+ I" t6 X) hInitialising Xen virtual ethernet driver.2 I h( N& r7 E
/ # ifconfig
# g/ q/ t" j, V3 F M8 T' x {5 m) [/ # ifconfig -a
/ i8 s% Z8 h% M- F) A9 k4 I& @eth0 Link encap:Ethernet HWaddr 00:16:3E:50:D3:20
# K: T2 _; p; _ BROADCAST MULTICAST MTU:1500 Metric:1
3 ]# D/ z0 w/ Q; v( L RX packets:0 errors:0 dropped:0 overruns:0 frame:0+ B3 X& F P2 ?5 ^" G- e
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0" p' m. j q9 @ N5 Y4 E
collisions:0 txqueuelen:1000
- K& D/ T6 {, s( s/ @ RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
0 F" _) S6 R9 v' V. | Interrupt:18
$ z$ x% k2 P4 Q" b9 W; ^
( Y$ ~7 x s" Z+ s- U: |lo Link encap:Local Loopback 4 F5 A u: A5 x. [, d' q
LOOPBACK MTU:65536 Metric:1
8 v2 S" f9 s: d ~ G2 ~! R RX packets:0 errors:0 dropped:0 overruns:0 frame:0. [0 \) R2 r, Y
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
e; z9 p5 {7 K' _' c collisions:0 txqueuelen:0
2 j; M; p7 @* t& P z3 w7 E; V# [ RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
* ~9 }- ? t& w) e5 ^8 @+ D$ H% k' F; X
$ u) Z; Q; x- K: r$ q+ e! X* _8 e
此时在Dom0上也可以看到虚拟机网卡的后半段8 B0 n- t0 W' g6 f
% L6 @- U+ r0 Z' T
[root@BAIYU_175 ~]# xl list
% H9 Z( n- S6 y7 \' dName ID Mem VCPUs State Time(s)
, u6 U, u& r' S3 |1 j2 PDomain-0 0 1024 2 r----- 78.6
. S! d* F, y) c' J0 Y; wanyfish-001 9 256 2 -b---- 3.0' g7 P3 S I3 D9 q7 M% G
[root@BAIYU_175 ~]# brctl show7 L- q1 Q7 b* N; L8 a5 A) d* w
bridge name bridge id STP enabled interfaces
1 R, `& D$ B, l( }xenbr0 8000.000c29efbbd4 yes eth0" H A& O4 A$ {6 k( n
vif9.0# E- F/ E) m; P& R9 A
[root@BAIYU_175 ~]# ifconfig
3 t- S! _0 H& @: l6 ]eth0 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:D4
; A- d7 X# c& e; S" F inet6 addr: fe80::20c:29ff:feef:bbd4/64 Scope:Link; V, a- I) } p* o! k0 h
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
% l& u. w) V z4 U RX packets:20797 errors:0 dropped:0 overruns:0 frame:0
: y5 e* k0 f f TX packets:563 errors:0 dropped:0 overruns:0 carrier:0) h4 t) H* Z5 D+ L
collisions:0 txqueuelen:1000 ) y% D& m3 b3 a3 n% R, f `# ?2 z
RX bytes:1332243 (1.2 MiB) TX bytes:62352 (60.8 KiB)
% T5 B( v' `- T- C6 Y" Y+ v6 s0 o$ q0 K5 M% {3 O: p
eth1 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:DE
0 u, t: D }" ], j8 X2 I2 m1 @ inet addr:172.16.11.199 Bcast:172.16.11.255 Mask:255.255.255.0
* l3 ?) o! d9 Y" k/ _9 `" y inet6 addr: fe80::20c:29ff:feef:bbde/64 Scope:Link
: w5 ^0 R; s7 @1 a UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
4 g5 L7 r! ~3 J* r J RX packets:26507 errors:0 dropped:0 overruns:0 frame:0
; j5 U( \( {+ T5 g: P TX packets:3142 errors:0 dropped:0 overruns:0 carrier:0
* O& C( O, _) _% m' j collisions:0 txqueuelen:1000 * N& y) C8 B L. \& Q' F
RX bytes:2899642 (2.7 MiB) TX bytes:457705 (446.9 KiB)
( L7 v# Q5 ^6 ~8 m6 S5 e
3 \ @( N. f2 ^$ wlo Link encap:Local Loopback * W) L8 v8 s, T; V
inet addr:127.0.0.1 Mask:255.0.0.0" y$ h" f& J' N
inet6 addr: ::1/128 Scope:Host2 e Z0 \% m; p" k
UP LOOPBACK RUNNING MTU:65536 Metric:1
- C8 S/ v8 n. {) _ RX packets:0 errors:0 dropped:0 overruns:0 frame:0
/ r/ x* P% r# R! u/ u TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
2 V x+ ?8 o5 p; q1 ] collisions:0 txqueuelen:0 3 t# P8 o; O7 c+ \' f( L1 Y- e
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
$ x# f# ]& T- X- n* c% T! R) n- m) M" T
vif9.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF #9是虚拟机的ID号,.0表示第一块网卡, G2 E8 w7 H c2 |6 u
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
9 y) c7 l) o; _8 u% b& Z$ Z% z8 v UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
9 V# l% a- n$ Q! [$ A RX packets:0 errors:0 dropped:0 overruns:0 frame:03 s5 Z. u3 f/ b6 L. ~0 V8 k) q
TX packets:46 errors:0 dropped:0 overruns:0 carrier:04 X% s/ B! n8 A
collisions:0 txqueuelen:32
* D' b( P, H$ R2 A7 q RX bytes:0 (0.0 b) TX bytes:2548 (2.4 KiB)" z) h$ S, T; X" q
; x! O4 o. n& b' S v' axenbr0 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:D4 ( h7 I$ e/ s1 o# i, N
inet addr:192.168.100.175 Bcast:192.168.100.255 Mask:255.255.255.0
# t; J: M, D+ s) a; Z' p inet6 addr: fe80::20c:29ff:feef:bbd4/64 Scope:Link8 Q( N5 u S( R* ?+ q) j
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
2 ?6 t, Y& S+ { RX packets:727 errors:0 dropped:0 overruns:0 frame:02 A* F* `# C/ @, `- t$ ]
TX packets:292 errors:0 dropped:0 overruns:0 carrier:0. ?7 y- [2 A6 z! H
collisions:0 txqueuelen:0 6 z6 w2 n' V4 V0 Q4 i( c5 Q' v
RX bytes:55541 (54.2 KiB) TX bytes:18796 (18.3 KiB)0 h0 J5 R( u) e5 g& n
: C% h; B5 {2 G# P$ u0 i8 Y, \#DomU上,/ Y4 e- n' N! |$ v: S) C
/ # ping 192.168.100.180
& {! T& q+ I+ B1 r6 w; x- |1 aPING 192.168.100.180 (192.168.100.180): 56 data bytes
, c* o7 T! l/ G1 _, p4 Pping: sendto: Network is unreachable
% U9 J& B: E, @" G H/ # ifconfig eth0 192.168.100.181
2 ^4 F q" {7 w; P7 o! V/ # ping 192.168.100.180- [7 @$ M4 Y7 |* I; f) H
PING 192.168.100.180 (192.168.100.180): 56 data bytes r4 M, y- n0 P& n/ k" G/ i8 Z) n, X
64 bytes from 192.168.100.180: seq=0 ttl=64 time=16.589 ms
7 ^; r, Y% ~4 G+ s$ c( W64 bytes from 192.168.100.180: seq=1 ttl=64 time=0.912 ms$ [. O& A g9 b* J/ w
% e4 Z) B) V# w7 `, E( J3 i8 X
, ?3 A+ P7 R# c _1 C上面这种方式创建的网卡是桥接,那我们怎么创建一个虚拟通道呢(相当于VMware Workstation网卡设置中的VMnet1,...VMnet19)?. [# U, S+ V" ]9 X3 V% B( K+ {
: s- o/ L- A$ x7 k. E6 O* q[root@BAIYU_175 ~]# xl list
0 I# \% \6 O0 o9 OName ID Mem VCPUs State Time(s)
3 O& L' K4 |: p4 j1 F# \0 DDomain-0 0 1024 2 r----- 100.7
' R+ s! J! d. C5 x1 k& b" U: Zanyfish-001 9 256 2 -b---- 12.5) R. \. Q* P. M. z) _% N
[root@BAIYU_175 ~]# xl destroy anyfish-001 #立即终止域,相当于拔电源
: L- o i* t! K0 }0 K[root@BAIYU_175 ~]# xl list K$ e8 L! `5 w* R1 n
Name ID Mem VCPUs State Time(s)
. [+ k6 ~8 Q) O- K. zDomain-0 0 1024 2 r----- 101.46 x& d% c; o( F. o8 b1 W D$ T' y1 x
[root@BAIYU_175 ~]# cp /p_w_picpaths/xen/busybox.img /p_w_picpaths/xen/busybox2.img
8 z: p1 B( r' o4 m- E2 Q[root@BAIYU_175 ~]# ls /etc/xen/& X+ x7 Q7 _ f7 {
auto busybox.orig scripts vm2.orig xlexample.hvm% z9 y9 n- `! c
busybox cpupool vm2 xl.conf xlexample.pvlinux
0 R n& Z5 w/ D8 _[root@BAIYU_175 ~]# brctl add xenbr12 h3 f; }. {. Z8 B+ Q7 s# |
[root@BAIYU_175 ~]# ifconfig xenbr1 up, J C3 G% G, t, q8 f- l. h
[root@BAIYU_175 ~]# ifconfig
; |# i7 W& k) L0 R d3 }* I, Q- Keth0 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:D4
( { y+ e( n, S' u9 B; {+ c inet6 addr: fe80::20c:29ff:feef:bbd4/64 Scope:Link* g% }) k' ~9 H+ h Y1 ?) \
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
( p/ e+ T* _! L- C RX packets:30305 errors:0 dropped:0 overruns:0 frame:0; T/ e: ~4 j4 R3 u
TX packets:4219 errors:0 dropped:0 overruns:0 carrier:08 F; ^2 E* L P/ m2 ?" ?
collisions:0 txqueuelen:1000
& M( T6 R( l+ x9 H7 R7 J+ G RX bytes:2008392 (1.9 MiB) TX bytes:387507 (378.4 KiB)5 K" l) m* k0 G& n& v7 M9 @. `
, Z% N( D7 Z$ s ]
eth1 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:DE * S) a; |9 S% c
inet addr:172.16.11.199 Bcast:172.16.11.255 Mask:255.255.255.0
8 e- T# D$ k) W inet6 addr: fe80::20c:29ff:feef:bbde/64 Scope:Link
( F, k2 b3 D/ }: O UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
& L4 R3 L' _( @( K8 v( S RX packets:34311 errors:0 dropped:0 overruns:0 frame:00 R( T' ]5 l* C2 [! t, Q
TX packets:3552 errors:0 dropped:0 overruns:0 carrier:0& X8 }1 g$ C4 S% C4 Q# r
collisions:0 txqueuelen:1000 ! R% K5 d3 A( O2 P# v" U8 g
RX bytes:3744076 (3.5 MiB) TX bytes:501793 (490.0 KiB)
1 T' \6 x' F; L0 a
: e/ M% t: Y) B) M$ X5 slo Link encap:Local Loopback
" a* v: i# Q: v; N# ~+ |4 S7 b inet addr:127.0.0.1 Mask:255.0.0.0
( k$ x3 O: M1 v3 H1 j inet6 addr: ::1/128 Scope:Host" Y' w# _* L% F1 P% t
UP LOOPBACK RUNNING MTU:65536 Metric:1
% n/ Q% y* V- K$ L1 s- t RX packets:0 errors:0 dropped:0 overruns:0 frame:0
3 ]' z' C: h% ]/ `" g' C TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
6 p% T+ E# c: o% ]& p: E collisions:0 txqueuelen:0
" i' F1 j3 f, [ RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)8 @( V& X. N9 E5 w/ ]
5 a6 o" f. K; y2 g2 w9 l5 D$ H' j) W( a
xenbr0 Link encap:Ethernet HWaddr 00:0C:29:EF:BB:D4
% _& A7 C, _; z4 ~ T' p9 o inet addr:192.168.100.175 Bcast:192.168.100.255 Mask:255.255.255.0. |9 S1 d1 K7 l# Y6 R. d# `
inet6 addr: fe80::20c:29ff:feef:bbd4/64 Scope:Link# E) p9 {+ e: B% D
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 N4 F6 E7 O9 Q/ j! {
RX packets:2656 errors:0 dropped:0 overruns:0 frame:08 |5 h# `! E8 |- S. R; |4 ?9 r Z
TX packets:994 errors:0 dropped:0 overruns:0 carrier:05 q5 w: s5 D- [; ^: u6 |: P$ U- E) Z
collisions:0 txqueuelen:0 8 Z/ L& o* T% k+ ]- Y
RX bytes:163430 (159.5 KiB) TX bytes:111633 (109.0 KiB)
; p& G$ ~6 g: H% ~& O! c. N1 z
2 Q8 S/ x$ ^5 B/ s& a# I! _7 d, [xenbr1 Link encap:Ethernet HWaddr 42:5B:43:45:2B:D2
* o+ M" x- e" g+ B, F! p, j. I K inet6 addr: fe80::405b:43ff:fe45:2bd2/64 Scope:Link
% ~7 d! t1 b% y% \ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
6 t4 B! _1 J( R# o" N* a RX packets:0 errors:0 dropped:0 overruns:0 frame:0. c' @7 `8 g0 g; f1 U, o* ?
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0! M) J9 E6 M$ k: }
collisions:0 txqueuelen:0
: M* e/ J, x4 R* Y. k RX bytes:0 (0.0 b) TX bytes:168 (168.0 b)
$ B1 W( a4 P% H: h9 j
7 t( ?" p4 @ b& x[root@BAIYU_175 ~]# cp /etc/xen/busybox /etc/xen/busybox2" C( A) U7 V3 P& O" A
[root@BAIYU_175 xen]# vi busybox3 z* F% W8 c( L% a" i
[root@BAIYU_175 xen]# grep -v '^#\|^$' busybox* g T7 Y; l/ M4 K2 C2 u
name = "anyfish-001"
% [7 w/ J1 P/ Q+ x( ?) Ukernel = "/boot/vmlinuz", k% X& a6 Q# l/ j
ramdisk = "/boot/initramfs.img"
' s" V4 A9 A$ L; l& T4 iextra = "selinux=0 init=/bin/sh"
2 @% Z( q* g4 t2 `! Bmemory = 256
% j8 T- Y0 n/ F8 fvcpus = 2 X% V. _5 S9 X, X5 E$ M
vif = [ 'bridge=xenbr1' ]" e4 M: S" M' \& @0 z
disk = [ '/p_w_picpaths/xen/busybox.img,raw,xvda,rw' ]
( r0 ~2 b' \( g3 Z$ ~: [8 m2 Wroot = "/dev/xvda ro") _- Z W- @2 X8 s
[root@BAIYU_175 xen]# vi busybox2: A. p* M: |/ y6 @8 M$ ^
[root@BAIYU_175 xen]# grep -v '^#\|^$' busybox2
7 a* U' _# z5 I( L# B5 X- T( j4 T0 uname = "anyfish-002"( X8 L$ e, S+ A0 r
kernel = "/boot/vmlinuz" l# O( ~! {4 C: E! X! |2 n5 f
ramdisk = "/boot/initramfs.img"% R; @, W n5 B* D! Q2 h# u" c3 b
extra = "selinux=0 init=/bin/sh"
( U; u0 N6 e1 k) z# Qmemory = 256; s. W/ ^: K9 s/ S( o& c& V8 \
vcpus = 2# B$ r! W4 z; @" z
vif = [ 'bridge=xenbr1' ]
. E" r, Z0 e. r! @* _( A) q, \disk = [ '/p_w_picpaths/xen/busybox2.img,raw,xvda,rw' ]
1 r$ c1 X& [3 i+ troot = "/dev/xvda ro"
+ F5 e/ G( q. I" {[root@BAIYU_175 xen]# xl create /etc/xen/busybox4 e b& G0 h( u* m( k h' d. ^ k6 ~
Parsing config from /etc/xen/busybox% F4 z3 t- T: S: }$ G. b) R
[root@BAIYU_175 xen]# xl create /etc/xen/busybox24 O. Z- }) W" p) I4 E. J# t
Parsing config from /etc/xen/busybox2
6 t8 ~3 E6 b$ a, g* w[root@BAIYU_175 xen]# xl list
& [7 p/ [' D+ ]* C6 w4 [* JName ID Mem VCPUs State Time(s)
0 n$ K! Y! x$ l( K3 I- X' QDomain-0 0 1024 2 r----- 112.8
8 {7 p7 n. D3 U$ j; Z" ?anyfish-001 10 256 2 -b---- 1.2
: }: k( m! i( T+ E7 @/ h2 ~anyfish-002 12 256 2 -b---- 1.2 F; \4 j+ V# W. t* r
- E+ Y% ^: y* l3 ~[root@BAIYU_175 xen]# xl console anyfish-0013 F$ z# b8 m: L5 @' F( q7 a
# ifconfig -a
; f$ b& i$ G: _! u. m1 Wlo Link encap:Local Loopback a8 J+ ^- O, {2 J
LOOPBACK MTU:65536 Metric:1& w: p* \9 A) W. h. X' o: U6 z" B
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
8 ]. d, h8 p# i: ] TX packets:0 errors:0 dropped:0 overruns:0 carrier:0+ m6 q" |$ U6 U5 c G/ p
collisions:0 txqueuelen:0
8 k! _, c+ d. y2 ]7 T4 d0 } RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
6 E7 N9 c' x% C: @4 ?6 g, Z9 f1 z; T5 v/ K/ H; ^' w
/ # insmod /lib/modules/xen-netfront.ko : J! T$ J' v( P6 T- b! y! M8 N
Initialising Xen virtual ethernet driver.) f ^( C/ [* w% }
/ # ifconfig -a
. @" Y) Y, n# |' H8 S0 ieth0 Link encap:Ethernet HWaddr 00:16:3E:7C:8B:F0
0 @" ~0 ~& T# | BROADCAST MULTICAST MTU:1500 Metric:1% O& g$ Z2 v! x, d8 b1 _& G
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
' D, U# d; B" V8 P/ L' ? TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 H; D2 K4 V) F- g9 S
collisions:0 txqueuelen:1000
# P8 S' v0 a. J8 d( ^" o. W RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
# Q0 d, H) a* o6 r( R* ? { Interrupt:18 ; ?, T2 f& Q# F0 Z# L: b
+ e9 {! T# `3 @( Blo Link encap:Local Loopback
' J' R% @9 H- N LOOPBACK MTU:65536 Metric:1
2 p* x8 z6 A8 F9 F/ o, P RX packets:0 errors:0 dropped:0 overruns:0 frame:0
7 U0 [8 U* t& c, i TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
/ l; u% E# u: L$ @! z/ c2 C collisions:0 txqueuelen:0
7 E8 L/ O7 a1 T" Y3 |# X RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
) ?! r, x' W1 T# j& g
) }4 t( [) J- b4 R/ V/ # ifconfig eth0 192.168.100.181 up! Y O9 ^: L" s! d) j& `* S
/ # ifconfig$ f8 S. R" D4 k
eth0 Link encap:Ethernet HWaddr 00:16:3E:7C:8B:F0 " }6 b- Z8 J$ T& ?- I
inet addr:192.168.100.181 Bcast:192.168.100.255 Mask:255.255.255.02 ]5 w1 L; L7 y$ B6 w( F& \2 z
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
) [4 c- K( c$ ?, o8 {4 r9 S RX packets:6 errors:0 dropped:0 overruns:0 frame:0
% Q5 q$ \( u0 ~0 R( E$ S: y+ W TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
! k9 P7 W" e- r' f+ D collisions:0 txqueuelen:1000
3 n0 F) V8 @& F RX bytes:384 (384.0 B) TX bytes:0 (0.0 B)
" K! Y l" w& z9 [; L& [! i$ k m- c Interrupt:18
5 d8 p3 |3 S! P& h) z3 A/ P3 M9 v, e
/ # ifconfig -a
' y1 v4 |0 a% v! Y b2 e( A+ oeth0 Link encap:Ethernet HWaddr 00:16:3E:7C:8B:F0
0 e |' ^4 T# R# C- g* O' m inet addr:192.168.100.181 Bcast:192.168.100.255 Mask:255.255.255.0. B, m, Y$ z- B3 B8 S7 [( g
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:18 h+ l5 q0 j" t* i5 m/ Y0 g1 y
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
: d. X7 f" l+ P& V% Q5 |* P- ? TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
( Y9 \5 t# }- e) J collisions:0 txqueuelen:1000 % X1 O" \) l- }: s& b5 L
RX bytes:384 (384.0 B) TX bytes:0 (0.0 B)
' b& w- I8 y& h' u$ w! p* U+ I; c; y$ A9 E Interrupt:18 4 L; Y/ F, V3 K4 H( e+ t
, E- O. o2 ?0 F3 e7 \( J( ?
lo Link encap:Local Loopback 5 ^/ _. p3 S$ G e y2 u% p9 |
LOOPBACK MTU:65536 Metric:13 A) Y( |# }* u9 [8 m
RX packets:0 errors:0 dropped:0 overruns:0 frame:0- M1 a- z" f6 T& i( J8 K7 K' S- Y
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0) c! @$ S7 z t1 H$ c
collisions:0 txqueuelen:0
% d. V' h6 L+ A5 N RX bytes:0 (0.0 B) TX bytes:0 (0.0 B): _1 x* |$ E8 y; D
5 N; s G8 P# o6 k$ D7 L/ # ifconfig
: w) ?; b. ?# I# q0 J Neth0 Link encap:Ethernet HWaddr 00:16:3E:7C:8B:F0 ( w5 P/ I3 ]% P& L+ m0 Z
inet addr:192.168.100.181 Bcast:192.168.100.255 Mask:255.255.255.0
5 [! t. _2 x a9 E* x UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1! i6 Z. Y' c% ^
RX packets:6 errors:0 dropped:0 overruns:0 frame:05 t& ^% q; _' ?5 R2 [
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
{2 U; e# w! v' C' b collisions:0 txqueuelen:1000 2 y% {$ }8 r! N5 l
RX bytes:384 (384.0 B) TX bytes:0 (0.0 B)
9 q; e0 g8 R% f6 G4 F! K) T Interrupt:18 - ^7 {! V3 N" R" w
- ]; I, h2 v* u7 l; u
[root@BAIYU_175 ~]# xl console anyfish-002 / x0 ^7 w: Q" A5 v9 Z( c
/ # insmod /lib/modules/xen-netfront.ko
" x' N( G+ }, S2 | }Initialising Xen virtual ethernet driver.% P& p" x! B6 l6 O* F7 f" s, y
/ # ifcofnig eth0 192.168.100.182, @' c0 ^) G+ E3 c9 m# l
/bin/sh: ifcofnig: not found
+ J# H: o* f7 N$ V1 E/ # ifconfig eth0 192.168.100.182 up
) a( ?! }' v- v5 Q: ^/ # ping 192.168.100.181( {+ m& U, `( H0 l; w
PING 192.168.100.181 (192.168.100.181): 56 data bytes Z0 J/ t; ?- e7 Z% n, c! W
64 bytes from 192.168.100.181: seq=0 ttl=64 time=3.144 ms5 i. W, H2 w4 {, k2 i( h
64 bytes from 192.168.100.181: seq=1 ttl=64 time=0.567 ms
& \: V7 F+ N) b1 T/ ]7 [2 {: Q' B8 j5 l \& c
此时虚拟通道创建完成,虚拟机之间可以互相通信,而虚拟机不能和物理机及外界通信4 B+ C5 J9 I4 ^0 s l0 m
- c( `4 x7 ~' j! z4 b: X6 A8 u- X
( n: o4 ~/ i; c5 M: U
|
|