辛子龍 梁棟茂 馬睿 鄒勱豪 張繼鵬

摘 要:近兩年,IT領域中,云計算和大數據是非常熱門的研究方向,OpenStack是云計算IaaS(基礎設施即服務)中重要的開源的云計算管理平臺,主要由Dashboard(控制臺)、Nova(計算)、Neutron(網絡)、Swift(對象存儲)、Cinder(塊存儲)、Glance(鏡像)、Keystone(認證)等服務組成。本文重點介紹OpenStack中的Glance服務,描述Glance服務在OpenStack平臺的地位和與其他服務的關聯,分別對Glance組件的服務架構、鏡像格式、鏡像狀態、鏡像制作進行簡要說明,提出一種適合實驗室或中小企業的基于OpenStack的私有云構建方案,并闡述了安裝步驟流程。
關鍵詞:OpenStack;Glance;鏡像服務;鏡像管理
中圖分類號:TP311.52文獻標識碼:A文章編號: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
隨著云計算時代的到來,基于IaaS層(基礎設施即服務)的云計算管理平臺不斷涌現,如AbiCloud、Hadoop、Eucalyptus、MongoDB、OpenStack等平臺。作為開源云管理平臺,OpenStack得到越來越多科研人員和企業的青睞[1-3]。Glance服務作為OpebStack平臺中Nova服務中獨立的服務,不僅大大減小了Nova服務的冗余,還提升了鏡像的儲存和管理能力[4-5]。
1 Glance服務在OpenStack框架中的位置和任務
OpenStack為一個開源的云計算解決方案,它主要利用Python語言進行編寫,主要通過命令行(ACL)、程序接口(API)和Web界面(GUI)實現對底層計算、存儲、網絡等資源的控制。它的功能是由多個子項目協同實現的,分別是Swift、Nova、Keystone、Glance、Neutron及Horizon等。其中,Glance是OpenStack重要的鏡像查詢、管理、注冊、傳輸組件,云主機的創建、啟動、快照等服務都需要調動Glance組件。
OpenStack由多個單元組成。其中,Heat單元的作用是編排云;Horizon組件為其他云服務提供一個基于Web的操作界面;Ceilometer負責監視其他模塊,其他模塊通過Keystone進行身份認證;虛擬機(VM)是實現云計算的核心,Nova負責創建VM;Glance提供鏡像給虛擬機;Cinder提供快存儲服務給虛擬機;Neutron提供虛擬機的網絡活動及服務;Swift負責OpenStack的對象的存儲,可保存Glance的鏡像文件和Cinder的備份卷。
Glance組件的主要任務是為OpenStack提供鏡像服務,它提供了虛擬鏡像的查詢、注冊和傳輸等服務。Glance本身并不能實現對鏡像的存儲功能。Glance只是一個代理,它充當了鏡像存儲服務與OpenStack的其他組件之間的紐帶。Glance共支持兩種鏡像存儲機制,即簡單文件系統和Swift服務存儲鏡像機制。簡單文件系統是指將鏡像保存在Glance節點的文件系統中。這種機制相對比較簡單,但是存在不足。比如,由于沒有備份機制,一旦文件系統受到損傷,將導致所有鏡像不可用。Swift服務存儲鏡像機制,是指將鏡像以對象的形式保存在Swift對象存儲服務器中,Swift具有非常強大的備份還原機制,因此可以減少因為文件系統損傷而造成的鏡像不可用情況。
2 Glance服務的服務架構
2.1 服務架構組成
Glance鏡像服務使用了C/S(客戶端/服務器)架構,Glance主要包括REST API、數據庫抽象層、后端存儲、域控制器、注冊層,使用Glance DB數據庫在各組件中共享數據。
REST API是Glance服務的程序接口。
數據庫抽象層是Glance服務與數據庫的程序接口。對于后端存儲,鏡像實際存儲位置可以接入簡單文件系統,如Swift(塊存儲)和Ceph(分布式文件系統)等,其也可以存儲在Openatack控制節點的/var/lib/Glance/images中。
域控制器是實現Glance的認證、策略、通知和數據鏈路信息交換的中間件。
注冊層用于域控制器和數據庫DAL層之間的安全通息。
Glance DB用于存儲鏡像的元數據。
2.2 配置文件
Glance服務擁有兩個配置文件,分別為Glance-api.conf與Glance-registry.conf。
Glance-api.conf配置數控鏈接字符串、Rabbitmq服務器、Keystone認證和日志文件,
Glance-registry.conf配置數控鏈接字符串、keystone認證和日志文件。
3 Glance鏡像文件格式
虛擬機鏡像需要指定磁盤格式。常見的鏡像格式有RAW、QCOW2、AMI、UEC tarball、VHD、VDI、VMDK和OVF,OpenStack默認啟動KVM虛擬機的格式為QCOW2,是一個支持可動態擴展、復制的磁盤格式。RAM是一個裸格式的磁盤格式,它擁有便攜的文件讀取和下載功能,沒有做任何修飾,擁有良好的性能表現,可以與其他格式的鏡像快速互換。
4 Glance服務中images狀態
OpenStack中鏡像系統較大,從鏡像開始上傳到鏡像完成上傳需要較長的時間,其在Glance中通過異步任務的方式一步步完成,包括以下狀態:排隊(Queued)、保存中(Saving)、有效(Active)、無效(Deactivated)、錯誤(Killed)、被刪除(Deleted)和等待刪除(Pending_delete)。
5 Glance服務的部署
準備Centos7.4基本環境,配置yum源,關閉必要防火墻,多節點網絡互通。
修改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 結語
本文對OpenStack中核心組件Glance進行全面的分析和安裝,對其工作原理進行詳細闡述,這對更好地理解和使用Glance具有重要的意義。當前,人們可以利用開源的OpenStack組件快速構建一個Glance鏡像存儲系統,為科研工作或企業用戶提供更好的鏡像存儲服務,并通過OpenStack完成云主機的部署。
參考文獻:
[1]李知杰,趙健飛.OpenStack開源云計算平臺[J].軟件導刊,2012(12):10-12.
[2]Vinoski S.Advanced Message Queuing Protocol[J].IEEE Internet Computing,2006(6):87-89.
[3]沈建國,陳勇.OpenStack云平臺基礎架構平臺[M].北京:人民郵電出版社,2017.
[4]劉瑋瑋.基于OpenStack+Swift的企業云盤設計與實現[J].電子測試,2018(24):77-78.
[5]毛軍禮.OpenStack之Nova服務[J].計算機與網絡,2018(3):60-63.