易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 2118|回复: 1
收起左侧

p2v、v2v迁移

[复制链接]
发表于 2021-8-18 17:00:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
最近在做P2V、V2V迁移,现在将迁移问题进行总结一下
9 p& _7 g3 H" _% R, l  n7 ?物理机迁移到kvm中
2 b# \; M) r) B: f: Y, y3 C- X本次迁移所选用的系统是centos7.5,安装P2V、V2V以及virtio-win等rpm包。刻录virt-p2v2 o, [- n) h# v: L! x
镜像
, Y# @  y3 C& \2 z* d. p; y" {5 Q! b" k4 _
1、采用virt-p2v引导,界面如下virt-p2v:- A$ v/ ~" T$ N
2、物理选择Start Virt P2V可以进入SSH配置界面
5 o. I; e& x; Y/ p(1) 填写转换服务器的IP地址
) T" v, I& |6 }+ a; b2 X- x(2) 需要转换服务器上的SSH端口号。
8 ]- D+ T' \0 T. x% h7 m(3) 选择将登录哪个用户的转换操作日志,并输入他们的密码( e2 p7 c- I* _  G% h" ~2 @. {
(4) root用户密码
& f, L$ V. S  n(5) 上传私有SSH密钥文件的路径名
- s* s5 ~; r1 ~/ z9 G3、磁盘和网络配置
, n+ B- u6 \; u(1) 配置创建的guest虚拟机的名称,虚拟CPU数量和内存
5 Z' ?* T( v) M4 t# b( B+ n(2) 修改guest虚拟机的生成位置和格式- G% e8 x- }; t' @5 T
(3) 选择要转换的网络接口,可移动媒体和存储磁盘: O1 t9 j/ u+ B  _
4、开始转换界面
; Z0 h) s; {! ~' r5 H# Z1 t' V- |; s' |! z9 M! r/ B% i) K
5、 验证迁移结果
6 p9 o0 y* }9 t( Z1 g(1) 底层查看系统转换后的磁盘格式
0 r, @) |# }. [8 D0 A6 S(2) 开启虚拟机,验证系统是否正常( i$ r. A5 j& t# y' l
vmware迁移到kvm/ u! x8 W0 C9 f
使用virt-v2v工具前提条件:
7 j+ W! w+ w/ _2 |(1)Vmware已安装安装vcenter& G1 O6 x* K' v. b2 p: r" [
(2) virt-v2v相关包已经安装0 [6 f& |  r- i/ s  A5 h3 g; z
1、查看vmware虚拟机,卸载vmware tools" ?5 M( Y- G! u# @- b
如果虚拟机上安装了 VMware Tools,必须先卸载它。因为 KVM 的虚拟机不支持 VMware Tools 里面的虚拟驱动。
9 f% `" o) z7 F4 C1 @2、 关闭虚拟机
! a, ^) W/ J* p4 L1 E) |# L7 A5 ^+ L  }3、测试vmware连通性
. i8 P; ^9 w$ v+ _( m5 S4、vmware迁移
& c7 g3 ]% E) x+ \# X0 ivirt-v2v -v -x -ic vpx://DOMAIN%5cuser@vCenterIP_NAME/DadacenterIP_NAME/ClusterIP_NAME/HostIP_NAME/?no_verify=1 -o libvirt -os <pool> -b[虚拟网络] <vm名称>7 L+ v5 a: U5 T0 D
如果用户名使用的是域账户(domain\name)或者虚机名中包含有反斜线,则反斜线需要转码特殊标示,使用“%5c”代替“\”" B4 k6 E) p8 o$ }
输入vcenter密码
0 J% \' K7 F% }( ?/ s- W3 g输入vcenter密码
9 Y8 Y, q& l- m7 C输入vcenter密码
( ^1 h5 w( P& e% ~输入vcenter密码8 ?0 L: D9 o: t# \$ L0 x. k
输入vcenter密码# G5 Q6 i  J) y. J6 `1 u
开始迁移,并转换磁盘格式为qcow2
$ V/ I% L- L* P; ?" D7 S迁移完成) u) n0 i$ Z% @& _
5、验证
6 Y- c, k9 a% Y/ ?3 Y  V2 A' Y! u. c  C* K3 G! h) p

* S! Z3 @: G# |" r4 O& x0 r
p2v启动界面.png
p2v启动界面.png
p2v加载系统配置.png
p2v配置界面.png
 楼主| 发表于 2021-8-25 17:40:56 | 显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)* L5 S2 ]7 D' R1 l
