找回密码
 注册
查看: 2116|回复: 1

p2v、v2v迁移

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-8-18 17:00:06 | 显示全部楼层 |阅读模式
最近在做P2V、V2V迁移,现在将迁移问题进行总结一下
/ s4 j! I4 X: C( o物理机迁移到kvm中0 F: I4 v' u: T7 d: }: g
本次迁移所选用的系统是centos7.5,安装P2V、V2V以及virtio-win等rpm包。刻录virt-p2v( I! H* q& L7 D6 N
镜像
6 m# s3 b+ o2 \6 i4 ]
7 ?* B$ D- m/ Z& Y1、采用virt-p2v引导,界面如下virt-p2v:+ D/ s- c( x. _6 D( {0 x0 u
2、物理选择Start Virt P2V可以进入SSH配置界面5 K! o& H+ b/ t* _3 u
(1) 填写转换服务器的IP地址& V5 I" r! v% Q5 V7 j. t
(2) 需要转换服务器上的SSH端口号。
% H1 h# b2 ~) h' P$ f' S3 O(3) 选择将登录哪个用户的转换操作日志,并输入他们的密码
  D3 ^. {) Q8 L' |# T5 ]/ J0 _(4) root用户密码
, |+ a: K8 V8 N' ]; a# i9 C, R(5) 上传私有SSH密钥文件的路径名& e- l, j, n% @
3、磁盘和网络配置7 m2 i* @4 E" C+ J# ]  s( E
(1) 配置创建的guest虚拟机的名称,虚拟CPU数量和内存
+ N8 C, s, w; [(2) 修改guest虚拟机的生成位置和格式8 X. ^1 m, M; J- u  d1 [
(3) 选择要转换的网络接口,可移动媒体和存储磁盘! G7 d1 g; t/ ^9 Q! ?: m) u$ c
4、开始转换界面
& G- A. }1 S* _. g1 b
1 D. r# [5 \7 y! J- `0 I5、 验证迁移结果
. d7 s6 N" R. s0 Y(1) 底层查看系统转换后的磁盘格式  e3 ?; e: B9 b2 [, _
(2) 开启虚拟机,验证系统是否正常2 m' R; Q0 w# v5 O7 m
vmware迁移到kvm; N$ S- s- Y/ G# {/ t! h" n5 I
使用virt-v2v工具前提条件:
2 r  z6 t! W; N  P" f  u1 }. c(1)Vmware已安装安装vcenter
0 y, j1 O; a5 U, n(2) virt-v2v相关包已经安装
; V$ i" Q( a' ~3 s: _6 @1、查看vmware虚拟机,卸载vmware tools+ d5 F! ^4 g% B+ o( k
如果虚拟机上安装了 VMware Tools,必须先卸载它。因为 KVM 的虚拟机不支持 VMware Tools 里面的虚拟驱动。
& c4 J% F0 y& |  @9 I2 L, ^2、 关闭虚拟机1 L% d* Q1 |# ]! L! v/ G: l
3、测试vmware连通性. g' U2 k2 C& T4 M
4、vmware迁移! H! i# O( ~3 {/ a6 a
virt-v2v -v -x -ic vpx://DOMAIN%5cuser@vCenterIP_NAME/DadacenterIP_NAME/ClusterIP_NAME/HostIP_NAME/?no_verify=1 -o libvirt -os <pool> -b[虚拟网络] <vm名称>& {- d& A0 U- Q8 D$ W
如果用户名使用的是域账户(domain\name)或者虚机名中包含有反斜线,则反斜线需要转码特殊标示,使用“%5c”代替“\”! `; O! H/ `3 Z( J5 S
输入vcenter密码
6 Q2 N* q2 K3 L% L输入vcenter密码
3 G" L6 a0 P' N* R输入vcenter密码
+ v8 V& m4 C# M! s2 \输入vcenter密码3 g5 w4 g# o2 _$ m+ ?
输入vcenter密码
! v* g+ [* b' H. A: _" K开始迁移,并转换磁盘格式为qcow29 d: X1 r, r! s  Z
迁移完成
; d6 m4 _7 j, G: h5、验证! Z/ V( z! D% n) X9 a. _" g8 Y
- z) {9 p# I" d" ], [
+ y* I- R4 F7 s+ l1 P1 m

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 03:23 , Processed in 0.037740 second(s), 29 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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