目录
Image service overview
官档:The Image service (glance) enables users to discover, register, and retrieve virtual machine images. It offers a REST API that enables you to query virtual machine image metadata and retrieve an actual image. You can store virtual machine images made available through the Image service in a variety of locations, from simple file systems to object-storage systems like OpenStack Object Storage.
粗译:Image service (glance)使用户能够发现、注册、检索虚拟机镜像。它提供了一个REST API让你能够查询虚拟机镜像的元数据和检索一个实际的镜像。无论是一个简单的file systems还是一个OpenStack Object Storage,你都可以通过Image service在各种不同的位置上存储一个虚拟机镜像。
Important:
For simplicity, this guide describes configuring the Image service to use the file back end, which uploads and stores in a directory on the controller node hosting the Image service. By default, this directory is /var/lib/glance/images/.
Before you proceed, ensure that the controller node has at least several gigabytes of space available in this directory.
重要提示:为了简单起见,该指南记录了使用Controller Node中的目录来上传和存储镜像文件。默认的,这个目录是<code>/var/lib/glance/images/</code>。
在开始之前,确定Controller Node上的镜像存储目录还有几个G的空间。
官档:The OpenStack Image service is central to Infrastructure-as-a-Service (IaaS) as shown in Conceptual architecture. It accepts API requests for disk or server images, and metadata definitions from end users or OpenStack Compute components. It also supports the storage of disk or server images on various repository types, including OpenStack Object Storage.
A number of periodic processes run on the OpenStack Image service to support caching. Replication services ensure consistency and availability through the cluster. Other periodic processes include auditors, updaters, and reapers.
粗译:Openstack Image service是IaaS中非常重要的组件。它能够为磁盘或者服务器镜像接受来自于User或者Openstack Compute service的API请求和元数据定义。它也支持磁盘存储、服务器镜像、OpenStack Object Storage等何种存储方式。OpenStack Image service还运行着一些周期性的进程来支持缓存。而且同步服务(Replication services)还能确保集群中的镜像的一致性和可用性。其他的周期性进程还包括auditors, updaters, and reapers。
glance-api:提供了Image service的发现、检索、存储功能的API调用。
glance-registry:用于存储、处理、检索Image元数据。这些元数据包含了镜像的size和type等信息。需要注意的是,注册(glance-registry)是OpenStack Image service私有的内部服务,这意味着不能向User公开该服务。
Database:用于存储Image的元数据,支持大多数Database种类,常使用MySQL或SQLite来实现。
Storage repository for image files(镜像文件的存储仓库):支持多种存储类型,包括file systems、Object Storage、RADOS block devices、HTTP、Amazon S3等类型。但有些存储类型只支持只读访问。
Metadata definition service(元数据定义服务):是一个统一的vendors API,管理员、服务、用户可以定义他们所拥有的自定义元数据(custom metadata)。这个自定义的元数据可以使用不同的资源类型,如:images、artifacts、volumes、flavors、aggregates。定义包含了new property’s key、description、constraints和相关的资源类型。
Install and configure
在Controller Node上安装并配置OpenStack Image service
Before you install and configure the Image service, you must create a database, service credentials, and API endpoints.
在安装个配置Image service之前,你必须创建一个Database,service credentials,API endpoints。
Use the database access client to connect to the database server as the root
以数据库管理员root的身份登录数据库
Create the glance database
创建glance数据库
Grant proper access to the glance database
创建数据库用户glance,并授予其对glance数据库的管理权限
Exit the database access client.
创建服务凭证
Source the admin credentials to gain access to admin-only CLI commands
Create the glance user
创建glance用户
Add the admin role to the glance user and service project
添加Project service和User glance到Role admin中
Create the glance service entity
创建glance服务实体,将Image service加入到服务目录。
Create the Image service API endpoints
为OpenStack Image service创建认证服务端点
Install and configure components
In the [database] section, configure database access
配置Image service的数据库连接
vim /etc/glance/glance-api.conf
配置详细日志报告
In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access
配置Identity service访问
注意:在<code>[keystone_authtoken]</code> 节点中,注释或删除其他别的选项。
In the [glance_store] section, configure the local file system store and location of image files
配置本地文件系统存储和镜像文件的存放路径
总览
vim /etc/glance/glance-registry.conf
Note:忽略所有的警告输出信息
查看glance数据库:
Finalize installation
Verify operation验证操作
Verify operation of the Image service using CirrOS, a small Linux image that helps you test your OpenStack deployment.
使用<code>CirrOS</code>镜像来进行Image service的测试操作,<code>CirrOS</code>是一个小型的Linux镜像文件。
Note:在Controller Node上执行下列操作
1.Source the admin credentials to gain access to admin-only CLI commands
2.Download the source image
3.Upload the image to the Image service using the QCOW2 disk format, bare container format, and public visibility so all projects can access it
以<code>QCOW2</code>的磁盘格式、<code>bare</code>容器格式、<code>public visibility</code>的方式将镜像上传到Image service,所以所有的用户都能否访问这个镜像。
Example:
查看镜像文件存储目录:
ERROR1:500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
解决:<code>systemctl restart mariadb.service</code>
ERROR2:An unexpected error prevented the server from fulfilling your request.
Glance Log:
解决:重启Controller Node主机
4.Confirm upload of the image and validate attributes
至此Openstack Image service的安装就完成