- 积分
- 16840
在线时间 小时
最后登录1970-1-1
|

楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)3 Q" G- ~- X; t/ z+ {* d: Q7 ]
1、v2v迁移$ K) \) `7 S" e+ t% P
#虚拟化迁移至虚拟化环境5 {) N6 I. M+ ]1 J) g! e
#p2v迁移,是指物理机器迁移至虚拟化环境! a( M+ }: @8 ^$ F0 E" w
#安装v2v迁移工具:yum install -y virt-v2v
* _3 \9 `8 ]( D% ]$ X y, g#% n5 P: i6 @1 d8 Q( |& y! R5 A
2、KVM-KVM的v2v迁移
- p; N0 f7 u8 `* Z! R3 p j g4 w& q#KVM是采用Centos7,vm是采用oel6操作系统,始终报错
& K2 t7 V) n' o9 d7 R) n错误信息:
1 }+ e: o" J0 u1 Eqemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory7 O Q H3 |4 |: b8 n. l! B- Y
virt-v2v: error: qemu-img command failed, see earlier errors/ X @) j' O: C. P: G. ^
If reporting bugs, run virt-v2v with debugging enabled and include the 9 |, B: N0 @ G: O' V* u
#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool
, B) g5 F6 [7 H/ T$ s7 X#node72检查
5 ~& D2 t3 l1 ~( v* S( v$ h[root@node72 ~]# virsh pool-list
- m+ }. q( y( \: e% a 名称 状态 自动开始* t1 F2 X. X' A3 B6 F9 ?
-------------------------------------------
5 _4 Z+ z" W0 N* i1 j* o iso 活动 是
9 p3 J3 k5 j: G' }) G o oel1 活动 是
7 E9 [. Y z; o* A+ s6 C: |! h8 S vmfspool 活动 是
* B/ @; Z" H- n+ n3 S3 }$ G( {1 C1 t7 a3 m
[root@node72 ~]#
) A, F9 w2 o0 z7 A8 m7 c2 ^#关闭需要迁移的虚拟机6 u; B9 O* G$ g5 P! o
[root@node72 ~]# virsh list --all
- B% e5 `. k" u$ K Id 名称 状态9 ?( y2 Z! L$ s9 G2 ~: n+ v8 R
----------------------------------------------------( `% ^& n! `) F# n* Y
7 oel4 running
0 f! t/ W8 F* H - oel5 关闭
3 b4 e! _$ e8 j% M; o R[root@node72 ~]# virsh shutdown oel4
! M" n1 }) N; g6 T; m6 ]域 oel4 被关闭7 Y ~) X! [" G. S
[root@node72 ~]#
" W7 e/ J- p6 p! I) G#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例
# s. P4 X3 A8 Z3 q* I3 `[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
' u$ c0 Q2 z q, n0 X5 D9 \[ 0.0] Opening the source -i libvirt oel4. N1 R9 Z x; u( ~ F5 M. v
[ 0.0] Creating an overlay to protect the source from being modified# t% Q3 u- l' d! Q' T
[ 0.0] Opening the overlay* x7 }, Z1 E y4 {4 ?3 j }: C
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool' |+ @) U* Q' |$ Z
root@192.168.2.110's password:
% G4 q; m* V3 _% p, v; s, Kroot@192.168.2.110's password: 6 _% U7 x& @# V- N9 B; \ o
root@192.168.2.110's password: 9 P6 ^* a9 u, D* F
[ 17.0] Inspecting the overlay b% K3 l# S9 @/ U2 Y+ v
[ 24.0] Checking for sufficient free disk space in the guest5 T, L; i# n# A8 I
[ 24.0] Estimating space required on target for each disk
* E0 e, v8 Z* e7 J6 a H5 j" U5 K5 O) t[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
8 M; c1 O7 p" O1 \4 U/ x7 Vvirt-v2v: This guest has virtio drivers installed.
; J, n8 }- N5 N! T; a2 P[ 69.0] Mapping filesystem data to avoid copying unused and blank areas1 I+ A* [- c$ E6 @" C5 v
[ 69.0] Closing the overlay
2 y g; j" o$ T) j0 D+ X9 ~[ 70.0] Checking if the guest needs BIOS or UEFI to boot
( l; ]& ]9 N! d6 D. O% o$ g[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)
0 w5 ]9 C7 h1 I. p0 b (100.00/100%)
8 f" p! H% `$ h' Z, r) l[ 82.0] Creating output metadata
, k0 q9 x9 @* O! C/ hroot@192.168.2.110's password: k+ a$ S0 P7 l" c
池 vmfspool 被刷新
( P) E& y: I7 w& S3 v1 oroot@192.168.2.110's password:
4 b) \) U) g6 \1 g定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)$ D X5 K9 S. X, |: \
[ 107.0] Finishing off+ S% x' o, m- E0 X% G) j" C
[root@node72 ~]#; u. g- T' L5 V. L
#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)
, p, q$ ^/ A2 O/ w#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,
, T! P; U6 x( V ^2 r' O[root@node72 ~]# virsh list --all
! B) X5 j+ m& J" A8 [/ o" _ Id 名称 状态( H `6 F, {" s! Y3 B- j' v
----------------------------------------------------) N' y w3 @+ r9 y! @% J3 M
- centos4 关闭
: E: o( H6 P) N- f8 o! i X - oel4 关闭: f- f: J" j# E/ t! B* A
- oel5 关闭* y5 P6 P. ]* p
[root@node72 ~]#/ O" |8 ^9 h, h& t+ y" ^# g
3、KVM之间的v2v迁移
+ s: Z& ^; H4 z6 W9 A: X, }% s- j7 I) N, g8 S' \ \/ q _8 N8 t1 Y# R, e
#检查node71的迁移环境+ h, t4 i6 E b* J; Z
[root@node71 ~]# virsh pool-list' @1 J) U5 h1 C8 z8 {& Q+ j: H
名称 状态 自动开始; W( ~+ Y& ?1 Y0 G+ h
-------------------------------------------
+ h& F* p& {6 R4 j( H8 g( c iso 活动 是 4 L0 v' z1 B- r8 x7 D
vmfspool 活动 是
" T( _9 E8 C8 _: o8 a9 l
U; v+ t; @+ J" y8 L/ u[root@node71 ~]# , {% M. g3 F4 m( X6 C5 s% Q: b
#测试迁移,从node72迁移出来0 G1 E3 C& R4 [$ I+ W* c
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4
& M7 `7 b @, I0 o! G9 t[ 0.0] Opening the source -i libvirt oel48 k- o$ V- X! y& F
[ 0.0] Creating an overlay to protect the source from being modified+ L3 ?' L X; u* \8 x. j# g4 [
[ 0.0] Opening the overlay
9 f- v0 p) g# p }5 S/ d4 d ]6 H[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool
- j3 b+ P4 j6 J* Wroot@192.168.2.111's password:
# ]1 O% @3 Z6 O. u, ~1 \root@192.168.2.111's password: 8 _! Q- H/ ^4 ~# K( {' W: m! _
root@192.168.2.111's password:
/ P g5 v$ H. N8 s1 N5 I" \[ 18.0] Inspecting the overlay* e; E3 Z% p& V% |
[ 24.0] Checking for sufficient free disk space in the guest/ }4 W5 `2 J7 Y: s! t. u% r
[ 24.0] Estimating space required on target for each disk4 J2 p% ?: B/ _5 S: j& d* H
[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
" G# |- n- p9 Y3 e0 m% j Uvirt-v2v: This guest has virtio drivers installed.# R2 [) [9 G- P3 v# @: `$ D/ J
[ 68.0] Mapping filesystem data to avoid copying unused and blank areas
5 D0 ^; v" B+ B; s+ e T6 l[ 69.0] Closing the overlay
3 o0 s5 K( S y1 p+ w# B- F2 @[ 69.0] Checking if the guest needs BIOS or UEFI to boot
# y P6 _ h7 t- n+ \[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)
7 K2 I' j7 I, n$ S/ ` (100.00/100%)
) H! V% ]! C# o, ]/ O: B[ 80.0] Creating output metadata) f0 c: V9 W" a0 @! o9 ]" }* t. z
root@192.168.2.111's password:
0 d( n, b& t7 c9 x$ q4 S6 m L; V池 vmfspool 被刷新
: P/ c+ O6 y1 u: U' }8 `0 v$ x; G1 J4 o# O: J) i# t# Q3 i9 O
root@192.168.2.111's password:
, d( F D: y+ }2 u' O& G5 |定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)8 I( |2 o/ C# `7 f' Q3 ?
- Z2 ? K3 C! G# J[ 86.0] Finishing off2 c+ A9 W5 ?8 [5 J1 Z( t
[root@node72 ~]# 4 s; g+ @: X! v/ [4 v4 j
#迁移完成
% @ h# m; n' M#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改
0 W4 d) T1 t* e" w9 [% \[root@node71 vmfs]# virsh list --all
2 `# c5 K: n7 c* k: { Id 名称 状态
" _8 M+ N8 U/ ~8 ^2 u. F# D1 B----------------------------------------------------
, F' T3 n% x4 @; v; y1 n- C$ ~ - oel2 关闭
" x$ C# x; y) n7 Q% u - oel3 关闭) L* f$ J. N6 @% b1 M5 ~
- oel4 关闭
2 ]6 m. v- T u6 Y[root@node71 vmfs]#
5 [# V! b1 @0 M6 t2 Y7 s#可以查看到oel4已经迁移完成" \! v" x4 K6 ^# U0 s! U) a
! l; d* z$ C4 B7 R$ U
#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误
j) j$ A+ e- E% \4 F[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4
( N: I, `( s# S: k; Nvirt-v2v: warning: no support for remote libvirt connections to '-ic 0 ^% }; J. L1 m
qemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to
0 K7 M! y" f ^read the source disks.
$ e9 \9 O0 q! @[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
9 z8 d: @6 _* z7 o4 s4 sroot@192.168.2.110's password:
3 T X; C2 G t; D4 m2 }! d0 _[ 2.0] Creating an overlay to protect the source from being modified* h( p2 v" J. O1 c- d5 h, @
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory3 X, ]& l; t" U' q" s \
virt-v2v: error: qemu-img command failed, see earlier errors
" |, d ^8 k9 P! Z- q
" g6 o% U1 D- n% x4 {/ wIf reporting bugs, run virt-v2v with debugging enabled and include the
* ?, [" v( c' C! I7 icomplete output:' ]+ Z& Y9 S" w" V( d' E( L5 N
$ g Q9 F1 C$ `5 M4 h* l+ O, J
virt-v2v -v -x [...]* {3 w& o9 h! K) v5 }" I7 L
[root@node71 vmfs]#
, |* W1 W* J3 n: a" V4 P#暂时还不清楚,我们-ic一直会报"No such file or directory"
8 z- W3 q& y5 T; kvirt-v2v 命令帮助
/ p3 M2 s' O' s- U; [[root@node71 iso]# virt-v2v --help8 O5 q) V7 c0 W4 v' P
virt-v2v: convert a guest to use KVM
( k- q; z* B% e% b% T' K! G8 D! c, R( m: C1 c
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest9 H. D- ~8 x% C: |
/ P. t9 U( l. Y9 R% A virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm8 [: f7 A( U) G( K7 V
8 r/ R' ?$ R/ B" G% n0 K virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
9 @/ Q, C) R# v9 `0 `0 k$ a: z
* L! Y1 X% C! Z7 ^8 d virt-v2v -i disk disk.img -o local -os /var/tmp, L8 `, Z8 L( Z8 f
( I% \1 x& t+ z virt-v2v -i disk disk.img -o glance0 y( R4 g7 e$ ^2 w
. p2 W2 M5 u1 |+ s7 V5 w
There is a companion front-end called "virt-p2v" which comes as an7 j& T5 D' d. T$ d
ISO or CD image that can be booted on physical machines./ f6 {: f, b* \8 t- C, b* p
- Y- G( h2 L7 E( W zA short summary of the options is given below. For detailed help please& b! @# \( D7 E! u M% U
read the man page virt-v2v(1).
% r/ R. |& [0 G7 A. O# |; g# `+ p5 B
-b in:out Map bridge 'in' to 'out'
w$ Y. S3 ?- D7 f- G0 B --bridge in:out -"-
; K" A4 M, Q' v% q: V' ^ --debug-gc Debug GC and memory allocations$ p3 H0 H% t) q: l
--dcpath path Override dcPath (for vCenter); O% t# s8 Y2 p
--dcPath path -"-
1 k0 X9 b9 U0 D --debug-overlay Save overlay files
- P B# Z; @: l2 W. v- j: A --debug-overlays -"-
0 U0 u3 z1 ~' ] -i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)
& D$ R# _4 L9 m2 @; ~1 t -ic uri Libvirt URI& g2 P( U6 h) f7 j9 p3 Q1 L
-if format Input format (for -i disk)
8 }. o1 z. i- `# x/ M1 [/ b --long-options List long options
5 N& Q( w' Q- z8 X$ Z --machine-readable Make output machine readable
. R3 ]% Y# ~6 s$ ]% t% l -n in:out Map network 'in' to 'out'
( T# s' G3 e! ?3 y7 |- \ --network in:out -"-
/ p* L: f4 B: _ M* u, v2 ` --no-copy Just write the metadata' Q/ b: J$ P6 ?8 H! K. [2 M" S
--no-trim all|mp,mp,.. Don't trim selected mounts
3 j, l; s$ d6 h2 I7 V -o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)" C* _8 v6 L- N4 E+ ^1 @% B, I5 Z
-oa sparse|preallocated Set output allocation mode* l. J Y" N; u/ M+ @
-oc uri Libvirt URI' |# t% G5 b7 f
-of raw|qcow2 Set output format
* f5 [, T# a2 ^0 u -on name Rename guest when converting
, ` y) J2 Z, { D -os storage Set output storage location
" a1 m$ c# ^ h --password-file file Use password from file
% ~ V. T0 B" C --print-source Print source and stop
2 o9 `( H1 E( p, S+ v. z$ F8 A8 n --qemu-boot This option cannot be used in RHEL
- p7 R. m+ m) P, g -q Quiet output
- D; r+ F" O2 o9 c" S/ H --quiet -"-: a$ [# n p( n5 ^" h3 j2 G+ g' q4 v
--root ask|... How to choose root filesystem2 t; f4 j' C& A& m
--vdsm-image-uuid uuid Output image UUID(s)
; `2 e' L! Q5 P5 | U" Q& N --vdsm-vol-uuid uuid Output vol UUID(s) x; @* j; w/ E" y' m* ]+ d
--vdsm-vm-uuid uuid Output VM UUID
& T: c3 y5 x' i+ | --vdsm-ovf-output Output OVF file* [ N$ ]& V3 V% R% V
-v Enable debugging messages
) o9 g$ @4 t f9 @ --verbose -"-+ n* N+ }* w2 z0 o6 V6 M- _# Y: D& T
-V Display version and exit
0 M" U3 j/ C1 J/ A --version -"-
- a. x/ M& q; b# ?1 Q --vmtype server|desktop Set vmtype (for RHEV) t! o. X T+ W
-x Enable tracing of libguestfs calls
$ ]7 N8 w" v1 o -help Display this list of options! J9 O% p3 e1 A h# _7 ]7 X
--help Display this list of options |
|