十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
镜像服务使用户能够发现、注册和检索虚拟机镜像。它提供了一个REST API,使您能够查询虚拟机镱像元数据并检索实际镱像。您可以将镜像服务提供的虚拟机镜像存储在各种位置,从简单的文件系统到对象存储系统(如OpenStack对象存储)。
OpenStack镜像服务是基础设施即服务(IaaS)的核心。它接受对磁盘或服务器镜像的API请求,以及来自最终用户或OpenStack计算组件的元数据定义。它还支持在各种存储库类型上存储磁盘或服务器镜像,包括OpenStack对象存储。
为了支持缓存,OpenStack镜像服务上运行了许多周期性进程。复制服务通过集群确保一致性和可用性。其他周期性过程包括审核员、更新人员和收割者。
OpenStack镜像服务包括以下组件:
创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于成都网站制作、做网站、洛扎网络推广、微信小程序、洛扎网络营销、洛扎企业策划、洛扎品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供洛扎建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com
安装镜像服务之前, 我们必须建立数据库,服务凭据,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 |
+--------------------------------------+--------+--------+