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

楼主 |
发表于 2021-8-25 17:40:56
|
显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)
3 w# d, Q; p2 @4 h. Y6 M1、v2v迁移
+ T$ j7 c K+ C/ c& _+ Z6 M1 V#虚拟化迁移至虚拟化环境/ |. o ]# e8 L& a# ?& i L
#p2v迁移,是指物理机器迁移至虚拟化环境
2 v7 [" T9 I, d+ ~#安装v2v迁移工具:yum install -y virt-v2v: E$ x0 b7 _: G; J; ?6 r( K0 h; M! a
#
! c* R$ X6 B) r. x U3 A' c0 g2、KVM-KVM的v2v迁移9 \5 ^& Z. v# d9 u) z1 L
#KVM是采用Centos7,vm是采用oel6操作系统,始终报错
6 O; L# [: I, X4 }" ^6 @1 f$ A& c6 y- F错误信息:8 \1 X, V$ E" }$ Y$ j
qemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
% n# r) s A- O; V2 d9 mvirt-v2v: error: qemu-img command failed, see earlier errors
% y# m; B3 v# J! GIf reporting bugs, run virt-v2v with debugging enabled and include the
+ @. X1 a7 S7 P- Z#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool
/ z$ ?6 b- N7 f#node72检查 m, k+ R" z q0 I$ }
[root@node72 ~]# virsh pool-list1 G, ^/ y! h7 i5 Z* ?4 k
名称 状态 自动开始; Y# w2 \7 H5 A( u% [" M" o9 o- d
-------------------------------------------
4 @( Z7 `: [0 K! z% P J0 ^5 e: r. T iso 活动 是
8 I4 p" p7 \0 J% N* b oel1 活动 是 # j! X+ d. O- W- H. Y% }+ T$ }
vmfspool 活动 是
8 L1 M3 w! t# v# L% G. N) l) h9 F* q d) p/ T' |! S
[root@node72 ~]#
2 {) \; Z) c% d. g5 X. S#关闭需要迁移的虚拟机
6 j% J$ S' l' e* @[root@node72 ~]# virsh list --all: |, U4 i9 w s2 e7 d$ H! {5 G6 m
Id 名称 状态
/ f: ]5 o/ Z4 a2 G----------------------------------------------------1 l h7 n v. l4 z4 u0 V
7 oel4 running
; D* i5 f$ K o5 Z5 i. ^- S - oel5 关闭
- m5 u* y9 } M2 B/ C% t7 a[root@node72 ~]# virsh shutdown oel4: J( r* E$ u! n" E5 e
域 oel4 被关闭
1 W; S' J) J8 P' y[root@node72 ~]#
+ B% T) Q2 Y P* ?) B#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例- j/ E: b: v6 k
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
& A1 e3 ]5 d. G, b% z[ 0.0] Opening the source -i libvirt oel4
. q8 ?! n- x4 D$ F' f6 M. r1 s[ 0.0] Creating an overlay to protect the source from being modified0 G0 n3 l7 q" m
[ 0.0] Opening the overlay- }. Z. D2 y, |9 t" k
[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool
2 O D6 s- H: y" D! O7 mroot@192.168.2.110's password: ; g ~+ s n4 v. l
root@192.168.2.110's password:
5 l _4 G- Z* n' Sroot@192.168.2.110's password: ; I S, U7 Y+ S! Q8 \4 ?
[ 17.0] Inspecting the overlay
0 a w9 c$ n' e0 A" O8 i[ 24.0] Checking for sufficient free disk space in the guest
* B/ c; @9 f; L1 I[ 24.0] Estimating space required on target for each disk, j0 x7 q" }! E+ ?- Z0 v
[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM8 T. U. x' }9 m8 q4 Z
virt-v2v: This guest has virtio drivers installed.: }% Y& H+ I0 j: M+ I: _- }0 ?
[ 69.0] Mapping filesystem data to avoid copying unused and blank areas0 h# H! L/ z% |- @" Y
[ 69.0] Closing the overlay
! h3 i5 f6 }' Z, B, J[ 70.0] Checking if the guest needs BIOS or UEFI to boot
3 _' a R0 _6 \' u[ 70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)+ U7 N9 y4 z0 Q# ]: {% l0 g
(100.00/100%)5 D. }! o" u( o4 G
[ 82.0] Creating output metadata0 b- l( m- y; f0 t! x
root@192.168.2.110's password: 9 f7 u0 @& g9 H9 M. h/ O. c
池 vmfspool 被刷新, A B( U" u! ]4 }" n+ f7 i) }/ n
root@192.168.2.110's password:
9 `+ ^ l( |2 v3 r定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)6 C' G. h* M" s* s- c( w8 }, N
[ 107.0] Finishing off
) X8 e4 j: ~5 a- a[root@node72 ~]#
3 H2 q; I0 ^0 s# U#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)) h8 X, o8 t; P. T5 u$ r
#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,
% n2 b% W8 Z/ z, F2 }5 A8 R, O[root@node72 ~]# virsh list --all
5 `, ^5 G0 `+ B D& c& J Id 名称 状态1 R/ }* F. H' x$ y
----------------------------------------------------- u% o0 H- ?+ b4 H, p- j
- centos4 关闭% `9 r1 v2 i" |; w, n- F+ A1 e: }! d
- oel4 关闭
9 F6 Z6 u2 i% q& ^9 A - oel5 关闭
- s' [! F! s2 _; _* @- t# d$ V[root@node72 ~]#
$ {8 V: w. z S3、KVM之间的v2v迁移
u) A) t1 @: E
) {0 v( R! g; i" N#检查node71的迁移环境
( }& r- L+ Z" w- \1 y, l[root@node71 ~]# virsh pool-list
! K8 R, H# N4 @: ^5 `6 R1 ~: t 名称 状态 自动开始* R: G: F$ V" p$ {4 e$ g( _
-------------------------------------------2 w; t# Q0 O% a& n6 m( C6 n( t
iso 活动 是 7 {# y( C: ?0 x1 r) | Z& Z
vmfspool 活动 是
+ _, x) O* S+ l% p, ]' w; G; w
1 c& X! T4 b8 {2 S, H[root@node71 ~]#
4 X7 {- T* x% n! I* r; i#测试迁移,从node72迁移出来
5 i) K$ B( u0 f[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool -b br0 oel4
' o* [3 C9 B8 G$ C[ 0.0] Opening the source -i libvirt oel4
: f+ W: M- V0 m- Q( @[ 0.0] Creating an overlay to protect the source from being modified
; E Y" u1 \* d' |5 V' ~4 Q[ 0.0] Opening the overlay
) a8 m; ]. r1 s! {[ 10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool
! ^9 l+ F0 M9 h+ }& o6 F# c6 R. f+ droot@192.168.2.111's password:
) J$ {" I( L* t+ Troot@192.168.2.111's password:
, }, t& E' C P' x V4 mroot@192.168.2.111's password:
6 e9 a# @0 a7 k$ J[ 18.0] Inspecting the overlay$ E/ C+ w# I, s# `+ G. K. R
[ 24.0] Checking for sufficient free disk space in the guest$ a! ~6 B& J: V
[ 24.0] Estimating space required on target for each disk
' f+ \, t6 l( m' {[ 24.0] Converting CentOS release 6.5 (Final) to run on KVM* P% Y% m5 Z! z& o( |0 [* j0 I5 R$ E
virt-v2v: This guest has virtio drivers installed.
$ K: z- x- m" @+ P/ b[ 68.0] Mapping filesystem data to avoid copying unused and blank areas. d. g2 c) t& d( z
[ 69.0] Closing the overlay
. W$ R6 k% d& L, Y[ 69.0] Checking if the guest needs BIOS or UEFI to boot; B7 `) ^& z' _5 |& L' s
[ 69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)
- b/ t6 h# K, w) t1 J (100.00/100%)
$ I9 }* e0 ~# C# Q6 q+ [[ 80.0] Creating output metadata9 c* r. k! Z% A3 ?7 b$ ^$ V
root@192.168.2.111's password:
6 i6 o j* u8 N池 vmfspool 被刷新2 o- c4 `, P" \7 V- m, j
, }& J3 y2 `, \! v+ m, m# Nroot@192.168.2.111's password: 8 \, j \$ \( E6 d/ j
定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)- _( G9 _! e8 n, S! @
9 S. p- H+ e% Y9 U' L1 F- u[ 86.0] Finishing off X( g2 ? P0 \5 P" \, O
[root@node72 ~]#
3 @* ^- U4 Q& r# L4 c#迁移完成0 P. ^1 y: F2 @9 T6 r" k }
#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改
7 Q) T0 K: I7 f/ R# h. n[root@node71 vmfs]# virsh list --all! k) Q3 H3 o6 [( e; t( z
Id 名称 状态
7 o$ [7 k: i; r% z----------------------------------------------------7 M9 p$ P' q$ A) R9 L
- oel2 关闭
0 |, K' L! E$ y- g9 \9 ` - oel3 关闭5 c. Q3 [) T# L' f- A. D" ]
- oel4 关闭4 |! T& P) T! n- q; H& ?! E, T
[root@node71 vmfs]# 2 m2 K* Z! W& Y7 Y
#可以查看到oel4已经迁移完成: m Y4 ]! _6 p+ c( m- x, i, @
- ]0 f) L. m" k) [#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误& u; N+ u$ ~ Y7 A0 V0 Z
[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4
5 ]) y) X; u. O- [1 ~- B! ?virt-v2v: warning: no support for remote libvirt connections to '-ic
4 \8 s4 o1 Q* _$ M. gqemu+ssh://192.168.2.110/system'. The conversion may fail when it tries to % B! b0 p8 I( x- L% f" m9 \
read the source disks.- h7 d8 J3 A' a$ W. Q
[ 0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
- l/ ]' z$ M# c. d qroot@192.168.2.110's password:
7 O. S8 U; m$ b[ 2.0] Creating an overlay to protect the source from being modified3 {* R+ Z8 q% e& l4 Q0 [6 p' j
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory' S& Q. F/ l4 g) j K3 O" W; W' G- R
virt-v2v: error: qemu-img command failed, see earlier errors
: T% \5 R$ r/ \% M w8 ~8 }: K9 c u; j/ Z
If reporting bugs, run virt-v2v with debugging enabled and include the 4 e& g+ A3 [% k4 m* P- `
complete output:2 G( x! n5 W9 _
! m; U- @8 |+ Q' j virt-v2v -v -x [...]
2 e( _7 p+ N4 |, u, m8 O& u[root@node71 vmfs]#
0 ?2 S) i y j) Y7 {; L#暂时还不清楚,我们-ic一直会报"No such file or directory"
1 _! o* Q8 z1 c4 D! Y, Lvirt-v2v 命令帮助; f* D/ X$ S( Q
[root@node71 iso]# virt-v2v --help' p/ H( R: n% [7 i$ l3 w/ \
virt-v2v: convert a guest to use KVM
3 _- s v z' _7 t( w B; p& U& R* x% K1 [! d4 {
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest% U) n, d) N: E2 T, ]
; M) l) J0 ?7 a- \1 N virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm0 N8 M4 e/ k) m9 K. z8 B' l
t8 J( X& |0 C
virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
3 u$ Q4 M5 L b0 c# i! c$ J, ^6 f2 Z6 D
virt-v2v -i disk disk.img -o local -os /var/tmp$ i6 g$ R3 V* \& F- ^4 B- M/ c
& l v$ ^& m- G! w virt-v2v -i disk disk.img -o glance
7 ^3 V/ {6 `% g% q# D& |
: E& H- I9 S1 _ V7 e2 zThere is a companion front-end called "virt-p2v" which comes as an6 Y6 s3 ]! X* ?% d5 ?& l
ISO or CD image that can be booted on physical machines.7 F- I& L8 C: k! h! T
2 o6 x5 ^- ~4 f6 ]0 M- D
A short summary of the options is given below. For detailed help please
1 `2 y( |2 F: W2 U: tread the man page virt-v2v(1).. n1 Z/ f1 V" r9 P
7 b" {5 i, a: k% W3 K -b in:out Map bridge 'in' to 'out'; ]% l5 Z4 [4 W& k7 U
--bridge in:out -"-% c+ h6 @) m$ w/ L
--debug-gc Debug GC and memory allocations
, }, N5 B" l' J% _, L --dcpath path Override dcPath (for vCenter). x% H6 O) [% |' |1 p
--dcPath path -"- H- C; ]& w. u1 E/ Y& q* l% k( c
--debug-overlay Save overlay files% f4 M6 }, ]9 i% m4 r& M8 b
--debug-overlays -"-
! A' h9 o9 C" x3 N& o& m3 @2 w -i disk|libvirt|libvirtxml|ova Set input mode (default: libvirt)
" A' U; k9 q+ N/ o. k -ic uri Libvirt URI
. w0 l1 f1 Y+ k9 N/ Y -if format Input format (for -i disk)
- d d7 q' h/ o$ Z' ` --long-options List long options
0 A; D3 |: i; D: F" ]2 Z6 U --machine-readable Make output machine readable
9 j _, e! Y$ h- E -n in:out Map network 'in' to 'out'
4 W# Z9 R1 E b5 B! g --network in:out -"-7 k& v: b G; n* @$ }# R
--no-copy Just write the metadata' M) R9 R- P* h5 o9 J
--no-trim all|mp,mp,.. Don't trim selected mounts- v) o/ B0 ?2 h5 ?
-o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)
" E, e; l1 a. U$ r& e+ v4 ` -oa sparse|preallocated Set output allocation mode
3 ^# i# i& ]- `+ @" W -oc uri Libvirt URI
# q. N, X1 x' V7 `5 s5 N' A; y- K -of raw|qcow2 Set output format" Y- t5 _0 D m6 m/ C; s
-on name Rename guest when converting) E8 A% N) ?# n
-os storage Set output storage location
& R) u8 S3 X, S9 @" l* N$ ^. s --password-file file Use password from file& @. i: O4 O3 }* s. v0 `
--print-source Print source and stop/ R$ v/ l' Y; Q/ _* J
--qemu-boot This option cannot be used in RHEL( B& b. q& p6 I9 l1 F& E; G$ {4 n5 ^ ?
-q Quiet output0 }% \" \. \/ R
--quiet -"-' e% ?$ w: |* A b
--root ask|... How to choose root filesystem
0 z+ a# h2 g+ y ^' | --vdsm-image-uuid uuid Output image UUID(s)" s* W* L# q* U2 P5 }* E
--vdsm-vol-uuid uuid Output vol UUID(s)
! K+ c% ~' J# k0 }4 A1 \ --vdsm-vm-uuid uuid Output VM UUID1 e1 X6 s- P2 l! i4 v6 b, B* w
--vdsm-ovf-output Output OVF file8 |, G! F( Y5 B, j$ [
-v Enable debugging messages4 H7 z7 }. x0 A1 j9 T5 y1 h/ E
--verbose -"-! H2 B# L% E' m- ^2 e- K5 a
-V Display version and exit! L. Y, m8 |# @6 B
--version -"-5 o3 u( z& h1 b" o5 e" U3 h
--vmtype server|desktop Set vmtype (for RHEV)- g0 T. a5 _5 y5 y
-x Enable tracing of libguestfs calls5 ?4 }3 P9 N0 o$ e- Y4 ?
-help Display this list of options
( s8 y! L5 p$ H2 o! } --help Display this list of options |
|