大家好,又见面了,我是你们的朋友全栈君。
环境说明
virt-p2v server:Centos 7.2
virt-p2v client:Centos 7.2
Virt-p2v version:1.28.1
Virt-v2v version: 1.28.1
配置说明
之前在 Centos 6下通过virt-p2v进行虚拟化转化(For Linux Server)这篇Blog中写过在Centos6下通过virt-p2v进行虚拟化服务器,但是发现在Centos7中,virt-p2v client的客户端
界面发生改变,且在virt-p2v server中没有virt-v2v.conf文件,下面我们来看看在Centos7中如何进行虚拟化服务器。
客户端配置
同样在http://rpm.pbone.net/index.php3?stat=26&dist=93&size=263085744&name=virt-p2v-1.28.1-1.51.3.el7.1.noarch.rpm链接中找到virt-p2v的安装文件,然后
在/usr/share/virt-p2v目录下面可以找到virt-p2v的iso文件。参照 Centos 6下通过virt-p2v进行虚拟化转化(For Linux Server)的操作步骤,将该iso文件写入U盘。
服务器配置
安装virt-v2v
代码语言:javascript复制#yum -y install virt-v2v
在服务器端创建pool
代码语言:javascript复制#virsh pool-create-as pool-1 dir --target=/home/pool1
在Centos6中virt-v2v的版本还有virt-v2v.conf文件进行需要配置,但是在Centos7中virt-v2v没有这个文件,所以不需要配置,在客户端直接指定pool就可以了。
虚拟化服务器
1.将U盘插入服务器,设置U盘为第一启动项,我们可以看见如下界面
2.设置ip地址,点击“configure network”设置ip地址
点击“edit”
点击“ipv4 settings”设置ip地址
3.设置连接virt-v2v服务器,分别填写virt-p2v 服务器ip及root密码
4.测试client及server的连接,点击“Test Connection”
5,.设置虚拟化选项
分别设置服务器名称,主要服务器名称是唯一的,不能有相同的,分别在“output to”中选择“libvirt”,而后在“output Storage”中填写pool-1,pool-1为之前在virt-p2v server中创
建的pool。点击“start convert”,而后客户端进入如下所示界面,进行转换。
等待转换完成后,会提示如下界面
6. 转换成功后,开始启动转换完成的虚拟机,先查看到该vm的xml文件,在/etc/libvirt/qemu目录下面可以找到
代码语言:javascript复制<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit Centos7-2
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>Centos7-2</name>
<uuid>107049bd-5a50-4442-a72b-297dc9420684</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='volume' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source pool='pool-1' volume='Centos7-2-sda'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='00:0c:29:5c:30:d0'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
主要查看network选项为default,先查看virt-p2v server的network列表
代码语言:javascript复制[root@ovirt-host-227 qemu]# virsh net-list
Name State Autostart Persistent
----------------------------------------------------------
;vdsmdummy; active no no
vdsm-ovirtmgmt active yes yes
在这里我们需要将default修改为vdsm-ovirtmgmt
代码语言:javascript复制 <interface type='network'>
<mac address='00:0c:29:5c:30:d0'/>
<source network='vdsm-ovirtmgmt'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
启动vm
代码语言:javascript复制[root@ovirt-host-227 qemu]# virsh define Centos7-2.xml
Domain Centos7-2 defined from Centos7-2.xml
[root@ovirt-host-227 qemu]# virsh start Centos7-2
Domain Centos7-2 started
查看Centos7-2所使用的vnc port,为10.10.200.227:0
代码语言:javascript复制[root@ovirt-host-227 qemu]# ps -ef | grep vnc
root 2705 1 1 20:58 ? 00:00:43 /usr/libexec/qemu-kvm -name windows2008 -S -machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off -cpu Westmere,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -m 2048 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 5a5cb94a-c508-46fc-9aa5-9e9f6add36cb -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-windows2008/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 -drive file=/root/virt-p2v-livecd-1.28.1-1.49.1.el7.iso,if=none,id=drive-ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive file=/home/windows2008.img,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,fd=24,id=hostnet0 -device rtl8139,netde
v=hostnet0,id=net0,mac=52:54:00:fd:0d:1f,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 10.10.200.227:92 -device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on
root 16347 1 92 21:54 ? 00:00:31 /usr/libexec/qemu-kvm -name Centos7-2 -S -machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off -m 2048 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 107049bd-5a50-4442-a72b-297dc9420684 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-Centos7-2/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/pool1/Centos7-2-sda,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive=drive
-ide0-0-0,id=ide0-0-0 -netdev tap,fd=26,id=hostnet0,vhost=on,vhostfd=27 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:0c:29:5c:30:d0,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vn
c <span style="color:#ff6666;">10.10.200.227:0 </span>-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
root 16893 7466 0 21:54 pts/1 00:00:00 grep --color=auto vnc
在windows pc端通过vnc view连接10.10.200.227:0,就可以连接上虚拟化后的服务器了。
另:在该版本的virt-p2v下转换Centos 6的服务器无法成功,原因未知,没有提示任何错误。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/160456.html原文链接:https://javaforall.cn
=