|
|
楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)
& t- }5 N: N/ A4 y% N4 E# A {1、v2v迁移$ K V; F" u; J
#虚拟化迁移至虚拟化环境9 l1 Q% u- A, J& L# D/ {% n
#p2v迁移,是指物理机器迁移至虚拟化环境 a8 Q! K' S# M
#安装v2v迁移工具:yum install -y virt-v2v
4 F7 v' |+ ]( o3 }6 b u0 q#
+ u6 b2 j! Q9 @/ C: k0 B2、KVM-KVM的v2v迁移# m, _+ y P% S% D, Q0 Q& F% ]
#KVM是采用Centos7,vm是采用oel6操作系统,始终报错
" w! B* J6 a& l) p5 Z$ D; j, X错误信息:- K& C/ a1 m$ p# @, Z6 y8 N
qemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
# V; Q0 E0 S4 r1 ?virt-v2v: error: qemu-img command failed, see earlier errors
6 e6 l7 b: _6 f; p) d2 w3 w! i/ J- c; EIf reporting bugs, run virt-v2v with debugging enabled and include the
9 N5 t0 s! x6 p5 Q x& M$ B#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool6 A1 D* h( `. g, v
#node72检查% m5 _2 ]+ `7 d+ h
[root@node72 ~]# virsh pool-list9 O1 s7 U3 I, q2 {8 a
名称 状态 自动开始# m/ D& t- H# i7 Q9 Q
-------------------------------------------
( A- ~* B# ? k" w8 ~& I. x! I iso 活动 是 5 O& P3 R$ h: [; o7 [# D& s! q
oel1 活动 是
6 h/ X- F7 y& \4 y* D( R vmfspool 活动 是
8 l; P! U8 t. G" F" t' P& H. y3 ^. g4 @# o- O
[root@node72 ~]# 2 O5 r. q. v6 k# ]
#关闭需要迁移的虚拟机
1 N. R' E" C' t! p& O[root@node72 ~]# virsh list --all8 n! f) f6 ~' W
Id 名称 状态! [* w* }- |1 Q
----------------------------------------------------, L5 @9 Y' @9 c9 ]4 N/ M7 v$ X
7 oel4 running
" l2 S1 m( R0 I: R1 p0 z% |5 F - oel5 关闭- {* W' ?7 x4 T+ l7 M, i( `/ [
[root@node72 ~]# virsh shutdown oel4 g7 _! O/ i+ w, F
域 oel4 被关闭
, i0 f' A9 }( W) r; ~+ w. X# q# k[root@node72 ~]#$ [! o. q/ X& B9 @
#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例
, Z1 I0 Y/ n/ a- L[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4 u7 `5 I9 ]$ n4 j5 r( U
[ 0.0] Opening the source -i libvirt oel42 T- \) p7 `/ S. y8 A- o6 d
[ 0.0] Creating an overlay to protect the source from being modified
0 U( Q8 V1 M5 ~# j7 B[ 0.0] Opening the overlay- u9 ^) D- ~- |! z
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool
& p0 s" m/ y6 {: aroot@192.168.2.110's password: ! ~* v2 U3 S- O+ r8 `
root@192.168.2.110's password:
/ y% Q% @. i5 a9 r8 W& c, K! l4 troot@192.168.2.110's password:
7 m( a0 W" n+ n; J$ I[ 17.0] Inspecting the overlay
' G2 p# ?$ v1 B( |; I. t- C- A! s[ 24.0] Checking for sufficient free disk space in the guest
+ \# G8 `! V6 n[ 24.0] Estimating space required on target for each disk
1 z6 Q7 }; N" O* @[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM$ J! q( C+ `+ X/ V+ Q$ G
virt-v2v: This guest has virtio drivers installed.! j' w# K( S v1 d' m9 h1 u
[ 69.0] Mapping filesystem data to avoid copying unused and blank areas' T: g$ a' P' I; M
[ 69.0] Closing the overlay0 G- d- b7 Q9 b
[ 70.0] Checking if the guest needs BIOS or UEFI to boot
5 i1 C- A" X! C: f[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)
1 B+ p, e6 Y' [& r' Q (100.00/100%)
8 x6 E8 R7 y8 e3 I[ 82.0] Creating output metadata P# R2 F# m# T7 g7 t% @* d" M
root@192.168.2.110's password:
- W# F! G, ]& _9 H1 q池 vmfspool 被刷新
) M) b/ _6 w g* _" Broot@192.168.2.110's password: * Z. A; ~$ j4 t, }+ q/ _' q
定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)
3 K6 p: z4 G9 k; Q[ 107.0] Finishing off
2 S" n8 W6 A! c0 s& j2 F' y[root@node72 ~]#0 B" g& l1 T: a) Z* H/ L2 v; B1 Z$ o
#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)- J! Z1 y6 i8 d& s
#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口," p0 Z; f; ~0 }$ l; c! T1 U
[root@node72 ~]# virsh list --all
4 U0 d" b7 {; |$ U( v/ B p; g. | Id 名称 状态
0 V2 ~+ h4 r: c2 M# J) X+ }; @----------------------------------------------------
6 k! h. e2 X* h. _( ` - centos4 关闭4 X$ ^( T; ]4 A* E# R4 ]
- oel4 关闭
4 {! w+ r0 s9 o q; d. k - oel5 关闭
/ V9 C; j2 Q, t5 n[root@node72 ~]#) S% _: Q; r; l4 }1 U X
3、KVM之间的v2v迁移
7 s( n: F" N! x" F* u6 v0 u" u+ x2 `- I) E+ C& A/ g" w
#检查node71的迁移环境; a! a; E$ z) k: |
[root@node71 ~]# virsh pool-list9 m. z, o, b5 e* s& G5 d
名称 状态 自动开始" p$ @. e' |$ I8 ?, D- r" L3 c
-------------------------------------------: X3 M. P, R1 _; A- t5 U; ?
iso 活动 是
8 D9 X: s" t' c/ L! s vmfspool 活动 是 ( I9 D+ a4 P. R9 W( M7 g( X
) W# t, R; p6 T7 Y: t
[root@node71 ~]# : {) P. X4 d# J
#测试迁移,从node72迁移出来
( g( b+ X3 k5 ^3 v: w: m: T: B[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4
4 n8 [% z9 V+ U# t* K[ 0.0] Opening the source -i libvirt oel4
" _3 v. ?, `2 m4 A* v0 ][ 0.0] Creating an overlay to protect the source from being modified
. O4 u7 Q8 p/ Z" j$ N0 S$ m2 f- m% W[ 0.0] Opening the overlay( T: `( m( i& T x+ Y; t
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool
; @; T r. T6 |" R J% A% yroot@192.168.2.111's password: 1 W2 b9 D5 B6 x6 i! g2 A9 d
root@192.168.2.111's password:
/ C+ h8 n* w5 j) ~, Yroot@192.168.2.111's password:
y, q6 W& K5 P' P3 D8 D[ 18.0] Inspecting the overlay' @2 `' N' Y' ~4 U/ V) z- {( P6 I' m* m
[ 24.0] Checking for sufficient free disk space in the guest
# ~6 Z( S+ A% {* T+ C! s G[ 24.0] Estimating space required on target for each disk
5 m' X+ `4 E4 U9 R4 F0 y& }[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM1 L' z/ I2 {! j" r7 b: _/ [# I
virt-v2v: This guest has virtio drivers installed.% W. \* K8 b) \; Z
[ 68.0] Mapping filesystem data to avoid copying unused and blank areas
9 V& z$ }5 m. }8 ]8 b[ 69.0] Closing the overlay7 ?/ e9 r& C+ `& E7 q/ }) V
[ 69.0] Checking if the guest needs BIOS or UEFI to boot
2 C7 T7 L0 N* p7 n[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2). k' G% G# j' r$ J6 p
(100.00/100%)! a% \. w3 z3 }8 ?5 H/ o
[ 80.0] Creating output metadata
( g( ^& t- o4 _# M$ a# U% |root@192.168.2.111's password:
v( C9 s9 o- }9 R池 vmfspool 被刷新
/ K( [) H9 U x4 w( D h9 i% q2 R5 T8 M2 Y8 a, x
root@192.168.2.111's password: 7 L1 F2 O( Q$ T' _' k
定义域 oel4(从 /tmp/v2vlibvirt255acc.xml): Q. P, C& [6 X. E. A
, \$ l' q! `- o* P
[ 86.0] Finishing off, i% U* M2 f. C! E/ y- B
[root@node72 ~]#
6 v1 m( m0 g% J5 V; K#迁移完成
: f6 ~' h/ l1 R% M$ H, \#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改
1 e* t0 {$ j5 ^6 {! {, C6 K' S[root@node71 vmfs]# virsh list --all3 x+ G9 L/ o `# U
Id 名称 状态7 n% S" N. h- `$ i3 m1 n3 {. u4 N
----------------------------------------------------$ \* I' r/ Q! ?: M5 a
- oel2 关闭 W) G9 m7 E4 T. N# f7 X" W
- oel3 关闭% a9 b, y- i% y! [3 e9 `5 Q
- oel4 关闭
4 x' t& t* ^% }+ [; `" r[root@node71 vmfs]# 7 @! B2 R2 F/ u" D$ {1 V1 s' v2 L) J
#可以查看到oel4已经迁移完成
+ Y! O# ^( [( w' U1 Q) ?1 ?) T6 O
% U* [3 x2 G$ ~1 W' p- ^9 [3 v#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误
2 P" E, N9 r3 F: F9 Y[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4
3 S/ B: P+ }, s, C( {: S0 pvirt-v2v: warning: no support for remote libvirt connections to '-ic
- O- m, B& P' G* s' a: Kqemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to ! \5 ?6 x, d, @
read the source disks.2 `8 a; a( @9 w7 a
[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
. T- E0 \' t# ~% y( ~# Lroot@192.168.2.110's password: 9 o1 K. U* P8 ?, C; i: s! v
[ 2.0] Creating an overlay to protect the source from being modified# B' I# L/ W1 f6 D& ~4 y% r, _
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory
, ^( V$ I: A f" t; s3 \# \* }7 Pvirt-v2v: error: qemu-img command failed, see earlier errors
6 P$ e( g5 T4 `/ J/ U$ ?
6 s2 v+ P. Z; hIf reporting bugs, run virt-v2v with debugging enabled and include the . q; f/ `% ^5 K. I6 ^/ D
complete output:
% `/ V; }3 Y/ x) r( T0 P; q* y( M. G4 R7 [: X* _6 V
virt-v2v -v -x [...]
( v- I: `- z, Q; B# ]) a" ?[root@node71 vmfs]# ' v" S" T- M( p6 C; N) Q" s$ s3 l
#暂时还不清楚,我们-ic一直会报"No such file or directory"
d" A @9 y5 l9 @% \/ {% P8 bvirt-v2v 命令帮助
4 y- M1 h& `( `2 t1 w[root@node71 iso]# virt-v2v --help
: n3 ^, @7 m. h& Gvirt-v2v: convert a guest to use KVM
) J% P2 ~2 l/ u' ?4 ^( y1 p- E5 @6 \6 O- D
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest `! G' B, q, U! s( h9 s: `
, V6 V1 Y" j( ]! b0 I" X0 W
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm
9 s5 ~* L- b$ w6 Q. T G# l1 ?% T6 G* ^% r, i4 D0 |, ^9 T% r, E
virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp: _" M; o+ c. w/ w2 h' y
6 ]& T- }7 l" M( f, j! m8 } virt-v2v -i disk disk.img -o local -os /var/tmp2 @* g3 V( Z5 Q8 c
8 n! `7 e3 _( O5 O5 N
virt-v2v -i disk disk.img -o glance/ _! `9 F9 \ y( L' `: `& ^; S) j
I8 S7 W1 o$ y- BThere is a companion front-end called "virt-p2v" which comes as an( A& X* h2 P0 X3 g6 u- S. g& E' i* E
ISO or CD image that can be booted on physical machines.
5 N# O! x. N a8 W5 y7 P3 [, Y9 q
# G3 r. X/ w* e" C1 L$ Y3 S/ eA short summary of the options is given below. For detailed help please
7 z* ]) x! v( sread the man page virt-v2v(1).
7 H. h% g( Q. e
. z1 ^; E3 W5 c9 Z3 A7 n -b in:out Map bridge 'in' to 'out'
8 j' Y% X! G5 @+ r2 W M# y --bridge in:out -"-2 u# s1 R- h7 e" @6 H6 h3 c! j
--debug-gc Debug GC and memory allocations
2 e8 D( Z' x0 q9 ? --dcpath path Override dcPath (for vCenter)
8 Q/ {1 H0 A; Z% w. Z6 X- ] Y --dcPath path -"-
7 o5 F# t% m7 n8 ?. l( @, P; Y --debug-overlay Save overlay files
8 D% i/ F5 f6 |+ E --debug-overlays -"-
% l- |4 }( }8 _; L1 \ -i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)
( o( y- S) D. ~* ~$ d1 |! [ -ic uri Libvirt URI, G v7 r0 f- U! u
-if format Input format (for -i disk)
6 R# {( A; d( ]& x7 X5 ] --long-options List long options5 u6 w; V) p0 F1 e7 l
--machine-readable Make output machine readable
$ c+ g% e) j1 U( ~! ]# e: }% E -n in:out Map network 'in' to 'out'. t/ M+ n7 u5 u4 {2 k1 T: d
--network in:out -"-+ }0 O$ Y% z2 Y2 B
--no-copy Just write the metadata
4 D3 m8 I: G3 C2 g0 W! B1 ] --no-trim all|mp,mp,.. Don't trim selected mounts9 D6 z$ g ?- T* d, \8 I& G* W
-o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)5 ?$ u& K! L, s9 W* V! Y
-oa sparse|preallocated Set output allocation mode
8 h1 g; p X. }6 i- r -oc uri Libvirt URI
`) D' B- U L6 b5 |: i -of raw|qcow2 Set output format1 Q$ G' c3 _+ v
-on name Rename guest when converting4 i( O% V4 M5 y/ b! ~7 D- f
-os storage Set output storage location2 s! I: o$ _+ z7 F/ y( Y5 D
--password-file file Use password from file- E. U4 I9 d8 O5 K
--print-source Print source and stop
' i0 ]6 e1 Y, N# Y, t --qemu-boot This option cannot be used in RHEL. z \7 h6 @. D% o: T2 l4 X
-q Quiet output2 N- {; d5 V# N( [" q* {
--quiet -"-
2 x( Y: L2 f% k0 q- h --root ask|... How to choose root filesystem( `& u& M4 _& r. r4 M' g! l0 Q
--vdsm-image-uuid uuid Output image UUID(s)% `! D7 z/ z+ v" o+ c
--vdsm-vol-uuid uuid Output vol UUID(s)6 I1 M( c/ J8 C) d! }
--vdsm-vm-uuid uuid Output VM UUID' S5 q" i3 Y% G" N G' B6 X- B( e
--vdsm-ovf-output Output OVF file
R* v% t- I- X5 K -v Enable debugging messages
+ ]. R7 T5 @# G7 T --verbose -"-% w8 p2 z5 @- C& ?) n
-V Display version and exit! g" o% Q8 K, h0 b
--version -"-
! C8 X0 B4 V2 t; p) t! M Y9 H --vmtype server|desktop Set vmtype (for RHEV)1 s- I+ l: F0 m
-x Enable tracing of libguestfs calls/ N" {0 [# q+ B h; V
-help Display this list of options
# s5 M2 {0 L" S& u0 d- }, o --help Display this list of options |
|