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