|
|
楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)
( A7 G" u. w& j# o( g1、v2v迁移
/ O6 ^* ]) ]8 g; |#虚拟化迁移至虚拟化环境; }( Q0 H6 }8 o
#p2v迁移,是指物理机器迁移至虚拟化环境, f7 x* K' G2 m, e4 p7 I4 P0 |
#安装v2v迁移工具:yum install -y virt-v2v9 _7 D) p2 B. i" @0 q+ A$ m: G) |
#
7 B. S3 c' D3 H( j2、KVM-KVM的v2v迁移8 m3 u+ z6 N% j. ~
#KVM是采用Centos7,vm是采用oel6操作系统,始终报错
- l* ], S8 p O错误信息:7 {. {, p9 \- |6 m- K7 l* p1 r
qemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
$ t) K: @0 R+ K' c+ B# W7 ^, |virt-v2v: error: qemu-img command failed, see earlier errors
* q0 I) H/ {: A# z7 yIf reporting bugs, run virt-v2v with debugging enabled and include the
0 _2 k3 e, i C7 ?& u/ L#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool" m. P3 A1 X1 d
#node72检查
; S7 p* n" k4 t+ O; R7 b[root@node72 ~]# virsh pool-list+ t& V& _5 T$ _% ]
名称 状态 自动开始
# l' ^. _2 _+ D/ c4 T4 }0 f-------------------------------------------/ {2 A0 Y( N8 A
iso 活动 是 ' {- t# L8 U# J2 a" T8 B3 M
oel1 活动 是 3 S6 [# p/ R. U* w! Y; u2 p& X7 D- i2 ]
vmfspool 活动 是 " e0 x+ K& z; |" |( d y
3 B/ Z4 N6 D# g8 j8 X3 A[root@node72 ~]#
) R4 k# Q6 B2 [" S( B9 P, r' J* P" m* q#关闭需要迁移的虚拟机
! C: H. w. X& A: Z9 C$ e" M[root@node72 ~]# virsh list --all; n% A# ]) ~9 r6 O
Id 名称 状态% Q; T' G Y9 w9 v/ Z
----------------------------------------------------. O4 Y# S! F- {/ ]. U6 v
7 oel4 running
5 b {/ n: g$ ]7 }$ M - oel5 关闭
! j& g3 h8 [4 k2 I. X2 z T/ J[root@node72 ~]# virsh shutdown oel48 Z5 l6 n' I( A. J: [# q
域 oel4 被关闭
+ d% _" S- r9 K+ E[root@node72 ~]#, H# f" N- {7 c# H! {7 [. r
#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例' G- v" P8 ?) H' u( O
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
- x {5 J' Z% f& X- C[ 0.0] Opening the source -i libvirt oel48 N0 p7 |0 V* m; {4 Z
[ 0.0] Creating an overlay to protect the source from being modified
# r, |+ y" B" g% M5 c! }[ 0.0] Opening the overlay
5 J3 Q5 K3 [9 l/ S; N[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool
2 ]9 j) N7 U- m- g! h: croot@192.168.2.110's password:
" j$ J+ d3 Y; Y7 F7 N% `* M9 Yroot@192.168.2.110's password:
) A6 u2 A g, s, L) P0 {/ `root@192.168.2.110's password:
O. U4 T; I& k, c8 a6 T3 P9 o[ 17.0] Inspecting the overlay
. c l( _) S# F& j# Z[ 24.0] Checking for sufficient free disk space in the guest; {2 ]$ r# `' L# i+ S# a
[ 24.0] Estimating space required on target for each disk
. x' l5 b: X. }$ |$ z5 Y[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM" j- A. I# V K
virt-v2v: This guest has virtio drivers installed.8 U2 H9 l8 W; {
[ 69.0] Mapping filesystem data to avoid copying unused and blank areas
H# {' A0 O: l* c7 k! p" J[ 69.0] Closing the overlay8 i3 K! k1 e8 x9 y9 m6 ~- T$ o
[ 70.0] Checking if the guest needs BIOS or UEFI to boot
% C" V+ a- o# r8 t[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)( q* o- l2 X4 B2 W) m- d
(100.00/100%) \: T; y) o% D+ Q9 s
[ 82.0] Creating output metadata
$ \. T: l; m- `! U' i! F: g8 n. t' Croot@192.168.2.110's password:
N2 t( R. j' V7 I) z( I7 a池 vmfspool 被刷新
2 L# t! t6 a: V0 F7 ], E9 Vroot@192.168.2.110's password:
/ \; U1 d" } i% a# K" b定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml), ]: b7 S2 ^0 }& j# y
[ 107.0] Finishing off
& J# J; ^% T" K* B1 n[root@node72 ~]#9 p s+ [" o& K1 V/ Y2 L. }
#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)* |+ L+ ?' c( u! l# W3 O
#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,
0 a' |% x: R4 e5 ^/ z[root@node72 ~]# virsh list --all& J1 o& t! s1 `( E3 C- o
Id 名称 状态
" }$ i* ]; A6 I, Y" K----------------------------------------------------
7 i6 U' {& u# I U - centos4 关闭
6 M, y- O S+ i - oel4 关闭
0 ^% M( s' B& X: y- F; k - oel5 关闭
0 r$ j- Z7 Z( ?% j3 a[root@node72 ~]#
1 X2 }1 p ?3 J: O9 k3、KVM之间的v2v迁移
p `5 H* P9 q) x+ v/ S* k& b9 e. \$ Z& A
#检查node71的迁移环境" I- M0 S2 T/ G
[root@node71 ~]# virsh pool-list9 @+ W, M" v/ r' d( ^
名称 状态 自动开始0 b, ?, P, Z6 Q( E: c- w9 d
-------------------------------------------2 @1 h1 @# Z5 h' k
iso 活动 是
) ?, O: ?* x+ ?% D& W0 \ vmfspool 活动 是
: a3 d1 t- [$ \* V: i9 I" Y6 J; x1 X& }5 I5 `" e
[root@node71 ~]#
7 ~% \: R/ r3 D# x$ n* Y @# N3 S" r#测试迁移,从node72迁移出来
3 @0 b: G2 Z+ e& X# ][root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4
" z3 U9 H1 k# W% g2 U[ 0.0] Opening the source -i libvirt oel4
* `; {1 }* G" ~8 v[ 0.0] Creating an overlay to protect the source from being modified# g. x, i2 G; B9 i
[ 0.0] Opening the overlay, K5 `/ M, U$ V+ X# v, {9 G
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool4 C$ l9 {% n5 H
root@192.168.2.111's password: 3 L# Q8 ~' W; u+ A: z7 h2 K
root@192.168.2.111's password:
' _$ B6 f; z- w, b. f# yroot@192.168.2.111's password: ; p7 P' [+ X. J$ Y
[ 18.0] Inspecting the overlay5 }# Z; A: y' s" ]" q# X$ F" @! E2 ~, V
[ 24.0] Checking for sufficient free disk space in the guest9 x% a3 G$ Y1 V3 z- M4 |7 }
[ 24.0] Estimating space required on target for each disk/ E- r8 t' s7 y. O% p, s5 P) J* P
[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
0 P; J+ \1 P# y7 @virt-v2v: This guest has virtio drivers installed.
5 Z) v* I! X V' r+ G# l b! e( X1 a[ 68.0] Mapping filesystem data to avoid copying unused and blank areas9 ` m! Y$ ?: ?! u
[ 69.0] Closing the overlay8 ^7 g1 i0 ~7 {/ _1 r
[ 69.0] Checking if the guest needs BIOS or UEFI to boot
9 [4 o8 {9 t; G N) H[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2) e0 o6 y# V) [' | c4 f
(100.00/100%)0 y9 E1 F* h+ K4 e' T* U# @, ]
[ 80.0] Creating output metadata
( W3 {4 r& o/ W% R9 B7 O, Droot@192.168.2.111's password:
+ o0 o: g( f6 S6 u2 l池 vmfspool 被刷新
$ Q+ ?3 ]2 j# @7 H8 I0 h$ R/ Z) K) C. Y, {2 S# d6 M9 n+ U
root@192.168.2.111's password:
" z1 b1 |: P) c2 F2 Z! m/ S定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)
2 J8 E& U0 C+ x/ @2 f7 x6 W. ?: t& Q: c" [' e4 F. Q2 g! Z- x
[ 86.0] Finishing off
( S' ?/ M5 Y; U[root@node72 ~]# " s8 j& y3 d; b8 \8 I {
#迁移完成" \( \: ?- g U9 u1 Q. d' D/ ^$ Y
#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改
4 Q. o5 C; o' t0 K4 ~[root@node71 vmfs]# virsh list --all
! J* A' K5 ]6 \6 ^. i Id 名称 状态2 c. ?7 O5 r8 y+ |. X
----------------------------------------------------
, T' M: m) G7 r% [6 @1 Z8 D7 C - oel2 关闭
9 g+ _3 f+ K: i$ t& [ j - oel3 关闭
0 w* ~/ e: ~+ S* V0 ]( F3 z - oel4 关闭4 R3 U$ s1 ]5 s$ L2 i
[root@node71 vmfs]#
3 q+ h) S8 g: [, i: u& i0 `' E#可以查看到oel4已经迁移完成" i; \& S, {1 O0 Y% U$ \
* }* N8 Z7 F* i; U6 U* m, k
#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误
8 {; g; J7 D* C- |- u/ O0 }[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4
( o' ~+ `+ W: t7 U) ]+ w, G. Mvirt-v2v: warning: no support for remote libvirt connections to '-ic - M2 r& n; \! h/ Z; O
qemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to 3 d1 j" {$ r- _; v; |
read the source disks., w' ^6 r+ _8 o9 w
[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4# a& ]- |: t. w, x- [' f
root@192.168.2.110's password:
6 ^5 J' N, t# V; j[ 2.0] Creating an overlay to protect the source from being modified' ?& n1 V5 x0 T. e5 T
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory
- G) u7 m9 o2 t+ j* u1 \' {virt-v2v: error: qemu-img command failed, see earlier errors- w) r5 }$ P' \% P; K' Z/ ~. C, F/ k
( d2 N% ^; [( A, DIf reporting bugs, run virt-v2v with debugging enabled and include the
$ E- o O% o! T5 _complete output:
8 m' O/ T- v4 X. Z3 f4 r d- v2 o7 [. ~* g' r, p R6 M2 J8 h# `
virt-v2v -v -x [...]
! ]2 E) j1 C$ R1 j; M9 s" [. l[root@node71 vmfs]#
2 L9 R" w' `3 P/ ?( h#暂时还不清楚,我们-ic一直会报"No such file or directory"
" R0 y+ A3 A p/ mvirt-v2v 命令帮助
% D% U0 Z. ^. x6 t7 L* y[root@node71 iso]# virt-v2v --help
9 Q& v6 J" o4 w2 Evirt-v2v: convert a guest to use KVM
( i+ S+ @7 u3 X! Z+ B5 d, H
z3 o& _; w' ~2 q/ J8 q virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest
) U$ U: `0 |5 u2 ^$ \7 @! g2 E, ]6 H: A
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm: h/ n* o& r' y
f+ X- j1 f3 j7 K2 @+ o7 t virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
8 Z1 P: X0 k$ K0 O1 b$ `9 o! S; I' i
virt-v2v -i disk disk.img -o local -os /var/tmp/ x/ c* i- A& r7 H& u, V [9 q
# \4 Y# ]' _" u% C0 H
virt-v2v -i disk disk.img -o glance, o) g6 _& z* u8 ?" x
2 C8 I4 i# i; t8 ?" M1 hThere is a companion front-end called "virt-p2v" which comes as an7 Z% L; K7 L/ P6 w
ISO or CD image that can be booted on physical machines.+ _$ k9 @) J2 J- \$ j! p
# |. C: _+ f# O+ J4 a5 D) LA short summary of the options is given below. For detailed help please# b; Q: C. M! S/ y3 c" o% h
read the man page virt-v2v(1).; I ^, G' A) U$ X( B2 x3 E0 T
- p% y: e& A4 D$ ^* |
-b in:out Map bridge 'in' to 'out'7 m3 D+ E5 h3 |% {: e7 n
--bridge in:out -"-- Y# z* J+ s) p7 _3 \
--debug-gc Debug GC and memory allocations
2 k" U/ n. y# V) W2 H --dcpath path Override dcPath (for vCenter)0 B7 L/ P% i' T
--dcPath path -"-
- U( t3 w( s( J+ { --debug-overlay Save overlay files
& s: \5 @" l A2 z4 t' G --debug-overlays -"-
4 u+ l1 j0 \. l -i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)) N; m# A/ Y D3 y
-ic uri Libvirt URI1 [/ J% ]. E2 E9 E( D
-if format Input format (for -i disk)* F( R* a/ e# H$ {' j
--long-options List long options; T5 _2 r; X: T( X0 M
--machine-readable Make output machine readable; @! e$ C- }6 Z4 }& _# X
-n in:out Map network 'in' to 'out'
7 X8 o' {0 p9 z" J5 i& z --network in:out -"-
4 C, b- I8 V7 ~/ @1 g --no-copy Just write the metadata
% n: J* G% [0 F5 ?, D6 t --no-trim all|mp,mp,.. Don't trim selected mounts8 n$ D0 u- Q9 l. y
-o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt) _' s3 N, B O3 k9 W
-oa sparse|preallocated Set output allocation mode% l) L6 p* W( q" Y, F
-oc uri Libvirt URI2 e; ~. d4 n- o8 E" e
-of raw|qcow2 Set output format
, J% ?4 g8 ~& e+ ?% g8 X% l* O8 l1 k+ j -on name Rename guest when converting8 b# ?# A" F) B4 a* \0 r
-os storage Set output storage location6 M/ ?1 b. }, C- O5 R
--password-file file Use password from file
' u. m% {& F5 u2 E --print-source Print source and stop
. P0 X. t0 n5 [) N# U7 u( I1 b6 j --qemu-boot This option cannot be used in RHEL
" u% O8 M' I3 J9 \6 t) G' X' X -q Quiet output
1 t2 d5 n$ _ K1 f& v$ q --quiet -"-! e% d8 T5 t& Z+ O( x8 r
--root ask|... How to choose root filesystem5 `0 [4 w) O3 V8 A/ z) M# v9 z& N
--vdsm-image-uuid uuid Output image UUID(s)
9 o7 p1 d9 j+ u& h --vdsm-vol-uuid uuid Output vol UUID(s)2 J' p( Q* R; w0 m$ u5 k
--vdsm-vm-uuid uuid Output VM UUID
# p5 `7 C7 z2 Q4 L M --vdsm-ovf-output Output OVF file
: ^& z7 y& x# F, h7 t -v Enable debugging messages) s8 G& ^, D2 y) K" R9 J4 F
--verbose -"-6 @( L0 g" u. p, @8 B
-V Display version and exit+ y$ X2 Y) Z1 E' \0 ^- R5 k: U
--version -"-. C$ \" d2 y" L* E+ d
--vmtype server|desktop Set vmtype (for RHEV)0 {5 q. k8 v& ]# r: U9 y
-x Enable tracing of libguestfs calls
: i- c$ P! ]2 m' l |! @- ] -help Display this list of options
5 g+ X0 v( t/ S- ^( F --help Display this list of options |
|