1. 概述
红帽公司推出了混合云CloudForms解决方案,RedHat的宗旨在于通过CloudForms能够管理所有的基础架构设施如RHEV,VMware和云(AWS和OpenStack),实现集中化管理平台。CloudForms由Engine引擎,VMDB虚拟数据库等组成,其中Engine作为CloudForms中核心功能,负责CloudForms的日常管理工作。
CloudForms Engine简称CFME,是一个已经制定好的虚拟机,通过部署该虚拟机,可以快速的部署CloudForms的环境。由于是虚拟机,根据环境的不同,可以部署在不通的虚拟化平台上,并且根据不通的虚拟化平台,由不通的虚拟机提供,如VMware平台,RHEV平台,OpenStack平台等。本文以部署在KVM为例,讲述CloudForms Egine的部署。
2. 通过KVM部署CloudForms
建立和修改虚拟机的配置文件
[root@ChuangYiYuan_10_16_2_9 ~]# cp /etc/libvirt/qemu/CentOS-5.9.xml /etc/libvirt/qemu/cfme.xml
修改如下内容:
a、名字 <name>cfme</name>
b、uuid <uuid>ba845a90-8670-4b89-9451-3a111372950c</uuid> 通过uuidgen生成一个新的号码
c、内存 <memory unit=’KiB’>4194304</memory>
d、CPU <vcpu placement=’static’>4</vcpu>
e、启动顺序 <boot dev=’hd’/>
f、磁盘文件
<disk type=’file’ device=’disk’> #磁盘类型为file
<driver name=’qemu’ type=’qcow2′ cache=’none’/> #驱动类型和格式
<source file=’/var/lib/libvirt/images/cfme.qcow2’/> #磁盘文件路径,从CloudForms中解压获取
<target dev=’vda’ bus=’virtio’/> #磁盘名字和总线类型为virtio
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x04′ function=’0x0’/> @@@注意,要删除@@@,否则总线的地址会冲突
</disk>
<disk type=’file’ device=’disk’>
<driver name=’qemu’ type=’qcow2′ cache=’none’/>
<source file=’/var/lib/libvirt/images/cfme_vdb.qcow2’/> #磁盘所在路径,后续创建
<target dev=’vdb’ bus=’virtio’/> #磁盘为vdb
</disk>
g、网卡
<interface type=’network’>
<mac address=’52:54:00:00:00:0c’/> #mac地址
<source network=’br-eth0’/> #桥接网卡,@@注意@@@此处用的是ovs的网桥,如果KVM的网桥,请修改为br0
<virtualport type=’openvswitch’></virtualport> #由于使用openvswitch网桥,需要添加,br0则不用
<model type=’virtio’/>
</interface>
h、VNC
<graphics type=’vnc’ port=’-1′ autoport=’yes’ listen=’0.0.0.0′> #用于VNC连接,防止没有图形界面
<listen type=’address’ address=’0.0.0.0’/>
</graphics>
修改完之后,虚拟机的配置文件内容如下:
cat /etc/libvirt/qemu/cfme.xml
<domain type=’kvm’>
<name>cfme</name>
<uuid>ba845a90-8670-4b89-9451-3a111372950c</uuid>
<memory unit=’KiB’>4194304</memory>
<currentMemory unit=’KiB’>4194304</currentMemory>
<vcpu placement=’static’>4</vcpu>
<os>
<type arch=’x86_64′ machine=’rhel6.5.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</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=’file’ device=’disk’>
<driver name=’qemu’ type=’qcow2′ cache=’none’/>
<source file=’/var/lib/libvirt/images/cfme.qcow2’/>
<target dev=’vda’ bus=’virtio’/>
</disk>
<disk type=’file’ device=’disk’>
<driver name=’qemu’ type=’qcow2′ cache=’none’/>
<source file=’/var/lib/libvirt/images/cfme_vdb.qcow2’/>
<target dev=’vdb’ bus=’virtio’/>
</disk>
<controller type=’usb’ index=’0′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x01′ function=’0x2’/>
</controller>
<controller type=’ide’ index=’0′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x01′ function=’0x1’/>
</controller>
<interface type=’network’>
<mac address=’52:54:00:00:00:0c’/>
<source network=’br-eth0’/>
<virtualport type=’openvswitch’></virtualport>
<model type=’virtio’/>
</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’/>
<graphics type=’vnc’ port=’-1′ autoport=’yes’ listen=’0.0.0.0′>
<listen type=’address’ address=’0.0.0.0’/>
</graphics>
<video>
<model type=’cirrus’ vram=’9216′ 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>
2. 获取CloudForms的虚拟机
为了方便大家使用,我已经放置到网盘中,连接路径:网盘地址:http://pan.baidu.com/s/1hrrmtec
3. 解压CFME虚拟机
[root@foundation0 cfme]# tar -xvf cfme-rhevm-5.3-47.x86_64.rhevm
master/
master/vms/
master/vms/e6b971c2-14bf-43e3-ad38-36d9702afb54/
master/vms/e6b971c2-14bf-43e3-ad38-36d9702afb54/e6b971c2-14bf-43e3-ad38-36d9702afb54.ovf
images/
images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/
images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/143fbb49-1441-4a1a-beaf-f9c6433f3566.meta
images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/143fbb49-1441-4a1a-beaf-f9c6433f3566 #CloudForms的磁盘镜像文件,要的就是该文件
#将CFME文件拷贝至KVM虚拟机目录,并改名字
[root@foundation0 cfme]# ll -h images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/143fbb49-1441-4a1a-beaf-f9c6433f3566
-rwxr-xr-x 1 root root 2.0G Jan 9 2015 images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/143fbb49-1441-4a1a-beaf-f9c6433f3566
[root@foundation0 cfme]# mv images/a2dd2ac4-7a94-4c90-9c86-6a45477cbbb9/143fbb49-1441-4a1a-beaf-f9c6433f3566 /var/lib/libvirt/images/cfme
#基于磁盘镜像文件,创建backing file连接,backing file类似于Linux下的软链接,是一个只读的文件,增量的写内容,都会保存至新的文件,本文即cfme.qcow2中
[root@foundation0 cfme]# qemu-img create -f qcow2 -b /var/lib/libvirt/images/cfme /var/lib/libvirt/images/cfme.qcow2
Formatting ‘/var/lib/libvirt/images/cfme.qcow2′, fmt=qcow2 size=42949672960 backing_file=’/var/lib/libvirt/images/cfme’ encryption=off cluster_size=65536
[root@foundation0 cfme]# qemu-img info /var/lib/libvirt/images/cfme.qcow2
image: /var/lib/libvirt/images/cfme.qcow2
file format: qcow2
virtual size: 40G (42949672960 bytes)
disk size: 200K
cluster_size: 65536
backing file: /var/lib/libvirt/images/cfme #基于该文件,建立的bakcing-file,实现快速的clone
#建立另外一块磁盘
[root@foundation0 cfme]# qemu-img create -f qcow2 /var/lib/libvirt/images/cfme_vdb.qcow2 10G #名字和路径,需要和配置文件中保持一致
Formatting ‘/var/lib/libvirt/images/cfme_vdb.qcow2’, fmt=qcow2 size=10737418240 encryption=off cluster_size=65536
[root@foundation0 cfme]# qemu-img info /var/lib/libvirt/images/cfme_vdb.qcow2
image: /var/lib/libvirt/images/cfme_vdb.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes) #10G的空间
disk size: 140K
cluster_size: 65536
4. 启动虚拟机,并获取VNC的端口号
[root@foundation0 ~]# virsh create /etc/libvirt/qemu/cfme.xml #加载到KVM域内
Domain cfme created from /etc/libvirt/qemu/cfme.xml
[root@foundation0 ~]# virsh
Welcome to virsh, the virtualization interactive terminal.
Type: ‘help’ for help with commands
‘quit’ to quit
virsh # list –all
Id Name State
—————————————————-
6 cfme running
virsh # vncdisplay cfme #查看VNC的端口号,即5900
:0
[root@foundation0 ~]# ifconfig
br-eth0 Link encap:Ethernet HWaddr 00:E0:81:DF:9C:DB
inet addr:10.16.0.60 Bcast:10.16.1.255 Mask:255.255.254.0 #KVM母机的ip地址,使用该地址和VNC端口连接到虚拟机
inet6 addr: fe80::5849:18ff:fee2:5c4e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:351184814 errors:0 dropped:0 overruns:0 frame:0
TX packets:234038352 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:54255684244 (50.5 GiB) TX bytes:56112174185 (52.2 GiB)
5. 使用VNC客户端连接至CFME虚拟机
配置成功,界面如下,默认的username:admin,password:smartvm
5. CloudForms初始化
使用admin:smartvm登陆到系统中,可以自行初始化操作,初始化的操作包括如下内容:
选择8,配置数据库即可,执行1生成key,选择内部internal,设置数据库区域为0,执行完之后,显示如下
查看CloudForms的状态信息
6. 登陆CloudForms
输入https://10.16.1.197即可登陆至CloudForms,由于是https,所需要确认证书,确认证书之后,将会进入到CloudForms的管理界面
输入admin:smartvm即可登陆,登陆之后页面内容
完毕!!!
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-05/130941.htm