您好,登錄后才能下訂單哦!
鏡像服務(wù)使用戶能夠發(fā)現(xiàn)、注冊和檢索虛擬機(jī)鏡像。它提供了一個(gè)REST API,使您能夠查詢虛擬機(jī)鐿像元數(shù)據(jù)并檢索實(shí)際鐿像。您可以將鏡像服務(wù)提供的虛擬機(jī)鏡像存儲在各種位置,從簡單的文件系統(tǒng)到對象存儲系統(tǒng)(如OpenStack對象存儲)。
OpenStack鏡像服務(wù)是基礎(chǔ)設(shè)施即服務(wù)(IaaS)的核心。它接受對磁盤或服務(wù)器鏡像的API請求,以及來自最終用戶或OpenStack計(jì)算組件的元數(shù)據(jù)定義。它還支持在各種存儲庫類型上存儲磁盤或服務(wù)器鏡像,包括OpenStack對象存儲。
為了支持緩存,OpenStack鏡像服務(wù)上運(yùn)行了許多周期性進(jìn)程。復(fù)制服務(wù)通過集群確保一致性和可用性。其他周期性過程包括審核員、更新人員和收割者。
OpenStack鏡像服務(wù)包括以下組件:
安裝鏡像服務(wù)之前, 我們必須建立數(shù)據(jù)庫,服務(wù)憑據(jù),API端點(diǎn).
○ 連接到數(shù)據(jù)庫,可以在本機(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ù)實(shí)體
# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 4dba7578eae342d88c131e1c90768518 |
| name | glance |
| type | image |
+-------------+----------------------------------+
○ 建立鏡像服務(wù)API端點(diǎn):
# 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ū)域, 配置身份認(rèn)證服務(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ū)域中的其它的選項(xiàng).
○ 在[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ū)域中的其它的選項(xiàng).
# su -s /bin/sh -c "glance-manage db_sync" glance
允許系統(tǒng)引導(dǎo)時(shí)自動(dòng)啟動(dòng)服務(wù)并啟動(dòng)服務(wù):
# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
# systemctl start openstack-glance-api.service \
openstack-glance-registry.service
使用cirros做為鏡像服務(wù)校驗(yàn)操作,這是一個(gè)很小的linux鏡像,幫助我們測試openstack環(huán)境,執(zhí)行下列的命令在controller節(jié)點(diǎn)上.
$ . 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 |
+------------------+------------------------------------------------------+
確認(rèn)上傳的鏡像和ID:
$ openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | active |
+--------------------------------------+--------+--------+
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。