2021-05-12 14:32:11
RHCA CL220實戰系列(一)之KVM部署CloudForms
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
相關文章