VMware ESXI迁移虚拟机至KVM平台
最编程
2024-01-18 16:39:11
...
第一种方法:直接迁移
1、开启ESXI上的ssh服务和ESXI Shell服务。
ESXI5.5如下:
ESXI6.7如下:
2、配置KVM到ESXI免密认证
[root@SIT-KVM01 ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Cd2XpDjQiR0Nz1eGRDcJhQFm6hyapIXLQ3BeAzRectk root@SIT-KVM01 The key's randomart image is: +---[RSA 2048]----+ | ...o=++. | | = Bo+EO.oo=.. | | = + * = + | | o = * + o | | = o S | | . | | | | | | | +----[SHA256]-----+ [root@SIT-KVM01 ~]# ssh-copy-id -i .ssh/id_rsa.pub 10.xxx.128.145 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub" The authenticity of host '10.xxx.128.145 (10.xxx.128.145)' can't be established. RSA key fingerprint is SHA256:DUhcdrc8dWdwMVv6RwOQs9AVjonPqIFwD7kumhURcjQ. RSA key fingerprint is MD5:86:2f:b2:02:e4:75:6b:13:3e:ec:32:48:c9:01:85:d3. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '10.xxx.128.145'" and check to make sure that only the key(s) you wanted were added. [root@SIT-KVM01 ~]#
3、调整ESXI中上一步添加的KEY认证文件
[root@SIT-KVM01 ~]# ssh 10.xxx.128.145 Password: The time and date of this login have been sent to the system logs. VMware offers supported, powerful system administration tools. Please see www.vmware.com/go/sysadmintools for details. The ESXi Shell can be disabled by an administrative user. See the vSphere Security documentation for more information. ~ # cd /etc/ssh/ /etc/ssh # ls keys-root moduli ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub sshd_config /etc/ssh # cd keys-root/ /etc/ssh/keys-root # ls authorized_keys /etc/ssh/keys-root # cd ~ # cat .ssh/authorized_keys >> /etc/ssh/keys-root/authorized_keys ~ # exit Connection to 10.xxx.128.145 closed. [root@SIT-KVM01 ~]# ssh 10.xxx.128.145 The time and date of this login have been sent to the system logs. VMware offers supported, powerful system administration tools. Please see www.vmware.com/go/sysadmintools for details. The ESXi Shell can be disabled by an administrative user. See the vSphere Security documentation for more information. ~ #
4、开始迁移,(注:迁移前需要将虚拟机关机,虚拟机路径里面不要包含空格,中文字符,否则汇报URI错误)。
[root@SIT-KVM01 ~]# eval `ssh-agent` Agent pid 30714 [root@SIT-KVM01 ~]# ssh-add .ssh/id_rsa Identity added: .ssh/id_rsa (.ssh/id_rsa) [root@SIT-KVM01 ~]# export LIBGUESTFS_BACKEND=direct [root@SIT-KVM01 vmfs]# virt-v2v -i vmx -it ssh "ssh://root@10.xxx.128.145/vmfs/volumes/553503c1-37053e17-f472-a0369f6/d1search02--10.xxx.128.55/d1search02--10.xxx.128.55.vmx" -os vmfs -of qcow2 --bridge br128 [ 0.0] Opening the source -i vmx ssh://root@10.xxx.128.145/vmfs/volumes/553503c1-37053e17-f472-a0369f677064/d1searc [ 0.6] Creating an overlay to protect the source from being modified [ 1.0] Opening the overlay [ 5.6] Inspecting the overlay [ 19.4] Checking for sufficient free disk space in the guest [ 19.4] Estimating space required on target for each disk [ 19.4] Converting Red Hat Enterprise Linux Server release 6.5 (Santiago) to run on KVM virt-v2v: This guest has virtio drivers installed. [ 110.6] Mapping filesystem data to avoid copying unused and blank areas [ 112.1] Closing the overlay [ 112.2] Assigning disks to buses [ 112.2] Checking if the guest needs BIOS or UEFI to boot [ 112.2] Initializing the target -o libvirt -os vmfs [ 112.2] Copying disk 1/1 to /vmfs/d1search02--10.xxx.128.55-sda (qcow2) (100.00/100%) [2321.3] Creating output metadata Pool vmfs refreshed Domain d1search02--10.xxx.128.55 defined from /tmp/v2vlibvirt56ad9d.xml [2321.4] Finishing