#Openstack 雲計算(二): Openstack Rocky部署三 glance 部署與驗證html
標籤(空格分隔):openstack系列python
- 一: glance 概述
- 二: glance 部署
用戶使用鏡像服務 (glance) 容許來建立,查詢虛擬機鏡像。它提供了一個 REST API,容許查詢虛擬機鏡像的 metadata 並獲取一個現存的鏡像 能夠將虛擬機鏡像存儲到各類位置,如簡單的文件系統或者是對象存儲系統,例如 OpenStack 對象存儲, 並經過鏡像服務使用 上傳指定的文件做爲後端配置鏡像服務,默認目錄是 /var/lib/glance/images/。
glance-api: 用於接收鏡像REST API的調用,諸如鏡像查找,獲取,上傳,刪除 glance-registry: 用於與mysql數據庫交互,監聽端口爲9191, 提供鏡像元數據相關的REST接口,用於存儲、處理和恢復鏡像的元數據(metadata),元數據包括項諸如大小和類型。 經過glance-registry能夠向數據庫中寫入或獲取鏡像的各類數據 其中有兩張表,image表保存了鏡像格式大小等信息,image property表保存進行的定製化信息 注意:glance-registry是私有內部服務,用於服務OpenStack Image服務。不能向用戶暴露 image:鏡像文件的存儲倉庫 支持多種類型的倉庫,它們有普通文件系統、對象存儲、RADOS塊設備、HTTP、以及亞馬遜S3。另外,其中一些倉庫僅支持只讀方式使用。 image store: 是一個存儲的接口層,經過這個接口glance能夠獲取鏡像,支持的存儲有亞馬遜的S3,openstack自己的swift,還有ceph,sheepdog,GlusterFS等分佈式存儲 image store是鏡像保存與獲取的接口,僅僅是一個接口層,具體的實現須要外部的存儲支持 數據庫: 存放鏡像元數據,用戶是能夠依據我的喜愛選擇數據庫的,多數的部署使用MySQL或SQLite。 元數據定義服務: 通用的API,是用於爲廠商,管理員,服務,以及用戶自定義元數據。 這種元數據可用於不一樣的資源,例如鏡像,工件,卷,配額以及集合。 一個定義包括了新屬性的鍵,描述,約束以及能夠與之關聯的資源的類型。
mysql -uroot -pflyfish225 CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance'; flush privileges;
openstack user create --domain default --password=glance glance openstack user list
在keystone上將glance用戶添加爲service項目的admin角色(權限) openstack role add --project service --user glance admin 建立glance鏡像服務的實體 openstack service create --name glance --description "OpenStack Image" image openstack service list
建立鏡像服務的 API 端點(endpoint) openstack endpoint create --region RegionOne image public http://10.0.0.11:9292 openstack endpoint create --region RegionOne image internal http://10.0.0.11:9292 openstack endpoint create --region RegionOne image admin http://10.0.0.11:9292 openstack endpoint list 至此,glance在keystone上面註冊完成,能夠進行安裝
在當前版本中有一個bug在Python3.5中可能會有ssl方面的問題,如下是詳情頁面 https://docs.openstack.org/glance/rocky/install/get-started.html#running-glance-under-python3 python --version
yum install openstack-glance python-glance python-glanceclient -y
配置glance-api.conf openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:glance@controller/glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://controller:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password glance openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http openstack-config --set /etc/glance/glance-api.conf glance_store default_store file openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
執行如下命令能夠快速配置glance-registry.conf openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:glance@controller/glance openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://controller:5000 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:5000 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password glance openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
檢查配置命令: grep '^[a-z]' /etc/glance/glance-api.conf grep '^[a-z]' /etc/glance/glance-registry.conf 至此,glance服務安裝完畢,該服務須要啓動
su -s /bin/sh -c "glance-manage db_sync" glance
systemctl start openstack-glance-api.service openstack-glance-registry.service systemctl status openstack-glance-api.service openstack-glance-registry.service systemctl enable openstack-glance-api.service openstack-glance-registry.service systemctl list-unit-files |grep openstack-glance*
能夠下載小型的Linux鏡像CirrOS用來進行 OpenStack部署測試。 cd /root wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public openstack image list
至此glance鏡像服務安裝完成,啓動成功