|
|
楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)
2 j0 ?+ \# w% \( i6 @6 _1、v2v迁移6 H8 d( p, e$ R' t! r/ ]
#虚拟化迁移至虚拟化环境+ \1 m! w2 B5 X6 Z" h4 S
#p2v迁移,是指物理机器迁移至虚拟化环境
0 n! l t( }" h#安装v2v迁移工具:yum install -y virt-v2v4 l0 B1 u' M, U& O
#
; y8 V- J A8 H8 ^" Q$ i3 W: u2、KVM-KVM的v2v迁移
& a) X8 b) I1 X D9 @" N#KVM是采用Centos7,vm是采用oel6操作系统,始终报错2 A9 _- ?3 e* ^: [1 ]' R) r
错误信息:
& \3 {- c U T& Pqemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
/ U1 }2 |3 [! s# y% Svirt-v2v: error: qemu-img command failed, see earlier errors: Q5 T* R- z% ~" [7 w4 U5 H
If reporting bugs, run virt-v2v with debugging enabled and include the 4 u N7 @$ i, O9 u/ e- `9 b
#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool; `( C6 E* m5 [3 i8 ~# J% M& U0 f
#node72检查
B- ]8 H- G2 i$ q# k: X[root@node72 ~]# virsh pool-list; S. V D+ q) ?2 H) ~! ~. c
名称 状态 自动开始
# I. [) A7 f: ~3 P-------------------------------------------
+ D6 z, `3 ^' Y iso 活动 是 ! ^+ t, |. V% @5 f' b! F
oel1 活动 是
6 P8 d$ [* c8 ?3 h( H9 B vmfspool 活动 是
# g( t) s" [1 X; x/ a# `4 P, ~& a5 {/ A2 Y2 i
[root@node72 ~]# & m( k2 J( E2 |4 I2 l' Q* I
#关闭需要迁移的虚拟机- R# E' P: R0 \- l: e# K5 a
[root@node72 ~]# virsh list --all
! L% q% \* N3 R- p Id 名称 状态) l1 p$ y7 X! U
----------------------------------------------------+ ^5 \& V! k( [' u8 {
7 oel4 running. O; R2 {, U; [
- oel5 关闭
. Z' y; [+ r0 f: A[root@node72 ~]# virsh shutdown oel41 [/ k6 g/ `7 X2 w+ \$ a
域 oel4 被关闭8 w/ `3 o; q' U4 o/ }; x1 G
[root@node72 ~]#9 R, R0 D1 F. Q) q" f' T9 l
#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例) d) F1 F, J- z1 E
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
) ?. h9 L8 q& l! Z[ 0.0] Opening the source -i libvirt oel4
5 d: ?( K) u7 }9 }& H[ 0.0] Creating an overlay to protect the source from being modified
O; S0 q3 N4 h[ 0.0] Opening the overlay# l! N' |) I- ~. `6 e0 m) I
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool' ~, a- m0 v0 N& S K
root@192.168.2.110's password:
3 N4 y3 l" o! \& L, jroot@192.168.2.110's password: / T9 d. c* z0 ]) ^. @$ L
root@192.168.2.110's password:
7 w) P7 o2 u$ g; g0 K5 x" S% \[ 17.0] Inspecting the overlay
% a! ?- c- L6 v4 U( M[ 24.0] Checking for sufficient free disk space in the guest
: W5 @$ _8 m2 a0 m; N: Y[ 24.0] Estimating space required on target for each disk
8 H: x" h" \3 w. j! v[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
! b4 w% r: W5 i6 |' N7 Rvirt-v2v: This guest has virtio drivers installed., N; ?2 w9 @5 n9 Q7 @/ p7 ]
[ 69.0] Mapping filesystem data to avoid copying unused and blank areas" ^! M& @7 D3 {+ l9 C
[ 69.0] Closing the overlay: ]- @7 m, G/ }/ G/ e! {
[ 70.0] Checking if the guest needs BIOS or UEFI to boot ~: }, x$ c) ~% o p: f0 n
[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)
; E2 I- J) z0 H0 J: X3 U. }1 r9 K (100.00/100%)
: g( z* v/ _% y& P* `/ `" G/ @[ 82.0] Creating output metadata
5 b4 x/ G" e% aroot@192.168.2.110's password: 8 o. P# m3 H4 Q, D0 T# S* H) Z/ E
池 vmfspool 被刷新
% C0 M `( o8 e4 B* froot@192.168.2.110's password: & ?/ K( n! a" t& d2 M$ L
定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)3 s/ G2 b% {: _' q& S6 E, m6 H
[ 107.0] Finishing off9 D b& ^* F1 Y$ b2 O
[root@node72 ~]#
6 B( f0 Q& H/ w# x/ K$ |#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)
2 h4 O! z1 s( f# g# C#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,
7 s8 e7 G( }0 @8 e: t9 |$ k; m ][root@node72 ~]# virsh list --all
1 Z/ B$ |$ y7 n9 n% x; x* Q! u Id 名称 状态
3 H- |% J7 t6 m+ ^2 `' v: [----------------------------------------------------
/ i. f6 {0 G4 T8 F2 g: \ - centos4 关闭# P! u* j) ~) R( u; |; s
- oel4 关闭
# Y# ]0 [0 q* g8 ^! N - oel5 关闭
' ~; o0 ^( e' G* i) @) _[root@node72 ~]#( }- {# m6 j! ?' f6 [3 `8 @& s
3、KVM之间的v2v迁移. d6 B" o' m! H7 K( O9 M& t
: T% A0 X9 j( q5 [% N
#检查node71的迁移环境
2 C" ^$ S. m) t[root@node71 ~]# virsh pool-list2 f% _, n+ t8 v% I. P3 r" D, F
名称 状态 自动开始7 t. I* z9 o/ @( d5 c
-------------------------------------------
/ u0 U% C/ }/ m iso 活动 是
9 h4 m+ J" n- M vmfspool 活动 是
& d2 i- ?4 F F$ Z) o2 D& d# O) B/ w; F
[root@node71 ~]# , b0 x7 }2 l' x$ _
#测试迁移,从node72迁移出来* C. C8 J+ t/ C1 x' o1 f( Y+ ?
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4/ p! D% E k" f
[ 0.0] Opening the source -i libvirt oel4
1 ^9 c" K+ a) o* S3 A[ 0.0] Creating an overlay to protect the source from being modified9 {& h8 N, l0 N. y' k
[ 0.0] Opening the overlay
: w* _! R8 ?6 s" A& F% ^[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool
/ S7 W ^- Y1 _7 w! Hroot@192.168.2.111's password:
3 ^* x, }1 E2 Croot@192.168.2.111's password: 3 z& U& v3 i# W* E2 Z F
root@192.168.2.111's password: # e) ]9 s2 l t9 n, m' B% [( X
[ 18.0] Inspecting the overlay
, V. [+ M" v: J' S9 F5 A; e0 f[ 24.0] Checking for sufficient free disk space in the guest
+ M X9 z& p1 E0 ?/ a[ 24.0] Estimating space required on target for each disk
) O' c& N) n8 K8 Y2 \. J% S+ l9 L[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM
* I. M ]) n4 J1 m9 a6 v" d' ^( n' {virt-v2v: This guest has virtio drivers installed.4 s, Z6 m9 q$ f% j" j
[ 68.0] Mapping filesystem data to avoid copying unused and blank areas+ V/ `4 `* @# j+ o. P# D, u
[ 69.0] Closing the overlay6 |* z F8 [( g; A' @+ g
[ 69.0] Checking if the guest needs BIOS or UEFI to boot, r" u+ L# I0 L
[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)
2 ^: P' N' o$ r; M2 m1 D (100.00/100%)
: @+ F* @5 B* w* K; g[ 80.0] Creating output metadata9 ^4 e8 j5 V2 c" ?9 m
root@192.168.2.111's password:
1 d8 W$ `: W8 U6 t7 O6 J池 vmfspool 被刷新. \! A0 f, \9 I5 V
3 w7 c7 n$ W1 @/ {2 { Broot@192.168.2.111's password: - s4 q4 U2 p1 j2 }9 U# v
定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)
" {5 @( A0 i. y3 O% H9 i6 d' j4 W8 f+ Q
[ 86.0] Finishing off
: @' s' w* d G" `7 ^# g7 `# `[root@node72 ~]# 4 K, O% v6 e/ a3 @" v- v
#迁移完成
; z! L) t6 _+ X8 U#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改+ v' y. H/ Y2 M5 i3 g
[root@node71 vmfs]# virsh list --all3 o0 a I8 T. K L$ q: {
Id 名称 状态
; H6 q. N( _8 P$ x----------------------------------------------------9 P. D5 V2 j0 Q# ^7 l' j4 L& Z" A
- oel2 关闭
+ Z6 ]0 w5 ?7 E: P6 z. _ - oel3 关闭
9 m/ [8 W' x# }) D1 s Q7 C$ a - oel4 关闭
1 T0 e6 ^+ n. Y7 F[root@node71 vmfs]# - y- [. x |% l2 |0 O' J( c/ ]
#可以查看到oel4已经迁移完成" r6 \5 Z+ S1 k. i: _) \# K
8 O/ B( n% `, F- \! T
#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误! S( E( S y$ N6 a9 r/ Y
[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4
z+ Y, ?/ ^7 k+ C- Tvirt-v2v: warning: no support for remote libvirt connections to '-ic
* G( m9 }6 e& W$ e9 P6 ^/ w; Pqemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to 6 c, I8 T, d: V4 {) M
read the source disks. Y% K- ]. K7 d5 T/ j$ `
[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
8 ^4 z8 U( y& c) z xroot@192.168.2.110's password:
1 K% d# d }) |9 w, J; w[ 2.0] Creating an overlay to protect the source from being modified" D3 i G. L/ C
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory
- F. E* K" h9 |, S! o7 wvirt-v2v: error: qemu-img command failed, see earlier errors$ q/ q% j, [2 S0 C
* {# w% h' @# F: ?- b
If reporting bugs, run virt-v2v with debugging enabled and include the
?$ C1 C9 H% d" dcomplete output:7 P5 N$ U- n) J* O' d
# \+ [( V A5 B9 C9 z, o virt-v2v -v -x [...]
" ]. [# D% J6 E! p1 a& @+ [[root@node71 vmfs]# ! d7 g7 b. W0 }1 @4 }% x; f" g
#暂时还不清楚,我们-ic一直会报"No such file or directory"
1 f, S0 u, a2 s. f+ r9 @3 Y/ m. lvirt-v2v 命令帮助
1 f3 M3 I8 r2 t( [' [' s2 H[root@node71 iso]# virt-v2v --help$ U% E7 h+ t/ t+ g; G
virt-v2v: convert a guest to use KVM
1 g/ _ [6 m) U [; e0 {# X% {) K* `; z. k3 c0 V7 F e
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest1 x7 u0 R" I7 e8 u
0 X+ a, i p3 d6 |
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm
8 g' h$ N c- }0 v) ]5 N9 E* A$ A1 q
- y+ L+ r3 _- {( _* m; @ virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp* G/ V* w: k" ^5 F+ b8 a
' A2 T) L& B0 \4 o+ h* @% O. | virt-v2v -i disk disk.img -o local -os /var/tmp/ v- b h2 t' s$ O
: R8 K7 j6 \( X, V- K virt-v2v -i disk disk.img -o glance
, a) B; G* s) t2 g9 Q" R3 d) ]. K, y% L% v1 |7 q n: R6 g: T
There is a companion front-end called "virt-p2v" which comes as an% g+ ^% K7 a% e- f* V
ISO or CD image that can be booted on physical machines.
" ~' H, D; x7 Q" ^( d6 |7 t7 y
1 T* L# I8 s+ x- b$ d3 LA short summary of the options is given below. For detailed help please
: v3 e) |) n* T) i3 rread the man page virt-v2v(1).8 Z9 ~' X, S; i% z# p. b6 F
% h9 q( h2 R! F) S5 O
-b in:out Map bridge 'in' to 'out'
3 e, a( `9 M: B3 T --bridge in:out -"-! a) V8 z {; k; ^
--debug-gc Debug GC and memory allocations
" [" w6 z" Y5 \) O9 N9 x --dcpath path Override dcPath (for vCenter), y# n+ w3 i4 A5 s& T& z6 c
--dcPath path -"-
' ^9 H! E$ Q3 M --debug-overlay Save overlay files8 |- H% L u0 N" V/ V
--debug-overlays -"-. f, q5 O$ ]6 J. Q
-i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)) Y" v/ L2 @/ e( g
-ic uri Libvirt URI3 N$ C7 @4 A1 n3 g4 R$ d
-if format Input format (for -i disk)& m$ I7 k8 K1 D @( g
--long-options List long options
, L- `6 E( `# [ z, r+ } --machine-readable Make output machine readable
4 Q; L, U3 [9 A% a l; T -n in:out Map network 'in' to 'out'
5 W- t2 J% f$ _( E8 m D --network in:out -"-3 S# p8 V/ Z2 M5 g, U
--no-copy Just write the metadata+ j- [# f% M7 l; e( q7 P7 U
--no-trim all|mp,mp,.. Don't trim selected mounts
& z# G! [7 A& J1 h T! g* Y q -o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)
: W4 _* a5 M. s% A6 f6 A -oa sparse|preallocated Set output allocation mode R) m9 R, q, f C* G# E A
-oc uri Libvirt URI
8 a+ ~+ \1 |. |$ k2 H4 y- a3 C -of raw|qcow2 Set output format+ E' F7 _9 u* P6 B$ Q g
-on name Rename guest when converting. l+ `8 Z! o+ P
-os storage Set output storage location9 `! o7 z$ V& Q
--password-file file Use password from file4 ~" p8 K; [" y' m& ~" ~
--print-source Print source and stop8 |+ V% c6 Q9 p
--qemu-boot This option cannot be used in RHEL
/ U- F% l6 u0 a; W( I' o6 v3 e -q Quiet output1 a- I. G+ v: h3 P! a4 Y, L5 l
--quiet -"-
/ e5 U8 S& h( }% q" p+ r% K( N% } --root ask|... How to choose root filesystem
9 y+ x# Z6 }' a --vdsm-image-uuid uuid Output image UUID(s)3 _- f- U8 d+ t- V2 W, v
--vdsm-vol-uuid uuid Output vol UUID(s)3 g9 ?% ^; Q, y. ]
--vdsm-vm-uuid uuid Output VM UUID; h% E* g2 S3 a$ m- x
--vdsm-ovf-output Output OVF file
4 J* Q2 V+ v) Q; U8 c -v Enable debugging messages
1 q3 }2 @" i0 j5 Q --verbose -"-
+ `6 u7 Z0 {1 D O3 w: ^1 {0 T$ K -V Display version and exit& @( E1 O+ {- \3 U7 w8 e ]6 H
--version -"-
) m3 B) n% j, _ q; W8 } --vmtype server|desktop Set vmtype (for RHEV)
. ^" ?. S8 S2 i" B3 R+ M -x Enable tracing of libguestfs calls
% r8 _# F9 R. ?& p6 N5 s -help Display this list of options6 F. J, d: H1 ^9 h
--help Display this list of options |
|