易陆发现互联网技术论坛

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

p2v、v2v迁移

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

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

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

x
最近在做P2V、V2V迁移,现在将迁移问题进行总结一下- w- Q) H' V) k! r  \, t$ @; \5 u
物理机迁移到kvm中  i) C+ y- ]0 r; P
本次迁移所选用的系统是centos7.5,安装P2V、V2V以及virtio-win等rpm包。刻录virt-p2v8 @1 P  a3 t- U4 G# K9 |
镜像
9 D9 l8 R+ _7 V- `; u
( t+ M: J& b% j$ Z1、采用virt-p2v引导,界面如下virt-p2v:
4 Q5 U0 e9 ]1 @0 D+ {2、物理选择Start Virt P2V可以进入SSH配置界面7 Q7 X& _& D, y" ]; p* w) x
(1) 填写转换服务器的IP地址7 a3 }6 P) L. c) t; c
(2) 需要转换服务器上的SSH端口号。
1 ]9 C. H8 o  F# y  V(3) 选择将登录哪个用户的转换操作日志,并输入他们的密码; R  C0 D9 @0 m$ p/ o
(4) root用户密码
, K5 n5 {  T2 _) w  i9 h(5) 上传私有SSH密钥文件的路径名% N( j' a: E6 i# E: ?
3、磁盘和网络配置
( Z3 \5 W! W2 j7 }(1) 配置创建的guest虚拟机的名称,虚拟CPU数量和内存
/ D) }1 ^( f5 y- s(2) 修改guest虚拟机的生成位置和格式2 s( R+ X2 s8 i+ E" F" o. v3 u; A
(3) 选择要转换的网络接口,可移动媒体和存储磁盘
5 g- N. Y; w, \9 d% i* |4 I4、开始转换界面
+ W! X, B3 K$ x- `3 f
7 s% T2 G4 C& ~" H# K- |9 o) f& B! M2 M5、 验证迁移结果
4 q1 t5 H2 [- [  x(1) 底层查看系统转换后的磁盘格式
) c: i0 {/ ?9 Q! m  F(2) 开启虚拟机,验证系统是否正常
% I( z. G& f' a* gvmware迁移到kvm
' _( ~+ N  B+ k5 t1 o使用virt-v2v工具前提条件:
0 T+ D( j1 j" h6 w* c# {/ E# {8 N8 D(1)Vmware已安装安装vcenter
, p0 i2 b) K( C(2) virt-v2v相关包已经安装4 P: C& R4 v3 M+ C8 t1 O  o9 y
1、查看vmware虚拟机,卸载vmware tools1 d7 C8 Z% |, U; b# {- {) w
如果虚拟机上安装了 VMware Tools,必须先卸载它。因为 KVM 的虚拟机不支持 VMware Tools 里面的虚拟驱动。
$ y* O7 g( U8 f. {) J5 U' l* C" O2、 关闭虚拟机: d5 i! g2 e' L; Q3 a
3、测试vmware连通性
, c: i" C8 S. m4、vmware迁移
4 e1 X4 |/ s7 D1 avirt-v2v -v -x -ic vpx://DOMAIN%5cuser@vCenterIP_NAME/DadacenterIP_NAME/ClusterIP_NAME/HostIP_NAME/?no_verify=1 -o libvirt -os <pool> -b[虚拟网络] <vm名称>3 E" V- a8 H7 R. E) A; l% x) G* f
如果用户名使用的是域账户(domain\name)或者虚机名中包含有反斜线,则反斜线需要转码特殊标示,使用“%5c”代替“\”# N- B+ D% e2 F2 }
输入vcenter密码
) p/ t* W0 S0 N$ b输入vcenter密码
& |* }! J# z6 ^4 m& E9 n输入vcenter密码) _- v: y! J$ z, _* K. h4 o; g7 H
输入vcenter密码
9 S9 R6 {1 o8 l! d6 d输入vcenter密码$ a  v7 P9 J' C2 j* z
开始迁移,并转换磁盘格式为qcow2
) E4 e) [2 B! \* C, U迁移完成
% j7 S! ~' J$ i5、验证
  c/ G0 S- A0 k( w+ Q
! H/ x0 n- N" a8 X9 h: G$ n; a
p2v启动界面.png
p2v启动界面.png
p2v加载系统配置.png
p2v配置界面.png
 楼主| 发表于 2021-8-25 17:40:56 | 显示全部楼层
Centos7 Kvm v2v迁移(都是在vm环境下,实验后面没有实现)
; D' i4 @$ G  R5 H1、v2v迁移' S' G  d6 Y9 y$ J; A
#虚拟化迁移至虚拟化环境
: b' @  k6 T: D+ |' K2 b# A#p2v迁移,是指物理机器迁移至虚拟化环境% ~8 w. [# L7 ~; t* Z1 B8 b' K
#安装v2v迁移工具:yum install -y virt-v2v
: z" C$ S2 j) j3 N0 O* p#
4 W& y- O) w" b" }4 O/ a# w2、KVM-KVM的v2v迁移* `: K# ~% e! H/ H5 G3 ~
#KVM是采用Centos7,vm是采用oel6操作系统,始终报错0 T' F1 c8 J. J/ y
错误信息:% @/ j# P0 {, S- X! ]) E
qemu-img: /var/tmp/v2vovl16ebce.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file irectory
; m% V9 p: v0 Svirt-v2v: error: qemu-img command failed, see earlier errors- {( x" k, g# ~+ N2 ^
If reporting bugs, run virt-v2v with debugging enabled and include the
' L! {4 T+ l1 T  P, f0 d8 X#新安装centos6操作系统测试,环境确认,两台KVM需要有相同的存储池位置,vmfspool8 |: Z. r- Y8 a% d# I# o
#node72检查& S% a, |! P" f' e  u" E" ]( |' I
[root@node72 ~]# virsh pool-list
9 v$ X5 x2 G2 h' [ 名称               状态     自动开始* [7 p. b5 C7 Y9 S* s
-------------------------------------------
& Y) C. k/ m" s) J% N+ ] iso                  活动     是       - I% T8 W" a9 E! x1 u
oel1                 活动     是       & t8 }% R* f1 \# e4 j- }
vmfspool             活动     是      
( r" X% k! _& O$ g/ i$ u( O2 u% m
7 r  |- x( E. q# X[root@node72 ~]#
& ^5 j+ g/ S% x0 k+ K#关闭需要迁移的虚拟机
8 T' ?! E/ s! B: L7 X[root@node72 ~]# virsh list --all0 k( F% U0 R7 x2 b
Id    名称                         状态
! ?; P) U( L0 Z! ~& u% J! s7 o----------------------------------------------------7 E! T# K) m# A
7     oel4                           running+ @6 z) G" g, f2 Z, i4 X1 Y
-     oel5                           关闭
% v; {$ d1 V6 z3 K  D+ a[root@node72 ~]# virsh shutdown oel4
/ T# o; a" V( Y1 N0 ?$ |7 d域 oel4 被关闭* P; {: i  x5 T8 s# c- D
[root@node72 ~]#% M! p* N4 y5 M6 j
#测试KVM 自身vm迁移到自身,-oc是迁移出去,-on取另外一个名字,因为系统本身已经存在oel4这个实例& C1 Q+ a1 T: @/ i+ v( @0 P
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.110/system -os vmfspool -on centos4 -b br0 oel4
4 e7 T8 y6 {& h! [[   0.0] Opening the source -i libvirt oel4. ?0 a4 Q* \1 ^% M
[   0.0] Creating an overlay to protect the source from being modified
6 M0 B: F+ p: @9 E[   0.0] Opening the overlay7 W% R3 j" G" }' A: s8 E
[  10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.110/system -os vmfspool3 z& G5 E- y9 B2 K" x* m
root@192.168.2.110's password: , [9 E+ e2 S$ D% y( B8 I; [& N
root@192.168.2.110's password: ) H, C$ v: A6 Q
root@192.168.2.110's password:
$ K2 t& M! w0 p8 L  v/ K8 A) _6 k[  17.0] Inspecting the overlay
* g: Q2 w5 R! g. f" Z[  24.0] Checking for sufficient free disk space in the guest
! K( n% z  s$ m: D' L[  24.0] Estimating space required on target for each disk
/ {7 \. j' ]; w3 p+ ^[  24.0] Converting CentOS release 6.5 (Final) to run on KVM
, `3 r9 K0 Z, [9 k* @virt-v2v: This guest has virtio drivers installed.
* Z5 D! L8 K) T5 V" m[  69.0] Mapping filesystem data to avoid copying unused and blank areas
; D; G6 m3 F; l2 ^[  69.0] Closing the overlay
$ C. ]9 ^$ L+ r0 }[  70.0] Checking if the guest needs BIOS or UEFI to boot  v$ Y1 j' q7 l
[  70.0] Copying disk 1/1 to /data/vmfs/centos4-sda (qcow2)
8 }1 E$ r2 w- Q# E    (100.00/100%)
; A( b1 Z# ]! O1 ?8 y[  82.0] Creating output metadata
# c% |* O# S$ y8 G% C( Q# Hroot@192.168.2.110's password: * D* m. r  J1 e
池 vmfspool 被刷新
) A' m" e( k: f4 c% Groot@192.168.2.110's password: ) u* u/ N4 V' v/ P8 q& I$ {. k! ?8 G
定义域 centos4(从 /tmp/v2vlibvirt7142b4.xml), M# U  Q6 Y; G: D2 ~
[ 107.0] Finishing off
% r$ X& O  [4 I% B1 I0 i5 z! W, J) A[root@node72 ~]#; _/ b/ n! D. P) M# n$ q
#可以看到迁移的vm磁盘为/data/vmfs/centos4-sda (qcow2)
4 g' S* [: C  H) }4 i0 V6 L#检查,另外需要因为是迁移到自身测试,所以需要查看配置文件UUID,MAC地址,VNC端口,* Y/ U! l3 n$ h
[root@node72 ~]# virsh list --all4 @! y; d+ S; S; Y: ?7 ~6 E+ f
Id    名称                         状态
6 x& e  s. ]2 L* t----------------------------------------------------
  [) F* v) C1 t* i* G -     centos4                        关闭
+ \; W. @, Q) d) j! Q! I -     oel4                           关闭
# Z- q; x6 q$ s! n3 h& R -     oel5                           关闭' x  }: H% o+ V& \
[root@node72 ~]#
/ i9 L, b) m$ k; p1 `+ b) _0 D3、KVM之间的v2v迁移/ T' h: ^; Z+ N) T

! |+ _" S5 o, H( E1 D#检查node71的迁移环境- r" w0 |- K& v# O* G9 I
[root@node71 ~]# virsh pool-list( |  Z2 V' s- S: E' p/ F
名称               状态     自动开始
% W# _: e; k' u. |7 y-------------------------------------------3 |/ S) G. E& j# h' }4 r, k$ ?
iso                  活动     是       ' _0 V3 |( p" t4 g! m
vmfspool             活动     是       ) P6 i3 e; S" J! q
$ T2 k" G( H0 y3 R: J5 o
[root@node71 ~]#   S/ ~+ m' i$ e, Q4 M- n
#测试迁移,从node72迁移出来1 ?  L- W7 p" ^2 p8 f7 e6 K
[root@node72 ~]# virt-v2v -oc qemu+ssh://192.168.2.111/system -os vmfspool  -b br0 oel4
1 X3 y% l( s2 ^- t$ m* k! P" Y[   0.0] Opening the source -i libvirt oel4' B; S0 K5 b0 F7 ~+ `! Z: f
[   0.0] Creating an overlay to protect the source from being modified
. d, w5 X  E; x  x' k0 ?8 S[   0.0] Opening the overlay
% ~2 B, d# d+ p[  10.0] Initializing the target -o libvirt -oc qemu+ssh://192.168.2.111/system -os vmfspool# R8 J* T7 l* d4 n" h
root@192.168.2.111's password:
/ `( l8 x. Y; o( ]root@192.168.2.111's password:
( h7 f; e+ }1 M& troot@192.168.2.111's password:
# k* j5 c3 ]0 x5 I9 b7 y, B[  18.0] Inspecting the overlay, Y  }7 D# P7 J5 w) d7 b$ X
[  24.0] Checking for sufficient free disk space in the guest
. r1 g1 M* U( d1 X[  24.0] Estimating space required on target for each disk/ W( P( T! U% A/ A+ k$ Z
[  24.0] Converting CentOS release 6.5 (Final) to run on KVM
3 X; |6 m& e! h! d6 fvirt-v2v: This guest has virtio drivers installed.
' _7 l1 {2 z; C$ b0 [2 u+ l. n[  68.0] Mapping filesystem data to avoid copying unused and blank areas: D" q9 k9 |. J4 @
[  69.0] Closing the overlay- J4 G' y# e+ W; [
[  69.0] Checking if the guest needs BIOS or UEFI to boot! m* @" [" f, x! N0 U# R( {, b
[  69.0] Copying disk 1/1 to /data/vmfs/oel4-sda (qcow2)
# B  ]4 F6 D  R' F& r$ t- B1 O    (100.00/100%)
2 u8 A% ?* m/ B! V0 b8 Z5 g[  80.0] Creating output metadata7 L5 j9 g: i. E1 N3 N" H! \5 M1 q
root@192.168.2.111's password: ) F+ n# X# B+ s, j' a. e' T
池 vmfspool 被刷新
9 P. }9 `# o9 ^" F; |. N6 C; a
# a1 Q; e9 h1 Q4 I+ x! vroot@192.168.2.111's password:
* B7 o# l, u8 v  L; a+ @2 L; m# f- c定义域 oel4(从 /tmp/v2vlibvirt255acc.xml)
$ g0 F' t2 W( j! r0 M
& w, ^, e! y- J. a" x: B[  86.0] Finishing off) H2 ]4 r8 T5 ?/ Q! j
[root@node72 ~]# 9 W* ~/ T! L8 Z5 {6 U8 B( [* S$ y
#迁移完成, G) H- X  j8 c$ |
#检查测试,在运行迁移的vm之前,需要根据实际环境的情况来检查vm配置文件,确定是否按需修改, \% G8 f2 V/ b, \+ P% n
[root@node71 vmfs]# virsh list --all
7 Y5 h% W1 u9 v Id    名称                         状态8 B/ f$ ?7 p+ c- {$ s5 {
----------------------------------------------------5 ^4 n+ T$ a. b
-     oel2                           关闭9 U; Q. R" c( u8 |/ W' T4 ]
-     oel3                           关闭. E, N! F5 T1 P# U, c
-     oel4                           关闭
. o" W. ~* H, \; s( Y( ^[root@node71 vmfs]#
$ T0 ], \/ ^7 z#可以查看到oel4已经迁移完成7 n  K8 r$ i; A0 f

3 U/ o- I  I5 _% S3 d#这是采用node72迁移出去的方式(-oc),但是在node71上采用迁移进来的方式(-ic)就会报错误
* Z5 P9 ^. C3 s8 y. V# C" K. r[root@node71 vmfs]# virt-v2v -ic qemu+ssh://192.168.2.110/system -os vmfspool -b br0 -on centos6 oel4& g; s) c5 n* B0 H* W7 h) G9 D0 w
virt-v2v: warning: no support for remote libvirt connections to '-ic
; _1 k5 C8 P! S* c2 |qemu+ssh://192.168.2.110/system'.  The conversion may fail when it tries to
5 |7 B% z5 p- P, U: jread the source disks.( A; y* g, ?1 f- [6 |2 R0 _
[   0.0] Opening the source -i libvirt -ic qemu+ssh://192.168.2.110/system oel4
3 Q. F$ E& r& e2 |root@192.168.2.110's password:
1 e! \* {$ J( T! G) c[   2.0] Creating an overlay to protect the source from being modified1 ]6 \4 ^" [5 @* k% {1 W- X
qemu-img: /var/tmp/v2vovl1c0ab2.qcow2: Could not open '/data/vmfs/c4_qcow2.img': No such file or directory/ }- D( ]9 I+ q
virt-v2v: error: qemu-img command failed, see earlier errors5 Q* h' x2 T  n( |

9 I$ d) O# T; ]$ wIf reporting bugs, run virt-v2v with debugging enabled and include the
. K' M4 t8 O$ dcomplete output:
9 a5 w2 k8 x2 q: i8 x
7 V0 J  }; M! V$ [0 x8 k  virt-v2v -v -x [...]6 m4 m* K' k0 `  @
[root@node71 vmfs]# ! |  y- R$ V' M2 D% i0 T
#暂时还不清楚,我们-ic一直会报"No such file or directory"
: n9 }" m; `& a1 jvirt-v2v 命令帮助
1 R. e; X/ D  T' }" p1 A[root@node71 iso]# virt-v2v --help( U, J  {- O% i
virt-v2v: convert a guest to use KVM! U% x- S- P# q
4 f7 _# T5 U* ?% |- q' r, k
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi -os imported esx_guest7 X+ n" E) J) I

5 a5 c% S0 `  ` virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi esx_guest -o rhev -os rhev.nfs:/export_domain --network rhevm6 V) J, I# S  p2 E4 M

0 L$ q& m! D/ A virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
1 r) r: g/ c7 |9 Z# x% U/ E( L5 v) k* K/ L5 X5 A
virt-v2v -i disk disk.img -o local -os /var/tmp
" |& i8 f1 a" v7 k0 D1 |3 U4 e) g# c2 r. F3 L! H+ l
virt-v2v -i disk disk.img -o glance
4 Y( i' @9 u  V% h4 a- l3 e8 v( o8 |- D3 T: W; g( J5 M1 e& f
There is a companion front-end called "virt-p2v" which comes as an
& W0 |7 D# j& W6 F! z9 f2 Q' l& UISO or CD image that can be booted on physical machines.# R7 P( o- @* o
0 q+ I  t* v; ~& g
A short summary of the options is given below.  For detailed help please
- C( o& T1 k7 b5 vread the man page virt-v2v(1).1 q9 t2 \- @4 f, e# |! @
) ]8 n& r8 [3 x- I) G* p
  -b in:out                                   Map bridge 'in' to 'out'1 e$ Q/ N9 V, L+ a( M
  --bridge in:out                             -"-
5 h6 g( c$ `) e8 M/ K' E  --debug-gc                                  Debug GC and memory allocations
7 t; f- G  ~( s9 ~/ C  --dcpath path                               Override dcPath (for vCenter)
! \8 h* v* h8 @# p) C4 U4 @( x( J) o  --dcPath path                               -"-" W% t) B  L; H
  --debug-overlay                             Save overlay files
/ `3 [, f. ?: L: M9 q" d  --debug-overlays                            -"-( ?) p! y  ?. `1 o# }0 v- l4 ~
  -i disk|libvirt|libvirtxml|ova              Set input mode (default: libvirt)/ [, F. z, W9 b$ x3 {0 u0 G
  -ic uri                                     Libvirt URI! I% g; U$ Y0 l6 D8 ?0 A( `
  -if format                                  Input format (for -i disk)  `0 {: D+ E  n/ d
  --long-options                              List long options2 o9 ~0 |& |% ~5 b
  --machine-readable                          Make output machine readable
. l# R4 V; q- u% {. {& Z9 ?  -n in:out                                   Map network 'in' to 'out'
: v5 K+ k$ M4 Y' o. N' P7 p  --network in:out                            -"-
* A/ E2 j- Q9 W/ H* h8 Y+ j0 h  --no-copy                                   Just write the metadata) ]/ r4 o9 @% f" {- V2 [
  --no-trim all|mp,mp,..                      Don't trim selected mounts
7 t& m7 T* s/ r! Z  -o glance|libvirt|local|null|qemu|rhev|vdsm Set output mode (default: libvirt)" k- x& Z6 o. h& Q2 N' F( H$ F* U
  -oa sparse|preallocated                     Set output allocation mode. M- J/ q) b" l% J: Y
  -oc uri                                     Libvirt URI2 M! N9 q1 j8 t) [3 ~
  -of raw|qcow2                               Set output format# p& Z! M. J9 g% F
  -on name                                    Rename guest when converting
; e9 x( s7 ^( l! [3 c  z7 d+ `3 ]- J  -os storage                                 Set output storage location9 m+ O. i8 @& }: Y4 s$ V( _+ B
  --password-file file                        Use password from file
, W' A: E! r8 |. o# E- Z8 Q+ [  --print-source                              Print source and stop9 k: V! _6 j/ J+ [  Y1 u
  --qemu-boot                                 This option cannot be used in RHEL1 b& I9 {, Y) g, Z) k/ j
  -q                                          Quiet output
5 y7 r* d( h5 h$ }+ K  --quiet                                     -"-
: ^: L" ~& g9 P) _) y) m1 P  --root ask|...                              How to choose root filesystem0 x5 w7 F5 W9 x  t% Q9 D
  --vdsm-image-uuid uuid                      Output image UUID(s)6 f: j& o+ X3 j* O! k0 b
  --vdsm-vol-uuid uuid                        Output vol UUID(s)
6 m% ?/ n' q; m  --vdsm-vm-uuid uuid                         Output VM UUID; t  {0 U1 v# j; y1 l& G4 Y0 N+ g
  --vdsm-ovf-output                           Output OVF file! k/ E& O5 R) `" W7 }# h
  -v                                          Enable debugging messages; P1 \; @: ]: ~, m. _* w
  --verbose                                   -"-
7 m1 o' s6 Z4 a0 ~  -V                                          Display version and exit2 b, x- h& S; U1 o$ u5 D
  --version                                   -"-
8 V" J! k3 U( v/ A# S  --vmtype server|desktop                     Set vmtype (for RHEV)/ H! b% P1 j# [
  -x                                          Enable tracing of libguestfs calls% U+ X* z4 p# x9 x
  -help                                       Display this list of options
! Q# \" v6 @! j3 i7 [+ p! `  }  --help                                      Display this list of options
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:24 , Processed in 0.057975 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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