鏡像服務(wù)使用戶能夠發(fā)現(xiàn)、注冊和檢索虛擬機鏡像。它提供了一個REST API,使您能夠查詢虛擬機鐿像元數(shù)據(jù)并檢索實際鐿像。您可以將鏡像服務(wù)提供的虛擬機鏡像存儲在各種位置,從簡單的文件系統(tǒng)到對象存儲系統(tǒng)(如OpenStack對象存儲)。
OpenStack鏡像服務(wù)是基礎(chǔ)設(shè)施即服務(wù)(IaaS)的核心。它接受對磁盤或服務(wù)器鏡像的API請求,以及來自最終用戶或OpenStack計算組件的元數(shù)據(jù)定義。它還支持在各種存儲庫類型上存儲磁盤或服務(wù)器鏡像,包括OpenStack對象存儲。
為了支持緩存,OpenStack鏡像服務(wù)上運行了許多周期性進程。復(fù)制服務(wù)通過集群確保一致性和可用性。其他周期性過程包括審核員、更新人員和收割者。
OpenStack鏡像服務(wù)包括以下組件:
創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、做網(wǎng)站、洛扎網(wǎng)絡(luò)推廣、微信小程序、洛扎網(wǎng)絡(luò)營銷、洛扎企業(yè)策劃、洛扎品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)建站為所有大學(xué)生創(chuàng)業(yè)者提供洛扎建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com
安裝鏡像服務(wù)之前, 我們必須建立數(shù)據(jù)庫,服務(wù)憑據(jù),API端點.
○ 連接到數(shù)據(jù)庫,可以在本機也可以使用mysql客戶端連接:
$ mysql -u root -proot123
○ 建立glance數(shù)據(jù)庫:
MariaDB [(none)]> CREATE DATABASE glance;
○ 授予相應(yīng)的權(quán)限給glance數(shù)據(jù)庫,密碼統(tǒng)一為用戶名后加123:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance123';
$ . admin-openrc
建立服務(wù)的憑據(jù),完成下列步驟:
○ 建立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服務(wù)實體
# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 4dba7578eae342d88c131e1c90768518 |
| name | glance |
| type | image |
+-------------+----------------------------------+
○ 建立鏡像服務(wù)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]區(qū)域, 配置數(shù)據(jù)庫訪問:
[database]
# ...
connection = mysql+pymysql://glance:glance123@dbs.flex.net/glance
○ 在[keystone_authtoken]和[paste_deploy]區(qū)域, 配置身份認證服務(wù)訪問:
[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]區(qū)域中的其它的選項.
○ 在[glance_store]區(qū)域, 配置本地文件存儲和鏡像文件的位置:
[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]區(qū)域中的其它的選項.
# su -s /bin/sh -c "glance-manage db_sync" glance
允許系統(tǒng)引導(dǎo)時自動啟動服務(wù)并啟動服務(wù):
# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
# systemctl start openstack-glance-api.service \
openstack-glance-registry.service
使用cirros做為鏡像服務(wù)校驗操作,這是一個很小的linux鏡像,幫助我們測試openstack環(huán)境,執(zhí)行下列的命令在controller節(jié)點上.
$ . admin-openrc
$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
上傳鏡像使用qcow2磁盤格式,bare 格式和公開權(quán)限訪問:
$ 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 |
+--------------------------------------+--------+--------+