OpenStack控制節(jié)點(diǎn)Image服務(wù)安裝部署

介紹

Image Service 的功能是管理Image,讓用戶能夠發(fā)現(xiàn)、獲取和保存 Image。該服務(wù)僅運(yùn)行在控制節(jié)點(diǎn)。

在 OpenStack 中,提供 Image Service 的是 Glance,其具體功能如下:

提供 REST API 讓用戶能夠查詢和獲取 image 的元數(shù)據(jù)和 image 本身

支持多種方式存儲(chǔ) image,包括普通的文件系統(tǒng)、Swift、Amazon S3 等

對(duì) Instance 執(zhí)行 Snapshot 創(chuàng)建新的 image

創(chuàng)建數(shù)據(jù)庫(kù)

root用戶登錄數(shù)據(jù)庫(kù)

sudo mysql

創(chuàng)建glance數(shù)據(jù)庫(kù)

CREATE DATABASE glance;

創(chuàng)建glance數(shù)據(jù)庫(kù)用戶并授予權(quán)限

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';

替換GLANCE_DBPASS為你自己的密碼

創(chuàng)建服務(wù)憑證

使用管理員用戶

. admin-openrc

在openstack中創(chuàng)建glance用戶

openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 3f4e777c4062483ab8d9edd7dff829df |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

添加admin角色到glance用戶和service工程中

openstack role add --project service --user glance admin

創(chuàng)建glance服務(wù)

openstack service create --name glance \
--description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

創(chuàng)建image服務(wù)API

openstack endpoint create --region RegionOne \
image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 340be3625e9b4239a6415d034e98aace |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne \
image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne \
image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 0c37ed58103f4300a84ff125a539032d |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

安裝和配置組件

安裝

sudo apt install glance

修改/etc/glance/glance-api.conf文件

配置數(shù)據(jù)庫(kù)訪問(wèn)

[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance

替換GLANCE_DBPASS為你自己的密碼

配置認(rèn)證服務(wù)訪問(wèn)

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS

[paste_deploy]
flavor = keystone

替換GLANCE_PASS為你自己的密碼,并且刪除文件中其他的[keystone_authtoken]部分

配置本地文件系統(tǒng)存儲(chǔ)和鏡像文件路徑

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

修改 /etc/glance/glance-registry.conf 文件配置

數(shù)據(jù)庫(kù)訪問(wèn)

[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance

配置認(rèn)證服務(wù)訪問(wèn)

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS

[paste_deploy]
flavor = keystone

替換GLANCE_PASS為你自己的密碼

導(dǎo)入image服務(wù)數(shù)據(jù)庫(kù)

sudo -s /bin/sh -c "glance-manage db_sync" glance

完成安裝重新啟動(dòng)

sudo service glance-registry restart
sudo service glance-api restart

驗(yàn)證

使用admin用戶登錄

. admin-openrc

下載鏡像

在下載之前由于使用到wget命令,需要配置http代理后使用wget命令

export http_proxy=http://172.17.30.100:50080
export https_proxy=https://172.17.30.100:50080
sudo http_proxy=$http_proxy https_proxy=$https_proxy wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img

以qcw2的磁盤(pán)格式、bare容器格式、所有人可見(jiàn)的方式將鏡像上傳到Image service

openstack image create "cirros" \
--file cirros-0.3.5-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)鏡像已上傳:

openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | active |
+--------------------------------------+--------+--------+
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容