您好,登錄后才能下訂單哦!
鏡像服務使用戶能夠發現、注冊和檢索虛擬機鏡像。它提供了一個REST API,使您能夠查詢虛擬機鐿像元數據并檢索實際鐿像。您可以將鏡像服務提供的虛擬機鏡像存儲在各種位置,從簡單的文件系統到對象存儲系統(如OpenStack對象存儲)。
OpenStack鏡像服務是基礎設施即服務(IaaS)的核心。它接受對磁盤或服務器鏡像的API請求,以及來自最終用戶或OpenStack計算組件的元數據定義。它還支持在各種存儲庫類型上存儲磁盤或服務器鏡像,包括OpenStack對象存儲。
為了支持緩存,OpenStack鏡像服務上運行了許多周期性進程。復制服務通過集群確保一致性和可用性。其他周期性過程包括審核員、更新人員和收割者。
OpenStack鏡像服務包括以下組件:
安裝鏡像服務之前, 我們必須建立數據庫,服務憑據,API端點.
○ 連接到數據庫,可以在本機也可以使用mysql客戶端連接:
$ mysql -u root -proot123
○ 建立glance數據庫:
MariaDB [(none)]> CREATE DATABASE glance;
○ 授予相應的權限給glance數據庫,密碼統一為用戶名后加123:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance123';
$ . admin-openrc
建立服務的憑據,完成下列步驟:
○ 建立glance用戶:
# openstack user create --domain default --password-prompt glance
User Password: glance123
Repeat User Password:glance123
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 288f544d71f04eefb7389bd8af685b3b |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
○ 添加管理員角色給glance用戶和service project:
# openstack role add --project service --user glance admin
注意:此輸出無信息
○ 建立glance服務實體
# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 4dba7578eae342d88c131e1c90768518 |
| name | glance |
| type | image |
+-------------+----------------------------------+
○ 建立鏡像服務API端點:
# openstack endpoint create --region RegionOne image public http://stack.flex.net:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 340be3625e9b4239a6415d034e98aace |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b49ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne image internal http://stack.flex.net:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b49ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne image admin http://stack.flex.net:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 0c37ed58103f4300a84ff125a539032d |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b949ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
# yum install openstack-glance
vi編輯/etc/glance/glance-api.conf并且完成下列修改:
○ 在[database]區域, 配置數據庫訪問:
[database]
# ...
connection = mysql+pymysql://glance:glance123@dbs.flex.net/glance
○ 在[keystone_authtoken]和[paste_deploy]區域, 配置身份認證服務訪問:
[keystone_authtoken]
# ...
www_authenticate_uri = http://stack.flex.net:5000
auth_url = http://stack.flex.net:5000
memcached_servers = dbs.flex.net:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance123
[paste_deploy]
# ...
flavor = keystone
注意: 注釋或移除在掉在[keystone_authtoken]區域中的其它的選項.
○ 在[glance_store]區域, 配置本地文件存儲和鏡像文件的位置:
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
編輯/etc/glance/glance-registry.conf并且完成下列修改:
○ In the [database] section, configure database access:
[database]
# ...
connection = mysql+pymysql://glance:glance123@dbs.flex.net/glance
○ In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access:
[keystone_authtoken]
# ...
www_authenticate_uri = http://stack.flex.net:5000
auth_url = http://stack.flex.net:5000
memcached_servers = dbs.flex.net:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance123
[paste_deploy]
# ...
flavor = keystone
注意: 注釋或移除在掉在[keystone_authtoken]區域中的其它的選項.
# su -s /bin/sh -c "glance-manage db_sync" glance
允許系統引導時自動啟動服務并啟動服務:
# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
# systemctl start openstack-glance-api.service \
openstack-glance-registry.service
使用cirros做為鏡像服務校驗操作,這是一個很小的linux鏡像,幫助我們測試openstack環境,執行下列的命令在controller節點上.
$ . admin-openrc
$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
上傳鏡像使用qcow2磁盤格式,bare 格式和公開權限訪問:
$ openstack image create "cirros" \
--file cirros-0.4.0-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2015-03-26T16:52:10Z |
| disk_format | qcow2 |
| file | /v2/images/cc5c6982-4910-471e-b864-1098015901b5/file |
| id | cc5c6982-4910-471e-b864-1098015901b5 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | ae7a98326b9c455588edd2656d723b9d |
| protected | False |
| schema | /v2/schemas/image |
| size | 13200896 |
| status | active |
| tags | |
| updated_at | 2015-03-26T16:52:10Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
確認上傳的鏡像和ID:
$ openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | active |
+--------------------------------------+--------+--------+
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。