1、v2v迁移
3 s' C) h6 x% M. e) W- B#虚拟化迁移至虚拟化环境) ^( t; L* l2 `. ~! n
#p2v迁移,是指物理机器迁移至虚拟化环境
6 o  J, ^" o5 M6 m#安装v2v迁移工具:yum install -y virt-v2v0 w3 a/ [' _; ~$ g
#  S3 b4 f. O1 I5 ]3 s
2、KVM-KVM的v2v迁移
+ D; F  n8 X+ O! L+ z: w#KVM是采用Centos7,vm是采用oel6操作系统,始终报错1 h; |0 j1 |0 o- n7 K/ e
错误信息:
2 i8 X( ~- D; ]( K! j6 e) Fqemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
; [. P: ^% y) b" ]  Tvirt-v2v: error: qemu-img command failed, see earlier errors
! H+ J5 Z, Z8 c9 C, w( }+ YIf reporting bugs, run virt-v2v with debugging enabled and include the / q! h& a8 `+ {# Q4 S8 W
#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool, k- X2 _8 Q6 n- v+ T+ r2 \
#node72检查( ]: h$ v+ J+ q6 l: u; s4 g
[root@node72 ~]# virsh pool-list5 I: ?# u$ k5 _
名称               状态     自动开始. N' ~" J% Y3 V' A  Y
-------------------------------------------
- t3 o4 q3 y/ U. C iso                  活动     是      
; i9 O8 T' [5 ^) l oel1                 活动     是       4 o! N/ D' B( v8 T
vmfspool             活动     是      
1 U4 s8 x0 X1 P
  q4 l- [* z3 |0 {[root@node72 ~]# ! I, Z& p& T5 j+ @5 ~
#关闭需要迁移的虚拟机0 P& n4 E$ c. J3 L0 `4 [
[root@node72 ~]# virsh list --all2 K* f, V6 H% X6 v0 Z
Id    名称                         状态: P0 l, C& ?, M; v6 q
----------------------------------------------------
7 [7 Q' s+ V' A2 p 7     oel4                           running* `' H" K+ J" q& ~$ z/ e! M5 x, }$ N
-     oel5                           关闭
& v' s6 s; [1 M, t. r" D  w5 Z  x[root@node72 ~]# virsh shutdown oel42 Q* k3 Q$ _2 p. E, X# C) A( f
域 oel4 被关闭* J3 s4 D* _2 x$ U- I
[root@node72 ~]#: B+ z( o9 L- }- |5 Q
#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例
. k) e5 V# R+ m' P9 [3 m- Q[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4, L3 \! F3 t  k0 R/ L) Q8 U
[   0.0] Opening the source -i libvirt oel4$ n! t: c: f' d9 O+ v. J
[   0.0] Creating an overlay to protect the source from being modified& x; c* B3 O. N/ o( Y1 B
[   0.0] Opening the overlay
- K  F" D- M4 J8 t1 c[  10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool
) W6 Z) {# e0 ]% q3 T6 Lroot@192.168.2.110's password: 5 m8 l3 ]% K7 ]5 _: N/ v, ]4 U2 n
root@192.168.2.110's password: 6 w4 h) Y  G7 s; e
root@192.168.2.110's password: - G1 Q7 F4 i2 \* B6 t$ r* x
[  17.0] Inspecting the overlay
( r- L$ W1 k' _) K; q[  24.0] Checking for sufficient free disk space in the guest+ F: ?7 H6 I! o* `, q& X
[  24.0] Estimating space required on target for each disk
2 v4 j) C6 s& m, |6 [. q; U[  24.0] Converting CentOS release 6.5 (Final) to run on KVM/ f! Z9 C+ }/ b) h
virt-v2v: This guest has virtio drivers installed.
+ h3 ?' f9 R0 p& i. i& x: x( Y' j" @[  69.0] Mapping filesystem data to avoid copying unused and blank areas3 }% s. L: x! C
[  69.0] Closing the overlay+ c4 ~, i( O& D" P9 \3 D5 p
[  70.0] Checking if the guest needs BIOS or UEFI to boot8 n# Z3 w, ~6 o/ a6 l. Q# E1 b
[  70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)
( _6 U3 V, w4 D& L* \( z( ^    (100.00/100%)
: x) L4 b- [- i$ n& z7 x/ c& S[  82.0] Creating output metadata* _5 ^" ~2 r, ~
root@192.168.2.110's password:
. F2 O8 K; G: ]. z池 vmfspool 被刷新  v& J+ J1 P3 ^- S  L$ G+ O- a" U
root@192.168.2.110's password:
3 L( _5 w* J) s& H+ N, Y! z定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml)
7 M! A2 D- s0 A! a[ 107.0] Finishing off5 D; _0 S8 o' G- {+ y4 ?1 o
[root@node72 ~]#
8 ]/ w' A+ @; E" `( j3 s2 W#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)% e  p1 a! a, x, c: _' ~! P
#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,) ?6 f  z9 r" b0 b
[root@node72 ~]# virsh list --all
6 F0 c0 {2 t9 L: m Id    名称                         状态
" F8 w5 k) ~: x* O----------------------------------------------------4 [! Z, d; y8 p4 y/ w
-     centos4                        关闭" \& j7 A3 D8 ?: M, L
-     oel4                           关闭2 M. _+ G8 D( M1 f' K( o$ i  i% U( X
-     oel5                           关闭: ^" B3 G$ s$ X0 K: W! ^) |
[root@node72 ~]#! H. Z% g5 m- b2 H( h& h; N
3、KVM之间的v2v迁移- i6 }- M% ?5 H, l8 r

9 N) y6 Q) n! f#检查node71的迁移环境
& d$ U8 }, T! |) Z! g; V  d, e[root@node71 ~]# virsh pool-list
8 G" j: G  ]" N" y6 M7 A 名称               状态     自动开始7 h) B0 ~7 l2 `( t6 ]/ i# Q1 ?. B
-------------------------------------------7 e- O8 W) ?9 v! n
iso                  活动     是      
; d( w2 Y6 s  t0 ?1 B1 v* F vmfspool             活动     是      
7 q$ p/ J3 s5 u$ _# O
/ d1 @! i% S4 P5 n' G[root@node71 ~]#
- n; E# i% T6 l, c2 x2 w#测试迁移,从node72迁移出来
+ ^7 f" [: o- r* x' b4 y, g' [& j[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool  -b br0 oel4
3 t+ N7 ^: K7 \9 ?! Y[   0.0] Opening the source -i libvirt oel4
, Z; a" l3 r( V' m, c[   0.0] Creating an overlay to protect the source from being modified
/ Q# t0 M% l3 v+ A$ h[   0.0] Opening the overlay/ W. D8 S: j! ~( {: }6 E
[  10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool: C. B- s( |5 _3 }* ]; l8 N0 f, ~+ m3 J
root@192.168.2.111's password:
( T$ b; u: A2 D2 p+ D  B2 zroot@192.168.2.111's password:
4 m2 }* j* J; Y; xroot@192.168.2.111's password:
" C" @. l( y# d: q; v/ e7 G3 h% n* c[  18.0] Inspecting the overlay! g0 d. `9 I3 ~! l# T. z
[  24.0] Checking for sufficient free disk space in the guest( v' o3 V! }- F( ?8 S
[  24.0] Estimating space required on target for each disk
* A) m  @1 T2 `; z[  24.0] Converting CentOS release 6.5 (Final) to run on KVM2 L& f9 Y  |" @: k2 r. w0 M7 y
virt-v2v: This guest has virtio drivers installed.
# n: y  I: B- A$ s  [9 @9 {5 c[  68.0] Mapping filesystem data to avoid copying unused and blank areas+ y1 E' F, I& s
[  69.0] Closing the overlay
% [* F+ x& [- n[  69.0] Checking if the guest needs BIOS or UEFI to boot) g: }6 i' x* @
[  69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)! ]6 }) s2 j& c/ ^
    (100.00/100%)0 [( q: b; ^; M$ X( f% J" z
[  80.0] Creating output metadata; `/ O7 v' F/ W2 k
root@192.168.2.111's password:
2 F3 `5 R0 J9 H% |4 f8 r0 g: N9 c池 vmfspool 被刷新
: H) a( I6 k2 A% \; n  u' z# D3 F% `8 [4 M8 f# M
root@192.168.2.111's password:
% [5 S8 h( G& R8 j+ N定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)* T7 R8 _# F. ?! v$ ]$ L5 U9 ]2 H) C

# \, A$ q; ~" W0 A[  86.0] Finishing off
" Y; E8 N9 g! O- D' \[root@node72 ~]# # I0 P- l) e; F  W8 D% D+ O
#迁移完成
, w, S& }  m6 a* K) C; G! y#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改
6 P- U& D9 I8 h' F# M# W; `9 U[root@node71 vmfs]# virsh list --all
/ |& k, y0 ?/ r, b$ J  J& B Id    名称                         状态
( F" Z  p: m. @; U# U1 H----------------------------------------------------) K: B2 r& T+ [) q* ~
-     oel2                           关闭2 ?2 g, g1 l6 U* g& @
-     oel3                           关闭! V* V9 ~* j# r$ k9 C2 X
-     oel4                           关闭* J" U! p/ H( r
[root@node71 vmfs]#
% e/ X9 W; `  Y8 o; i' T#可以查看到oel4已经迁移完成
% {3 @4 l7 Y* U, D
' g9 a5 |( K- l#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误; O/ _# `' H- x8 y
[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel48 j6 L, t3 p! z1 D) E' i$ g
virt-v2v: warning: no support for remote libvirt connections to '-ic $ ^. h0 B% R+ C: ?4 v/ x
qemu+ssh://192.168.2.110/system'.  The conversion may fail when it tries to / O' ]3 F, J+ U( g+ @
read the source disks.
; W4 p" c4 b" I1 f$ E, {. C[   0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
+ T  g, V" \+ c6 v9 r1 broot@192.168.2.110's password: + f( c: {7 M' L1 k6 d/ s
[   2.0] Creating an overlay to protect the source from being modified% F# m  a1 T, S" [8 D& l
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory0 J0 d, U8 w4 X/ O2 q: K
virt-v2v: error: qemu-img command failed, see earlier errors* }- T0 V4 j8 P9 v# K
. d; D0 M" ~' E! S" t' h6 f+ m
If reporting bugs, run virt-v2v with debugging enabled and include the ( o1 w& L; ~' f9 w( M* `
complete output:1 p4 C% w0 g0 v2 j+ g

! K! g; k" o8 H& o. w  virt-v2v -v -x [...]- q' N; }* `5 \1 a7 R5 O/ I! q: D
[root@node71 vmfs]#
/ U8 o, Z  ]( d  W#暂时还不清楚,我们-ic一直会报"No such file or directory"! U4 E$ O' ?& O% M
virt-v2v 命令帮助/ E1 p' D6 a) ]0 W
[root@node71 iso]# virt-v2v --help
7 i9 m9 u3 m: I, Q$ b. X" \& fvirt-v2v: convert a guest to use KVM
( g% @3 z) ~# [7 H
7 ^/ c% z" z0 i9 I+ o! Z! k virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest
; ], B& J) A0 K5 ]/ K% O- Y1 c' X& u2 a0 }8 V7 e3 s# t4 u! y# C
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm) ?' \- ]0 |) F" S- x& ~  I0 M8 d
# V2 V( L; o: d2 \3 B( a
virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp9 I' o' W! c- l3 g/ i: P" Y/ ]

. i  i$ [1 P# f; n virt-v2v -i disk disk.img -o local -os /var/tmp
7 r# h" r% d' [. E. u: {+ b. \
7 }; e0 E7 |& j8 R( j virt-v2v -i disk disk.img -o glance
- J- z( o: ?8 m: g+ D6 F6 q) ?# Y# Y& O/ f9 d- M# K6 p
There is a companion front-end called "virt-p2v" which comes as an
! A6 h( T9 W$ G( B( I9 QISO or CD image that can be booted on physical machines.7 _  }" F+ t* Q9 S+ M) o
- H8 F' W6 m  l) _
A short summary of the options is given below.  For detailed help please
) I  W9 ]4 i. x% e# N# Lread the man page virt-v2v(1).& q! `. i; T. K3 Z; W4 ^

  K" m& n& y% N+ ~1 p2 B  -b in:out                                   Map bridge 'in' to 'out'
; ~) l4 W2 W& n  --bridge in:out                             -"-3 d: J9 s2 c8 q) L( i1 i
  --debug-gc                                  Debug GC and memory allocations
& {- N* |# b1 O3 y" ~7 h4 r  --dcpath path                               Override dcPath (for vCenter)1 y* N* u4 h* J  q& o
  --dcPath path                               -"-; A# g) l2 @1 a8 J& [! A
  --debug-overlay                             Save overlay files
' k5 k4 Y* t0 a* D  --debug-overlays                            -"-% b/ O# L$ N0 K; ?
  -i disk|libvirt|libvirtxml|ova              Set input mode (default: libvirt)) ]9 d) @0 u% j6 n! a
  -ic uri                                     Libvirt URI
