#冲刺创作新星# Migrate OVM to OLVM 原创
OVM 3.3.4 to OLVM
获取OVS下vm主机信息
针对ORACLE VM Server下的testvm01进行迁移。
迁移过程需对testvm01关机操作
右键查看其VM Config File信息
记录以下信息
亦可通过查看vm.cfg获取相关信息
生成对应xml配置文件
将所有需迁移vm主机,生成对应xml配置文件
以下为xml文件需修改部分
以下为xml源文件
将文件复制到KVM主机
启动OVS服务器NFS服务
创建“Repository Export”
检查nfs服务状态
KVM服务器准备
安装所需组件
[root@ol7-kvm01 ~]# yum install oraclelinux-developer-release-el7 yum-utils -y
[root@ol7-kvm01 ~]# yum-config-manager --enable ol7_developer_kvm_utils
[root@ol7-kvm01 ~]# yum install qemu-block-curl
拷贝OLVM证书到KVM服务器
[root@ol7-kvm01 ~]# scp 192.168.137.51:/etc/pki/ovirt-engine/ca.pem /root/ca.pem
生成用于连接OLVM API的密码文件
[root@ol7-kvm01 ~]# echo "P@ss0lvm" >/tmp/ovirt-admin-password
NFS挂载
KVM主机创建对应目录并挂载
[root@ol7-kvm01 ~]# mkdir -p /OVS/Repositories/0004fb0000030000681b0d6bd6435d1b
[root@ol7-kvm01 ~]# mount -t nfs 192.168.137.183:/OVS/Repositories/0004fb0000030000681b0d6bd6435d1b /OVS/Repositories/0004fb0000030000681b0d6bd6435d1b
开始迁移
# export LIBGUESTFS_BACKEND=direct
# virt-v2v -i libvirtxml <xml-conf-generated> -o ovirt-upload -oc https://<OLVM-FQDN>/ovirt-engine/api -os <OLVM-Storage-Domain> -op <OLVM-ADMIN-PASSWORD-FILE> -of raw -oo rhv-cluster=<OLVM-CLUSTER> -oo rhv-cafile=<OLVM-CERT-FILE>
Example:
[root@ol7-kvm01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.137.51 ol7-olvm
192.168.137.61 ol7-kvm01
[root@ol7-kvm01 ~]# export LIBGUESTFS_BACKEND=direct
[root@ol7-kvm01 ~]# virt-v2v -i libvirtxml testvm01.xml -o ovirt-upload -oc https://ol7-olvm/ovirt-engine/api -os vmware-data -op /tmp/ovirt-admin-password -of raw -oo rhv-cluster="Default" -oo rhv-cafile=/root/ca.pem -oa preallocated
迁移完成
启动验证
打开“Compute”- “Virtual Machines”编辑迁移完成vm主机
核对修改vm主机名等信息
启动vm主机
打开Console查看启动过程
Console配置
Native Client
Windows主机需下载virt-viewer-x64进行安装方能连接到Console
https://virt-manager.org/download/sources/virt-viewer/virt-viewer-x64-11.0-1.0.msi
noVNC (Console Option)
下载CA证书,并安装到:受信任的根证书颁发机构
修改链接console的方式
OVM 3.4.x to OLVM (XML)
可根据 “6.1” 迁移方法手动修改xml文件进行迁移,以下将使用virsh生成所需对应xml文件
针对ORACLE VM Server下的ol7.1进行迁移。
启动xend服务
OVS服务器,修改配置文件开启http监听端口(8000)
# vi /etc/xen/xend-config.sxp ## Uncomment specified lines
(xend-http-server yes)
(xend-unix-path /var/lib/xend/xend-socket)
(xend-port 8000)
重启“xend”及“libvirtd”服务
[root@ovms3 ~]# /etc/init.d/xend restart
[root@ovms3 ~]# /etc/init.d/libvirtd restart
KVM主机连接测试(连接到OVS)
[root@ol7-kvm01 ~]# virsh -c xen+ssh://root@192.168.137.162 list --all
root@192.168.137.162's password:
Id Name State
--------------------------------------------------
0 Domain-0 running
6 0004fb0000060000c166a49d23eefc56 idle
身份验证配置
获取KVM VDSM守护进程自身份验证到OVS服务器
# sudo -u vdsm ssh-keygen
# sudo -u vdsm ssh-copy-id root@<ovm-host>
# sudo -u vdsm ssh root@<ovm-host>
Example:
启动OVS服务器NFS服务
创建“Repository Export”
检查nfs服务状态
KVM服务器准备
安装所需组件
[root@ol7-kvm01 ~]# yum install oraclelinux-developer-release-el7 yum-utils -y
[root@ol7-kvm01 ~]# yum-config-manager --enable ol7_developer_kvm_utils
[root@ol7-kvm01 ~]# yum install qemu-block-curl
拷贝OLVM证书到KVM服务器
[root@ol7-kvm01 ~]# scp 192.168.137.51:/etc/pki/ovirt-engine/ca.pem /root/ca.pem
生成用于连接OLVM API的密码文件
[root@ol7-kvm01 ~]# echo "P@ss0lvm" >/tmp/ovirt-admin-password
NFS挂载
KVM主机创建对应目录并挂载
[root@ol7-kvm01 ~]# mkdir -p /OVS/Repositories/0004fb0000030000cfbe1e2a846ea785
[root@ol7-kvm01 ~]# mount -t nfs 192.168.137.162:/OVS/Repositories/0004fb0000030000cfbe1e2a846ea785 /OVS/Repositories/0004fb0000030000cfbe1e2a846ea785
生成xml配置文件
待迁移vm主机需为开机状态
确认主机信息
生成xml配置文件
# virsh -c xen+ssh://root@<ovm-host> dumpxml <vm-uuid> > <vm-name>.xml
Example:
关闭需迁移主机
迁移过程需对ol7.1关机操作
开始迁移
# export LIBGUESTFS_BACKEND=direct
# virt-v2v -i libvirtxml <xml-conf-generated> -o ovirt-upload -oc https://<OLVM-FQDN>/ovirt-engine/api -os <OLVM-Storage-Domain> -op <OLVM-ADMIN-PASSWORD-FILE> -of raw -oo rhv-cluster=<OLVM-CLUSTER> -oo rhv-cafile=<OLVM-CERT-FILE>
Example:
[root@ol7-kvm01 ~]# cat /etc/hosts
192.168.137.51 ol7-olvm
192.168.137.61 ol7-kvm01
[root@ol7-kvm01 ~]# export LIBGUESTFS_BACKEND=direct
[root@ol7-kvm01 ~]# virt-v2v -i libvirtxml ol7.1.xml -o ovirt-upload -oc https://ol7-olvm/ovirt-engine/api -os vmware-data -op /tmp/ovirt-admin-password -of raw -oo rhv-cluster="Default" -oo rhv-cafile=/root/ca.pem -oa preallocated
迁移完成
启动验证
打开“Compute”- “Virtual Machines”编辑迁移完成vm主机
核对修改vm主机名等信息
启动vm主机
打开Console查看启动过程
Windows主机需下载virt-viewer-x64-10.0-1.0.exe进行安装方能连接到Console
至此迁移完成
OVM 3.4.x to OLVM (Online)
以下将通过OLVM管理控制台连接OVM Xen进行迁移
针对ORACLE VM Server下的ol7.1进行迁移。
启动xend服务
OVS服务器,修改配置文件开启http监听端口(8000)
# vi /etc/xen/xend-config.sxp ## Uncomment specified lines
(xend-http-server yes)
(xend-unix-path /var/lib/xend/xend-socket)
(xend-port 8000)
重启“xend”及“libvirtd”服务
[root@ovms3 ~]# /etc/init.d/xend restart
[root@ovms3 ~]# /etc/init.d/libvirtd restart
KVM主机连接测试(连接到OVS)
[root@ol7-kvm01 ~]# virsh -c xen+ssh://root@192.168.137.162 list --all
root@192.168.137.162's password:
Id Name State
--------------------------------------------------
0 Domain-0 running
6 0004fb0000060000c166a49d23eefc56 idle
身份验证配置
获取KVM VDSM守护进程自身份验证到OVS服务器
# sudo -u vdsm ssh-keygen
# sudo -u vdsm ssh-copy-id root@<ovm-host>
# sudo -u vdsm ssh root@<ovm-host>
Example:
OLVM导入VM
打开“Compute” - “Virtual Machines”
Source选择“Xen”,输入OVS URL
将需迁移VM选中并提交到Import列表
OVM 3.4.6 to OLVM(未验证)
当前版本3.4.1验证测试失败,应是OVS版本问题,在OVS 3.4.6之后解决
OLVM服务器准备
安装必要组件
[root@ol7-olvm ~]# yum install python python-requests python-libs -y
[root@ol7-olvm ~]# yum install python-ovirt-engine-sdk4 -y
创建目录并将证书拷贝到此目录
[root@ol7-olvm ~]# mkdir migrate_vm
[root@ol7-olvm ~]# cd migrate_vm/
[root@ol7-olvm ~]# cp /etc/pki/ovirt-engine/ca.pem .
测试ssh连接到OVS和KVM主机
测试登录到ovmcli
上传migrate_vm.py
增加执行权限
[root@ol7-olvm ~]# chmod +x /root/migrate_vm/migrate_vm.py
执行迁移
验证测试失败
Script usage
A sample usage of the script is as follows:
Option 1: Export the guest VM in Oracle VM and Import it in OLVM
# python migrate_vm.py
=== Welcome to guest VM migration tool ===
1.Export from OVM manager and import in OLVM
2.Already exported guest VM as Virtual appliance in OVM manager, Need to import in OLVM
3.Already placed the ova file in KVM host, Need to import in OLVM
Enter the option:1
Enter hostname/ IP address of OVM manager:<hostname/ IP address of OVM manager>
Enter the admin password:<admin password>
Succesfully accessed Oracle VM Manager <hostname/ IP address of OVM manager>
Enter Repository name:<Repository name>
Enter guest VM name:OVM
Enter Virtual Appliance Name:OVM1
OVM> exportVirtualAppliance Repository name=<Repository name> name=OVM1 vms=0004fb00000600007da1991568ddd669
Command: exportVirtualAppliance Repository name=<Repository name> name=OVM1 vms=0004fb00000600007da1991568ddd669
Status: Success
Time: 2019-11-11 21:23:26,823 IST
JobId: 1573486449082
Data:
id:1139e0e6e6 name:OVM1
OVM> Connection closed.
The guest VM is exported to Repository...
Enter hostname/IP address of Oracle VM Server:<hostname/IP address of Oracle VM Server>
Enter hostname/IP address of KVM host:<hostname/IP address of KVM host>
Enter path for placing the ova file:/home/
root@<hostname/IP address of Oracle VM Server>'s password:
root@<hostname/IP address of KVM host>'s password:
package.ova 100% 6326MB 9.6MB/s 11:01
Connection to <hostname/IP address of Oracle VM Server> closed.
The migration of ova file from OVS to KVM host completed...
Enter the Hostname/IP address of OLVM manager:<Hostname/IP address of OLVM manager>
Enter the username:admin@internal
Enter the password:<password>
Enter the VM name:<VM name>
Enter the name of KVM host as specified in OLVM GUI:<KVM host Name>
Enter the cluster name as specified in OLVM GUI:<cluster name>
Enter the Storage domain name as specified in OLVM GUI:<Storage domain name>
Enter the url for OVA file (It should be like 'ova://<path to ova file>'):ova:///home/package.ova
The VM is being imported...
Option 2: Already exported guest VM as Virtual appliance in OVM manager, Need to import in OLVM.
# python migrate_vm.py
=== Welcome to guest VM migration tool ===
1.Export from OVM manager and import in OLVM
2.Already exported guest VM as Virtual appliance in OVM manager, Need to import in OLVM
3.Already placed the ova file in KVM host, Need to import in OLVM
Enter the option:2
Enter hostname/ IP address of OVM manager:<hostname/ IP address of OVM manager>
Enter the admin password:<admin password>
Succesfully accessed Oracle VM Manager <hostname/ IP address of OVM manager>
Enter Repository name:<Repository name>
Enter Virtual Appliance ID:11d693c1b8
Enter hostname/IP address of Oracle VM Server:<hostname/IP address of Oracle VM Server>
Enter hostname/IP address of KVM host:<hostname/IP address of KVM host>
Enter path for placing the ova file:/11d693c1b8.ova
root@<hostname/IP address of Oracle VM Server>'s password:
root@<hostname/IP address of KVM host>'s password:
package.ova 100% 5847MB 246.8KB/s 6:44:17
Connection to <hostname/IP address of Oracle VM Server> closed.
The migration of ova file from OVS to KVM host completed...
Enter the Hostname/IP address of OLVM manager:<Hostname/IP address of OLVM manager>
Enter the username:admin@internal
Enter the password:<password>
Enter the VM name:<VM name>
Enter the name of KVM host as specified in OLVM GUI:<KVM host Name>
Enter the cluster name as specified in OLVM GUI:<cluster name>
Enter the Storage domain name as specified in OLVM GUI:<Storage domain name>
Enter the url for OVA file (It should be like 'ova://<path to ova file>'):ova://<path to ova file>
The VM is being imported...
Option 3: Already placed the ova file in KVM host, Need to import in OLVM.
# python migrate_vm.py
=== Welcome to guest VM migration tool ===
1.Export from OVM manager and import in OLVM
2.Already exported guest VM as Virtual appliance in OVM manager, Need to import in OLVM
3.Already placed the ova file in KVM host, Need to import in OLVM
Enter the option:3
Enter the Hostname/IP address of OLVM manager:<Hostname/IP address of OLVM manager>
Enter the username:admin@internal
Enter the password:<password>
Enter the VM name:<VM name>
Enter the name of KVM host as specified in OLVM GUI:<KVM host Name>
Enter the cluster name as specified in OLVM GUI:<cluster name>
Enter the Storage domain name as specified in OLVM GUI:<Storage domain name>
Enter the url for OVA file (It should be like 'ova://<path to ova file>'):ova://<path to ova file>
The VM is being imported...