易陆发现互联网技术论坛

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

p2v、v2v迁移

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

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

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

x
最近在做P2V、V2V迁移,现在将迁移问题进行总结一下' Z! z$ n/ p+ e5 V: X9 V: y' c
物理机迁移到kvm中. g/ y& \( D+ y; q+ y( Y
本次迁移所选用的系统是centos7.5,安装P2V、V2V以及virtio-win等rpm包。刻录virt-p2v
& \7 O2 V& I- D( B镜像
0 r3 z) v( r' k4 r. |: Y, L# c) c+ L: T2 K% u
1、采用virt-p2v引导,界面如下virt-p2v:* L) E5 {+ g4 M! z
2、物理选择Start Virt P2V可以进入SSH配置界面
# g7 u& D& Q4 t4 F# G1 g- A  f0 ~(1) 填写转换服务器的IP地址
2 O, ]# b4 y5 C9 |: T! l' R9 j4 {(2) 需要转换服务器上的SSH端口号。9 B: ~% ]: X2 w1 Y
(3) 选择将登录哪个用户的转换操作日志,并输入他们的密码
# b% Y* |) ?8 i7 P5 o# D(4) root用户密码8 p; a9 X% `1 B( ?# o8 |- e. x
(5) 上传私有SSH密钥文件的路径名6 P: r' S$ A+ N( r2 E
3、磁盘和网络配置$ Y2 L% J4 _- H; i+ F
(1) 配置创建的guest虚拟机的名称,虚拟CPU数量和内存9 A2 H2 j, n) M1 Y4 f
(2) 修改guest虚拟机的生成位置和格式
2 P8 q; L4 B" C& \4 A. L4 L7 J; ^(3) 选择要转换的网络接口,可移动媒体和存储磁盘
$ C$ \# \% x4 \, R4、开始转换界面
, i( Z; {& J+ }8 S: T# W- q( a$ K& \- e+ ^6 x4 w9 B
5、 验证迁移结果0 g0 o4 \+ H3 X5 s! _
(1) 底层查看系统转换后的磁盘格式4 ]+ y! P2 |6 X6 n, \* a% r. V: K
(2) 开启虚拟机,验证系统是否正常
5 [1 a! C) S6 r7 ]- w, _vmware迁移到kvm: g" N6 b3 b( ~& @% ]" y
使用virt-v2v工具前提条件:
5 u: b0 g/ G- S- p/ P# s* I% r3 f(1)Vmware已安装安装vcenter3 r( Z; L5 q$ o7 H
(2) virt-v2v相关包已经安装: n) h1 c, m3 V+ J6 `/ o
1、查看vmware虚拟机,卸载vmware tools1 D/ d& r0 p2 n" s& L) \: ]
如果虚拟机上安装了 VMware Tools,必须先卸载它。因为 KVM 的虚拟机不支持 VMware Tools 里面的虚拟驱动。* i2 L  ?5 E: s  v
2、 关闭虚拟机2 X4 Y; G% V/ c4 o$ J7 c
3、测试vmware连通性
. ^- r& ?) u! w/ m9 K8 \4、vmware迁移
  X9 n. d! C1 X: zvirt-v2v -v -x -ic vpx://DOMAIN%5cuser@vCenterIP_NAME/DadacenterIP_NAME/ClusterIP_NAME/HostIP_NAME/?no_verify=1 -o libvirt -os <pool> -b[虚拟网络] <vm名称>
6 M" K7 y$ H. N8 Y* f1 c如果用户名使用的是域账户(domain\name)或者虚机名中包含有反斜线,则反斜线需要转码特殊标示,使用“%5c”代替“\”8 x, \9 x0 f: d% o( D
输入vcenter密码# ~8 O( p/ z0 Z( s4 @( o: o
输入vcenter密码& q9 x2 w1 {6 k# z2 O9 _
输入vcenter密码! J8 {5 r5 v- i- d: z0 F# y) U1 {
输入vcenter密码4 B& D$ A8 q  M% o  y" X2 K
输入vcenter密码: x& u$ E9 Z4 Y% O1 p
开始迁移,并转换磁盘格式为qcow2+ r. R$ K+ O5 O' [$ M9 U0 I
迁移完成
9 T. k: Y& Y! j" c5、验证8 A, ]. Y# u$ A
4 v( N! S9 ^- S
, y0 ?# f) ^" q" a9 o9 i4 t
p2v启动界面.png
p2v启动界面.png
p2v加载系统配置.png
p2v配置界面.png
 楼主| 发表于 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
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

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

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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