& o. A) q2 J1 G  -if format                                  Input format (for -i disk)
7 j9 n1 ~1 ]  a8 W  g8 ~' n1 H; d& I  --long-options                              List long options
- c4 ?; M7 N- B4 g2 F( D' |  --machine-readable                          Make output machine readable+ b& ~  X0 `& Z2 I  H# V
  -n in:out                                   Map network 'in' to 'out'
( c. i* V0 n( k0 v) j  _& Q0 d  --network in:out                            -"-7 ]6 O6 ]' d# K- }% ?# c# z, W9 ?; K
  --no-copy                                   Just write the metadata1 v2 l( r9 m1 O( V
  --no-trim all|mp,mp,..                      Don't trim selected mounts% J7 `' S- R, {0 \8 `
  -o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)- P, a" p+ \2 Y# D  A6 V4 v9 m! e& r
  -oa sparse|preallocated                     Set output allocation mode
- k* h/ {8 x3 j7 U* E  -oc uri                                     Libvirt URI
0 u1 M0 v& F# q$ K4 s  -of raw|qcow2                               Set output format
7 G$ |8 E5 s* M6 w/ c  -on name                                    Rename guest when converting
8 Z* ?3 c$ J6 S) k1 |7 i2 D% Z* j  -os storage                                 Set output storage location2 d' b7 w0 o5 B, x# ~
  --password-file file                        Use password from file
7 i5 g9 P% p* v7 P5 N  --print-source                              Print source and stop
+ ~) L5 u8 X4 a' r  --qemu-boot                                 This option cannot be used in RHEL
4 f, o* J% ?3 N9 b! E  -q                                          Quiet output
; H3 K, O9 i# k  |# h1 ^  --quiet                                     -"-
+ y/ {, ?/ D, r) O/ v; H# _  --root ask|...                              How to choose root filesystem$ l0 {6 F3 ]( _. w& X% I, H" }* V
  --vdsm-image-uuid uuid                      Output image UUID(s)6 |, u) K/ h( j
  --vdsm-vol-uuid uuid                        Output vol UUID(s)
! U2 @0 l" D' B: M  --vdsm-vm-uuid uuid                         Output VM UUID# W3 [, N8 [8 [) K
  --vdsm-ovf-output                           Output OVF file4 c! u' n  y3 T: u8 w- s
  -v                                          Enable debugging messages3 c2 d- V4 _+ E( ^* |; b
  --verbose                                   -"-: O+ f5 ?# b- Q2 j. W4 r+ L
  -V                                          Display version and exit
' b' D7 O0 M' |9 ?, M: f  --version                                   -"-1 I$ o: {5 H8 D& [
  --vmtype server|desktop                     Set vmtype (for RHEV)
( B, h' f9 W6 s! J  -x                                          Enable tracing of libguestfs calls
4 j  M9 L; X% o/ s; B  -help                                       Display this list of options! |  ^# a0 _6 T7 i$ t8 I* T$ v
  --help                                      Display this list of options
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 17:19 , Processed in 0.049184 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表