|
|
楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)9 _) }- V* I7 u) p8 {3 o) N
1、v2v迁移1 J* U6 H) w* F0 j
#虚拟化迁移至虚拟化环境5 R+ C; t) b9 Q. s; R' v
#p2v迁移,是指物理机器迁移至虚拟化环境
+ n/ Q7 G3 l" B( n( t#安装v2v迁移工具:yum install -y virt-v2v
) }$ C4 k, n* f5 B$ x3 M#
' p4 V( B+ ` q6 ?& ?7 }3 @2、KVM-KVM的v2v迁移; N+ y& U* v5 \! j
#KVM是采用Centos7,vm是采用oel6操作系统,始终报错
# A9 |$ X+ O+ s. i- F$ G* S v; {错误信息:8 o2 J6 ]# p/ A& r
qemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory- A3 G( F" g" S" L
virt-v2v: error: qemu-img command failed, see earlier errors
! `$ w6 M7 ?0 A, u1 z. GIf reporting bugs, run virt-v2v with debugging enabled and include the : p- f, ~5 e$ c- |" o
#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool% V% W) N) B. z
#node72检查
# D. B/ c% F P8 s[root@node72 ~]# virsh pool-list5 L1 z. s6 f* y- N3 Z( @4 P
名称 状态 自动开始
: W5 G, y; }4 { U-------------------------------------------- x1 P/ |# v b3 t- r* e
iso 活动 是
' F. q$ I- e1 `7 h. ~" | oel1 活动 是 , e. {* c$ d. g4 {! U2 t
vmfspool 活动 是 8 b) G8 \2 i6 a6 ]2 M4 A
( H+ W1 _/ W) q Q/ d
[root@node72 ~]#
% F( d" V4 H2 t, u0 k8 z# Z#关闭需要迁移的虚拟机
# S1 R6 [2 B- C, {" x[root@node72 ~]# virsh list --all
. j- }; y/ r' y8 R& U. Z1 L$ y* ~ Id 名称 状态
6 J- c/ D7 i' ^+ r----------------------------------------------------* ], u/ g: R6 ]) |* F
7 oel4 running+ } c1 n) H% M& S% X2 h
- oel5 关闭
# r) B2 {( v/ L+ O3 P. s[root@node72 ~]# virsh shutdown oel4
6 T) e0 U% t- l" g8 u# j5 N+ Q域 oel4 被关闭$ _' W$ d+ E( O, j1 B
[root@node72 ~]#
u% C5 M# K' Z#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例, t0 p' q6 H m
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
0 ]; H7 i0 c/ t- y/ L# G# P9 B6 A[ 0.0] Opening the source -i libvirt oel4
/ a, L* P0 r- l[ 0.0] Creating an overlay to protect the source from being modified
$ L: u- D4 {0 k+ q[ 0.0] Opening the overlay8 a! d3 t% }! g; Z4 h Z
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool; h; N( O" K2 i* O9 j$ m) \
root@192.168.2.110's password:
- i. s3 N; F! a* z9 w! ^root@192.168.2.110's password: ( C# y$ Y- l7 N. I
root@192.168.2.110's password: g7 t+ Y# y" ]
[ 17.0] Inspecting the overlay
! Z, J, {0 c; U, ~8 |! u" l[ 24.0] Checking for sufficient free disk space in the guest
C b% j* ?; z7 f7 V[ 24.0] Estimating space required on target for each disk
0 T0 ~& ?! }" c4 i' q+ ^: T& _[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
6 j$ N, B9 ]) I b& P* k9 H; e6 Lvirt-v2v: This guest has virtio drivers installed.
1 N% K" ~' x2 m, A9 ][ 69.0] Mapping filesystem data to avoid copying unused and blank areas+ _/ q F" e+ A
[ 69.0] Closing the overlay g$ e9 O' f5 @; X! g
[ 70.0] Checking if the guest needs BIOS or UEFI to boot
( h7 C) f- z8 X2 c# o% u" n[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)- p- i, l* n2 h+ R1 f5 F' j5 N4 U
(100.00/100%)
/ g: k, S' b* W5 E, e# Z[ 82.0] Creating output metadata$ K* X8 {6 m9 ?- ^" Q
root@192.168.2.110's password: ' @! K3 F4 M3 Z( o+ X& a
池 vmfspool 被刷新- A. o, H/ w+ p9 n1 |
root@192.168.2.110's password: ; x2 q2 t6 P6 ?! o2 n
定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)5 u( {9 {1 m5 D: [) m4 l4 j
[ 107.0] Finishing off
V, \, l$ W) R4 a[root@node72 ~]#0 X5 V; r7 Y9 w, N. S5 a* ^
#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)
0 m! A# ~; |! P4 }; H: V#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,
+ C7 b A" M7 Q. W$ M7 C[root@node72 ~]# virsh list --all
& Y; j \% n- }' }9 q7 \ Id 名称 状态- _. T$ F) A, H
----------------------------------------------------
, |- D& e3 L6 {% E - centos4 关闭
' ^( z3 ~$ q* ~1 q& D$ }' |% y9 Q - oel4 关闭
+ F2 l1 E& A* i9 J+ H - oel5 关闭
( f! V1 f% E; c4 Q; }$ K0 A[root@node72 ~]#
! m3 j2 r% g: B3、KVM之间的v2v迁移
/ n6 s+ |) p1 e8 z" |- H" s* ~ j* c
- M+ s0 [9 t" Q: w* }3 F; d#检查node71的迁移环境: K. b' T: s3 P% J/ g- B
[root@node71 ~]# virsh pool-list+ P! o! g! q: I6 \2 G t
名称 状态 自动开始" C# p; T' a1 }
-------------------------------------------; l: a r6 E0 P8 L: ]
iso 活动 是
6 i3 \. W, J; d% ]) V1 A+ s vmfspool 活动 是
T. S+ ]! ~8 m+ j& R' @( \% G0 ]8 G4 e$ H3 `: h
[root@node71 ~]# - Q q: x) x% D' ^: T& l
#测试迁移,从node72迁移出来2 |0 }8 Y I: t2 A# E j& U: M
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4
9 x8 D: k* `7 |[ 0.0] Opening the source -i libvirt oel43 M9 e9 S8 ]: T/ ?
[ 0.0] Creating an overlay to protect the source from being modified
! K6 K6 E5 V5 Z& T0 Z: A- A[ 0.0] Opening the overlay' S3 _8 |7 r8 `! w+ v
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool
6 ^; p# N3 c x5 B) p) e. Croot@192.168.2.111's password:
9 G$ B0 U' q" H& |root@192.168.2.111's password:
% I! C9 }; K% [6 X6 Yroot@192.168.2.111's password:
% S" P" a) d0 g* E, s) H' N[ 18.0] Inspecting the overlay, p& V5 q3 a3 F: _
[ 24.0] Checking for sufficient free disk space in the guest
$ L: j) v, m+ g, j8 z8 x[ 24.0] Estimating space required on target for each disk
4 S2 C( M! C$ v[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM1 A" n4 H: |, W& E+ s8 S
virt-v2v: This guest has virtio drivers installed. P4 q* j! K! f; K
[ 68.0] Mapping filesystem data to avoid copying unused and blank areas. L( m2 s# T! ]4 o( b7 F
[ 69.0] Closing the overlay
8 e' {0 o2 M% X8 m[ 69.0] Checking if the guest needs BIOS or UEFI to boot; E! }; j* X3 E
[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)6 a+ E( r+ S8 G! V
(100.00/100%)
6 U- {8 x" Y/ ]- ^3 ^[ 80.0] Creating output metadata
+ b0 q) [4 Y2 |2 d( x Lroot@192.168.2.111's password: 3 M" D5 ]% i1 C0 X7 i5 l
池 vmfspool 被刷新
# L9 d$ e) ? b% o2 p3 R. J9 }: F/ y4 Q+ M h$ b; |5 |& S0 s
root@192.168.2.111's password:
6 b1 o* C. [. R' S3 c2 _! I5 f% P定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)
: D0 L' ~& x8 H7 r; O& S1 K" h
, I" n" w$ h" }9 C* m; y: |[ 86.0] Finishing off7 m* H8 ~0 ?) e/ K2 F& Z
[root@node72 ~]#
3 H6 v6 r3 _0 T' M4 `#迁移完成# U# G- I3 S% B5 ]0 A+ |% `
#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改* v+ B7 o$ W' l+ M0 i* X1 F
[root@node71 vmfs]# virsh list --all
3 J- ?4 x2 b; i Id 名称 状态1 i/ y; q' d( h$ P: Q& C6 k: B
----------------------------------------------------
$ [) @ o: z ^ - oel2 关闭8 `# {) Y1 F& @1 p0 z2 T/ e8 J3 i* }: i( u
- oel3 关闭% K5 C- R7 K! k+ I& f/ l
- oel4 关闭 {* j6 W5 ]2 G h
[root@node71 vmfs]# 0 c6 y- J! |) W/ H' o5 R
#可以查看到oel4已经迁移完成" z2 P8 A i; v: \
" t' ^: k0 Q, }#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误: D. A( u, l5 X: y' @& ^
[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4' }6 {# }6 V6 i. v6 v% V
virt-v2v: warning: no support for remote libvirt connections to '-ic
+ R5 ^3 G% w8 O2 D$ Dqemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to
$ x3 t) {8 V) ?& Z gread the source disks.
) G/ O8 H9 b. E i' l[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel46 p( P- S9 R" k. D: J! f+ c
root@192.168.2.110's password:
- _9 C) f% t; f. V' j' K[ 2.0] Creating an overlay to protect the source from being modified
6 Q( V! P# ?7 n( o7 S2 xqemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory* U! H, w$ q- e$ L4 m
virt-v2v: error: qemu-img command failed, see earlier errors
" l4 l. c# t. d; L. S/ u6 e+ ]! c( |: x4 ~0 D5 A
If reporting bugs, run virt-v2v with debugging enabled and include the
- j" `) P/ u- R! Zcomplete output:: W/ u1 y/ B0 ]1 E' t
3 | E9 G" u* ]+ J6 f# b
virt-v2v -v -x [...]
2 O/ u5 I9 Y# e[root@node71 vmfs]# " n: F+ D! k2 |. L5 n+ u
#暂时还不清楚,我们-ic一直会报"No such file or directory"3 i A9 Y. s. m9 x/ t$ p( [
virt-v2v 命令帮助
% q. N1 T% i- a6 w/ {# Z" W[root@node71 iso]# virt-v2v --help% M" s7 {9 `. Z% L
virt-v2v: convert a guest to use KVM$ J: p0 s3 t) m( y, M& ^
; {0 D7 ^, S: S7 F virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest
! l& ]" H3 P2 q% e% y6 P: _& z1 p( v! g6 l: U
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm1 e$ G; |$ J! Q. {1 w$ s8 J
+ y- C7 k( _+ c; _1 q( k" o virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
$ p( \8 e. w8 [+ I% m+ |0 s/ y8 D0 k3 @5 F" s( I
virt-v2v -i disk disk.img -o local -os /var/tmp
7 O* ^' f1 P4 X1 g# [( }$ _6 f1 T2 X- N0 \5 F. L
virt-v2v -i disk disk.img -o glance
7 V, v0 u! B$ J, K# y$ m S3 q( q( \* p M2 S3 E
There is a companion front-end called "virt-p2v" which comes as an
/ p u4 V% a3 j7 A; r( Z& T1 j) gISO or CD image that can be booted on physical machines.
4 X: G% o# o9 Q8 F7 {# F& G5 X9 b
% V1 N" u" i2 t7 S8 KA short summary of the options is given below. For detailed help please
B/ }/ d% E/ a. y: ]read the man page virt-v2v(1).' y! ?% ~( {; o! J
" J: x6 H3 b3 I -b in:out Map bridge 'in' to 'out'/ w$ u- y/ v$ J7 `
--bridge in:out -"-: D, L. |2 y8 ]; y. A( E D+ f
--debug-gc Debug GC and memory allocations
6 Z; n1 |) v& J$ g4 i+ C --dcpath path Override dcPath (for vCenter) j( O$ D- Q8 ]. y; w* W: a
--dcPath path -"-- q( E3 B1 I" [1 C5 l
--debug-overlay Save overlay files
$ N# s, e0 M7 R8 W --debug-overlays -"-
" P$ F( C, d3 D9 _# r -i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)
' n! C4 T+ l. u u -ic uri Libvirt URI3 ~) W, b9 u8 g# B. x& h
-if format Input format (for -i disk)0 w$ B3 R5 _; r" U& L% r7 ?
--long-options List long options
& d) n; B! K) V. W( ^& E& Y3 Y9 \ --machine-readable Make output machine readable- p# f/ L" Y. V* D7 `
-n in:out Map network 'in' to 'out'; |( B6 q; L; ^' p( g* N% q' T& H. j
--network in:out -"-5 A5 T" r% \* @" B
--no-copy Just write the metadata& n! f7 A9 `% ~# B6 V8 B; }4 j
--no-trim all|mp,mp,.. Don't trim selected mounts
7 l& h: Y% l2 A- b1 p- r -o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)
) t ?$ z) H' ]' d- f -oa sparse|preallocated Set output allocation mode% @4 i7 W5 u( t; I
-oc uri Libvirt URI' ?' l2 ]8 I; ^/ a
-of raw|qcow2 Set output format
: [# z( }) u2 p6 Q! _: Q -on name Rename guest when converting
/ [; J: X" ?$ ~$ U9 w+ ~4 w -os storage Set output storage location4 N) L! P+ ~5 a$ R% u( y* L
--password-file file Use password from file
W/ e% i' o! N; A" i --print-source Print source and stop2 y& _7 z+ d4 z4 d( E
--qemu-boot This option cannot be used in RHEL" i1 b" m7 J1 M" c! S! K* }% J
-q Quiet output
' s# k* Z/ G4 U --quiet -"-) M+ j3 l" h! x4 Z. j1 M6 h
--root ask|... How to choose root filesystem, z, |# R5 t& ^! {4 U
--vdsm-image-uuid uuid Output image UUID(s)' Y3 P3 c/ Q5 X* U
--vdsm-vol-uuid uuid Output vol UUID(s)% C }" R$ G" `
--vdsm-vm-uuid uuid Output VM UUID
5 M, _( `8 g. _! ] --vdsm-ovf-output Output OVF file
$ V: x2 U; w9 b+ `1 Z -v Enable debugging messages
2 q- J1 j E- B8 W+ [& p k9 k --verbose -"-
) ^' g/ f% h' ]$ u, @$ E4 ~- U# ^ -V Display version and exit
( ~0 _1 l4 ~7 U) Y --version -"-
4 f6 m- `* p& H& U { --vmtype server|desktop Set vmtype (for RHEV)
$ l* k1 _% d y9 q6 @/ ]) Y -x Enable tracing of libguestfs calls- F! D$ P! V$ E( U
-help Display this list of options8 S; G: `0 ?2 Q n! Q
--help Display this list of options |
|