辛子龍 梁棟茂 馬睿 鄒勱豪 張繼鵬
摘 要:近兩年,IT領(lǐng)域中,云計(jì)算和大數(shù)據(jù)是非常熱門(mén)的研究方向,OpenStack是云計(jì)算IaaS(基礎(chǔ)設(shè)施即服務(wù))中重要的開(kāi)源的云計(jì)算管理平臺(tái),主要由Dashboard(控制臺(tái))、Nova(計(jì)算)、Neutron(網(wǎng)絡(luò))、Swift(對(duì)象存儲(chǔ))、Cinder(塊存儲(chǔ))、Glance(鏡像)、Keystone(認(rèn)證)等服務(wù)組成。本文重點(diǎn)介紹OpenStack中的Glance服務(wù),描述Glance服務(wù)在OpenStack平臺(tái)的地位和與其他服務(wù)的關(guān)聯(lián),分別對(duì)Glance組件的服務(wù)架構(gòu)、鏡像格式、鏡像狀態(tài)、鏡像制作進(jìn)行簡(jiǎn)要說(shuō)明,提出一種適合實(shí)驗(yàn)室或中小企業(yè)的基于OpenStack的私有云構(gòu)建方案,并闡述了安裝步驟流程。
關(guān)鍵詞:OpenStack;Glance;鏡像服務(wù);鏡像管理
中圖分類號(hào):TP311.52文獻(xiàn)標(biāo)識(shí)碼:A文章編號(hào):1003-5168(2020)23-0033-03
Abstract: In the past two years, cloud computing and big data have been very popular research directions in the IT field, OpenStack is an important open source cloud computing management platform in cloud computing IaaS (infrastructure as a service), which is mainly composed of Dashboard (console), Nova (computing), Neutron (network), Swift (object storage), Cinder (block storage), Glance (mirror), Keystone (authentication) and other services. This paper focused on the Glance service in OpenStack, and described the position of the Glance service in the OpenStack platform and its association with other services, and briefly described the service architecture, image format, image status and image production of Glance components, and proposed an OpenStack-based private cloud construction plan suitable for laboratories or small and medium-sized enterprises, and explained the installation process.
Keywords: OpenStack;Glance;image service;image management
隨著云計(jì)算時(shí)代的到來(lái),基于IaaS層(基礎(chǔ)設(shè)施即服務(wù))的云計(jì)算管理平臺(tái)不斷涌現(xiàn),如AbiCloud、Hadoop、Eucalyptus、MongoDB、OpenStack等平臺(tái)。作為開(kāi)源云管理平臺(tái),OpenStack得到越來(lái)越多科研人員和企業(yè)的青睞[1-3]。Glance服務(wù)作為OpebStack平臺(tái)中Nova服務(wù)中獨(dú)立的服務(wù),不僅大大減小了Nova服務(wù)的冗余,還提升了鏡像的儲(chǔ)存和管理能力[4-5]。
1 Glance服務(wù)在OpenStack框架中的位置和任務(wù)
OpenStack為一個(gè)開(kāi)源的云計(jì)算解決方案,它主要利用Python語(yǔ)言進(jìn)行編寫(xiě),主要通過(guò)命令行(ACL)、程序接口(API)和Web界面(GUI)實(shí)現(xiàn)對(duì)底層計(jì)算、存儲(chǔ)、網(wǎng)絡(luò)等資源的控制。它的功能是由多個(gè)子項(xiàng)目協(xié)同實(shí)現(xiàn)的,分別是Swift、Nova、Keystone、Glance、Neutron及Horizon等。其中,Glance是OpenStack重要的鏡像查詢、管理、注冊(cè)、傳輸組件,云主機(jī)的創(chuàng)建、啟動(dòng)、快照等服務(wù)都需要調(diào)動(dòng)Glance組件。
OpenStack由多個(gè)單元組成。其中,Heat單元的作用是編排云;Horizon組件為其他云服務(wù)提供一個(gè)基于Web的操作界面;Ceilometer負(fù)責(zé)監(jiān)視其他模塊,其他模塊通過(guò)Keystone進(jìn)行身份認(rèn)證;虛擬機(jī)(VM)是實(shí)現(xiàn)云計(jì)算的核心,Nova負(fù)責(zé)創(chuàng)建VM;Glance提供鏡像給虛擬機(jī);Cinder提供快存儲(chǔ)服務(wù)給虛擬機(jī);Neutron提供虛擬機(jī)的網(wǎng)絡(luò)活動(dòng)及服務(wù);Swift負(fù)責(zé)OpenStack的對(duì)象的存儲(chǔ),可保存Glance的鏡像文件和Cinder的備份卷。
Glance組件的主要任務(wù)是為OpenStack提供鏡像服務(wù),它提供了虛擬鏡像的查詢、注冊(cè)和傳輸?shù)确?wù)。Glance本身并不能實(shí)現(xiàn)對(duì)鏡像的存儲(chǔ)功能。Glance只是一個(gè)代理,它充當(dāng)了鏡像存儲(chǔ)服務(wù)與OpenStack的其他組件之間的紐帶。Glance共支持兩種鏡像存儲(chǔ)機(jī)制,即簡(jiǎn)單文件系統(tǒng)和Swift服務(wù)存儲(chǔ)鏡像機(jī)制。簡(jiǎn)單文件系統(tǒng)是指將鏡像保存在Glance節(jié)點(diǎn)的文件系統(tǒng)中。這種機(jī)制相對(duì)比較簡(jiǎn)單,但是存在不足。比如,由于沒(méi)有備份機(jī)制,一旦文件系統(tǒng)受到損傷,將導(dǎo)致所有鏡像不可用。Swift服務(wù)存儲(chǔ)鏡像機(jī)制,是指將鏡像以對(duì)象的形式保存在Swift對(duì)象存儲(chǔ)服務(wù)器中,Swift具有非常強(qiáng)大的備份還原機(jī)制,因此可以減少因?yàn)槲募到y(tǒng)損傷而造成的鏡像不可用情況。
2 Glance服務(wù)的服務(wù)架構(gòu)
2.1 服務(wù)架構(gòu)組成
Glance鏡像服務(wù)使用了C/S(客戶端/服務(wù)器)架構(gòu),Glance主要包括REST API、數(shù)據(jù)庫(kù)抽象層、后端存儲(chǔ)、域控制器、注冊(cè)層,使用Glance DB數(shù)據(jù)庫(kù)在各組件中共享數(shù)據(jù)。
REST API是Glance服務(wù)的程序接口。
數(shù)據(jù)庫(kù)抽象層是Glance服務(wù)與數(shù)據(jù)庫(kù)的程序接口。對(duì)于后端存儲(chǔ),鏡像實(shí)際存儲(chǔ)位置可以接入簡(jiǎn)單文件系統(tǒng),如Swift(塊存儲(chǔ))和Ceph(分布式文件系統(tǒng))等,其也可以存儲(chǔ)在Openatack控制節(jié)點(diǎn)的/var/lib/Glance/images中。
域控制器是實(shí)現(xiàn)Glance的認(rèn)證、策略、通知和數(shù)據(jù)鏈路信息交換的中間件。
注冊(cè)層用于域控制器和數(shù)據(jù)庫(kù)DAL層之間的安全通息。
Glance DB用于存儲(chǔ)鏡像的元數(shù)據(jù)。
2.2 配置文件
Glance服務(wù)擁有兩個(gè)配置文件,分別為Glance-api.conf與Glance-registry.conf。
Glance-api.conf配置數(shù)控鏈接字符串、Rabbitmq服務(wù)器、Keystone認(rèn)證和日志文件,
Glance-registry.conf配置數(shù)控鏈接字符串、keystone認(rèn)證和日志文件。
3 Glance鏡像文件格式
虛擬機(jī)鏡像需要指定磁盤(pán)格式。常見(jiàn)的鏡像格式有RAW、QCOW2、AMI、UEC tarball、VHD、VDI、VMDK和OVF,OpenStack默認(rèn)啟動(dòng)KVM虛擬機(jī)的格式為QCOW2,是一個(gè)支持可動(dòng)態(tài)擴(kuò)展、復(fù)制的磁盤(pán)格式。RAM是一個(gè)裸格式的磁盤(pán)格式,它擁有便攜的文件讀取和下載功能,沒(méi)有做任何修飾,擁有良好的性能表現(xiàn),可以與其他格式的鏡像快速互換。
4 Glance服務(wù)中images狀態(tài)
OpenStack中鏡像系統(tǒng)較大,從鏡像開(kāi)始上傳到鏡像完成上傳需要較長(zhǎng)的時(shí)間,其在Glance中通過(guò)異步任務(wù)的方式一步步完成,包括以下?tīng)顟B(tài):排隊(duì)(Queued)、保存中(Saving)、有效(Active)、無(wú)效(Deactivated)、錯(cuò)誤(Killed)、被刪除(Deleted)和等待刪除(Pending_delete)。
5 Glance服務(wù)的部署
準(zhǔn)備Centos7.4基本環(huán)境,配置yum源,關(guān)閉必要防火墻,多節(jié)點(diǎn)網(wǎng)絡(luò)互通。
修改Glance配置文件
修改配置文件glance-api.conf
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_host controller
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_port 35357
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_protocol http
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password 000000
[root@controller ~]#openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
修改配置文件glance-registry.conf
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_host controller
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_port 35357
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_protocol http
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password 000000
[root@controller ~]#openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
6 結(jié)語(yǔ)
本文對(duì)OpenStack中核心組件Glance進(jìn)行全面的分析和安裝,對(duì)其工作原理進(jìn)行詳細(xì)闡述,這對(duì)更好地理解和使用Glance具有重要的意義。當(dāng)前,人們可以利用開(kāi)源的OpenStack組件快速構(gòu)建一個(gè)Glance鏡像存儲(chǔ)系統(tǒng),為科研工作或企業(yè)用戶提供更好的鏡像存儲(chǔ)服務(wù),并通過(guò)OpenStack完成云主機(jī)的部署。
參考文獻(xiàn):
[1]李知杰,趙健飛.OpenStack開(kāi)源云計(jì)算平臺(tái)[J].軟件導(dǎo)刊,2012(12):10-12.
[2]Vinoski S.Advanced Message Queuing Protocol[J].IEEE Internet Computing,2006(6):87-89.
[3]沈建國(guó),陳勇.OpenStack云平臺(tái)基礎(chǔ)架構(gòu)平臺(tái)[M].北京:人民郵電出版社,2017.
[4]劉瑋瑋.基于OpenStack+Swift的企業(yè)云盤(pán)設(shè)計(jì)與實(shí)現(xiàn)[J].電子測(cè)試,2018(24):77-78.
[5]毛軍禮.OpenStack之Nova服務(wù)[J].計(jì)算機(jī)與網(wǎng)絡(luò),2018(3):60-63.