目录
前文列表
Image service overview
官档:The Image service (glance) enables users to discover, register, and retrieve virtual machine p_w_picpaths. It offers a REST API that enables you to query virtual machine p_w_picpath metadata and retrieve an actual p_w_picpath. You can store virtual machine p_w_picpaths 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/p_w_picpaths/. Before you proceed, ensure that the controller node has at least several gigabytes of space available in this directory.重要提示:为了简单起见,该指南记录了使用Controller Node中的目录来上传和存储镜像文件。默认的,这个目录是/var/lib/glance/p_w_picpaths/
。
官档: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 p_w_picpaths, and metadata definitions from end users or OpenStack Compute components. It also supports the storage of disk or server p_w_picpaths 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。
Openstack Image service包含的组件
glance-api:提供了Image service的发现、检索、存储功能的API调用。
glance-registry:用于存储、处理、检索Image元数据。这些元数据包含了镜像的size和type等信息。需要注意的是,注册(glance-registry)是OpenStack Image service私有的内部服务,这意味着不能向User公开该服务。
Database:用于存储Image的元数据,支持大多数Database种类,常使用或SQLite来实现。
Storage repository for p_w_picpath files(镜像文件的存储仓库):支持多种存储类型,包括file systems、Object Storage、RADOS block devices、HTTP、Amazon S3等类型。但有些存储类型只支持只读访问。
Metadata definition service(元数据定义服务):是一个统一的vendors API,管理员、服务、用户可以定义他们所拥有的自定义元数据(custom metadata)。这个自定义的元数据可以使用不同的资源类型,如:p_w_picpaths、artifacts、volumes、flavors、aggregates。定义包含了new property’s key、description、constraints和相关的资源类型。
Install and configure
在Controller Node上安装并配置OpenStack Image service
Prerequisites 先决条件
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。To create the database
Use the database access client to connect to the database server as the root
以管理员root的身份登录数据库mysql -u root -pfanguiju11
Create the glance database
创建glance数据库CREATE DATABASE glance;11
Grant proper access to the glance database
创建数据库用户glance,并授予其对glance数据库的管理权限GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'fanguiju';GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'fanguiju';1212
Exit the database access client.
To create the service credentials
创建服务凭证
Source the admin credentials to gain access to admin-only CLI commands
[root@controller ~]# . admin-openrc11
Create the glance user
创建glance用户[root@controller ~]# openstack user create --domain default --password-prompt glanceUser Password:Repeat User Password:+-----------+----------------------------------+| Field | Value |+-----------+----------------------------------+| domain_id | 011fbf8c04f1479ab1a4e49b019b22d1 || enabled | True || id | 81712fe752e942fab0750288fb6bb103 || name | glance |+-----------+----------------------------------+12345678910111234567891011
Add the admin role to the glance user and service project
添加Project service和User glance到Role admin中openstack role add --project service --user glance admin11
Create the glance service entity
创建glance服务实体,将Image service加入到服务目录。[root@controller ~]# openstack service create --name glance --description "OpenStack Image" p_w_picpath+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image || enabled | True || id | d15d7716542f4c0ca128796b33a76eed || name | glance || type | p_w_picpath |+-------------+----------------------------------+1234567891012345678910
Create the Image service API endpoints
为OpenStack Image service创建认证服务端点[root@controller ~]# openstack endpoint create --region RegionOne p_w_picpath public http://controller.jmilk.com:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 357e08b29f7f4a56a05877cf760b79f4 || interface | public || region | RegionOne || region_id | RegionOne || service_id | d15d7716542f4c0ca128796b33a76eed || service_name | glance || service_type | p_w_picpath || url | http://controller.jmilk.com:9292 |+--------------+----------------------------------+[root@controller ~]# openstack endpoint create --region RegionOne p_w_picpath internal http://controller.jmilk.com:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | c46bab42157942f0a77562bdfb73a25f || interface | internal || region | RegionOne || region_id | RegionOne || service_id | d15d7716542f4c0ca128796b33a76eed || service_name | glance || service_type | p_w_picpath || url | http://controller.jmilk.com:9292 |+--------------+----------------------------------+[root@controller ~]# openstack endpoint create --region RegionOne p_w_picpath admin http://controller.jmilk.com:9292 +--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | e71b8c296f4442ccab8966ca6ec99da8 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | d15d7716542f4c0ca128796b33a76eed || service_name | glance || service_type | p_w_picpath || url | http://controller.jmilk.com:9292 |+--------------+----------------------------------+ 123456789101112131415161718192021222324252627282930313233343536373839404142123456789101112131415161718192021222324252627282930313233343536373839404142
Install and configure components
Install the packages
yum install openstack-glance -y11
Edit the /etc/glance/glance-api.conf file
In the [database] section, configure database access
配置Image service的数据库连接 vim /etc/glance/glance-api.conf[database]connection = mysql+pymysql://glance:fanguiju@controller.jmilk.com/glance1212
配置详细日志报告
[DEFAULT]verbose = True1212
In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access
配置Identity service访问 注意:在[keystone_authtoken]
节点中,注释或删除其他别的选项。 [keystone_authtoken]auth_uri = http://controller.jmilk.com:5000auth_url = http://controller.jmilk.com:35357memcached_servers = controller.jmilk.com:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = fanguiju[paste_deploy]flavor = keystone1234567891011121312345678910111213
In the [glance_store] section, configure the local file system store and location of p_w_picpath files
配置本地文件系统存储和镜像文件的存放路径[glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/p_w_picpaths/12341234
总览
[root@controller ~]# cat /etc/glance/glance-api.conf | grep -v ^# | grep -v ^$[DEFAULT]verbose = True[cors][cors.subdomain][database]connection = mysql+pymysql://glance:fanguiju@controller.jmilk.fan/glance[glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/p_w_picpaths/[p_w_picpath_format][keystone_authtoken]auth_uri = http://controller.jmilk.com:5000auth_url = http://controller.jmilk.com:35357memcached_servers = controller.jmilk.com:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = fanguiju[matchmaker_redis][oslo_concurrency][oslo_messaging_amqp][oslo_messaging_notifications][oslo_messaging_rabbit][oslo_policy][paste_deploy]flavor = keystone[profiler][store_type_location_strategy][task][taskflow_executor]1234567891011121314151617181920212223242526272829303132333412345678910111213141516171819202122232425262728293031323334
Edit the /etc/glance/glance-registry.conf file
In the [database] section, configure database access
vim /etc/glance/glance-registry.conf[database]connection = mysql+pymysql://glance:fanguiju@controller.jmilk.com/glance1212
In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access
注意:在[keystone_authtoken]
节点中,注释或删除其他别的选项。 [keystone_authtoken]auth_uri = http://controller.jmilk.com:5000auth_url = http://controller.jmilk.com:35357memcached_servers = controller.jmilk.com:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = fanguiju[paste_deploy]flavor = keystone1234567891011121312345678910111213
总览
[root@controller ~]# cat /etc/glance/glance-registry.conf | grep -v ^# | grep -v ^$[DEFAULT][database]connection = mysql+pymysql://glance:fanguiju@controller.jmilk.com/glance[glance_store][keystone_authtoken]auth_uri = http://controller.jmilk.com:5000auth_url = http://controller.jmilk.com:35357memcached_servers = controller.jmilk.com:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = fanguiju[matchmaker_redis][oslo_messaging_amqp][oslo_messaging_notifications][oslo_messaging_rabbit][oslo_policy][paste_deploy]flavor = keystone[profiler]12345678910111213141516171819202122231234567891011121314151617181920212223
Populate the Image service database
[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glanceOption "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future./usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1056: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade expire_on_commit=expire_on_commit, _conf=conf)/usr/lib/python2.7/site-packages/pymysql/cursors.py:146: Warning: Duplicate index 'ix_p_w_picpath_properties_p_w_picpath_id_name' defined on the table 'glance.p_w_picpath_properties'. This is deprecated and will be disallowed in a future release. result = self._query(query)123456123456
Note:忽略所有的警告输出信息
查看glance数据库:
[root@controller ~]# mysql -u root -pfanguijuWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 8Server version: 10.1.12-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| glance || information_schema || keystone || mysql || performance_schema |+--------------------+5 rows in set (0.00 sec)MariaDB [(none)]> use glanceReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedMariaDB [glance]> show tables;+----------------------------------+| Tables_in_glance |+----------------------------------+| artifact_blob_locations || artifact_blobs || artifact_dependencies || artifact_properties || artifact_tags || artifacts || p_w_picpath_locations || p_w_picpath_members || p_w_picpath_properties || p_w_picpath_tags || p_w_picpaths || metadef_namespace_resource_types || metadef_namespaces || metadef_objects || metadef_properties || metadef_resource_types || metadef_tags || migrate_version || task_info || tasks |+----------------------------------+20 rows in set (0.00 sec)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
Finalize installation
systemctl enable openstack-glance-api.service openstack-glance-registry.servicesystemctl start openstack-glance-api.service openstack-glance-registry.service1212
Verify operation验证操作
Verify operation of the Image service using CirrOS, a small Linux p_w_picpath that helps you test your OpenStack deployment.
使用CirrOS
镜像来进行Image service的测试操作,CirrOS
是一个小型的Linux镜像文件。 Note:在Controller Node上执行下列操作
1.Source the admin credentials to gain access to admin-only CLI commands
. admin-openrc11
2.Download the source p_w_picpath
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img11
或者点这里。
3.Upload the p_w_picpath to the Image service using the QCOW2 disk format, bare format, and public visibility so all projects can access it
以QCOW2
的磁盘格式、bare
容器格式、public visibility
的方式将镜像上传到Image service,所以所有的用户都能否访问这个镜像。 openstack p_w_picpath create "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public 12341234
Example:
[root@controller ~]# openstack p_w_picpath create "cirros" \> --file cirros-0.3.4-x86_64-disk.img \> --disk-format qcow2 --container-format bare \> --public +------------------+------------------------------------------------------+| Field | Value |+------------------+------------------------------------------------------+| checksum | ee1eca47dc88f4879d8a229cc70a07c6 || container_format | bare || created_at | 2016-06-21T16:07:16Z || disk_format | qcow2 || file | /v2/p_w_picpaths/cced0c86-9841-451b-9497-929380dc53f8/file || id | cced0c86-9841-451b-9497-929380dc53f8 || min_disk | 0 || min_ram | 0 || name | cirros || owner | 6c04f1d3ecd04aafb427f4f8d01be534 || protected | False || schema | /v2/schemas/p_w_picpath || size | 13287936 || status | active || tags | || updated_at | 2016-06-21T16:07:16Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+ 12345678910111213141516171819202122232425261234567891011121314151617181920212223242526
查看镜像文件存储目录:
[root@controller ~]# ll /var/lib/glance/p_w_picpaths/total 12980-rw-r----- 1 glance glance 13287936 Jun 21 12:07 cced0c86-9841-451b-9497-929380dc53f8123123
ERROR1:500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
解决:systemctl restart mariadb.service
ERROR2:An unexpected error prevented the server from fulfilling your request.
Glance Log:2016-06-21 11:52:03.196 3949 ERROR glance.common.wsgi [req-4a033bf7-2bf3-4af9-bd50-03d5ce089e87 d5e5331d665540159f1bfabb7327eca5 6c04f1d3ecd04aafb427f4f8d01be534 - - -] Caught error: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 111] ECONNREFUSED)")11
解决:重启Controller Node主机
4.Confirm upload of the p_w_picpath and validate attributes
[root@controller ~]# openstack p_w_picpath list+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| cced0c86-9841-451b-9497-929380dc53f8 | cirros | active |+--------------------------------------+--------+--------+123456123456
至此Openstack Image service的安装就完成
版权声明:转载请注明出处 JmilkFan:http://blog.csdn.net/jmilk