The OpenStack Mirroring Service (glance) allows users to discover, register, and recover virtual machine images. Glance provides the rest API to query the metadata of virtual machine images and to obtain mirroring. With glance, virtual machine images can be stored on a variety of storage, such as simple file storage or object storage (such as the Swift Project in OpenStack).
One, the OpenStack mirroring service contains components
Figure 1.1. OpenStack Glance Components
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/0B/wKiom1XyhUKi4QdjAAFmZ8oQcjE562.jpg "title=" 3 _1.jpg "alt=" Wkiom1xyhuki4qdjaafmz8oqcje562.jpg "/>
Second, OpenStack image service installation
The following describes how to install and configure the mirroring service, glance. This configuration saves the image to the local file system, which is stored by default in the/var/lib/glance/images/directory. All the steps will be performed on the controller node.
1. Pre-Installation Preparation
Before you install and configure the mirroring service, you must create a database, a service certificate, and an API endpoint.
1.1 Database Configuration
1) Create a database
[Email protected]:~# mysql-uroot-pmariadb [(none)]> CREATE DATABASE glance; Query OK, 1 row affected (0.06 sec)
2) authorization to the database
MariaDB [(None)]> GRANT all privileges on glance.* to ' glance ' @ ' localhost ' identified by ' sfzhang1109 '; Query OK, 0 rows affected (0.45 sec) MariaDB [(none)]> GRANT all privileges on glance.* to ' glance ' @ '% ' identified by ' s Fzhang1109 '; Query OK, 0 rows Affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.06 sec)
3) exit the database client
MariaDB [(none)]> Exitbye
1.2 Import Admin credentials to execute administrative commands
[Email protected]:~# Source admin-openrc.sh
1.3 Creating a service Certificate
1) Create glance User (password: glance)
[email protected]:~# openstack user create --password-prompt glanceuser password:repeat user password:+----------+----------------------------------+| field | Value |+----------+------- ---------------------------+| email | none | | enabled | True | | id | 8d333920d9df49af8d57910c3c18dcf8 | | name | glance | | username | glance |+----------+------- ---------------------------+
2) Add glance user and tenant service to admin corner
[Email protected]:~# openstack Role Add--project service--user glance admin+-------+--------------------------------- -+| Field | Value |+-------+----------------------------------+| ID | 05616505A61C4AA78F43FBA9E60BA7FC | | name | Admin |+-------+----------------------------------+
3) Create a Glance service entity
[Email protected]:~# openstack service create --name glance --description "Openstack image service" image+-------------+----------------------------------+| field | value |+-------------+----------------------------------+| description | openstack image service | | enabled | True | | id | e448c04b115a4cd3b745b70b17fa95b3 | | name | glance | | type | image |+-------------+----------------------------------+
1.4 Creating the Mirroring service API endpoint
[Email protected]:~# openstack endpoint create --publicurl http://controller:9292 --internalurl http://controller:9292 --adminurl http://controller:9292 --region regionone image+--------------+----------------------------------+| field | Value |+--------------+----------------------------------+| adminurl | http://controller:9292 | | id | aa4ac4216c7a41fd8452c7186c9493ac | | internalurl | http://controller:9292 | | publicurl | http://controller:9292 | | region | RegionOne | | service_id | e448c04b115a4cd3b745b70b17fa95b3 | | service_name | glance | | service_type | image |+------------ --+----------------------------------+
2. Installing and configuring the Mirroring service component
2.1 Installing Packages
[Email protected]:~# apt-get Install glance python-glanceclient
2.2 Edit the/etc/glance/glance-api.conf configuration file to complete the configuration below
1) Configure database access in the [Database] section
[database]...connection = Mysql://glance:[email protected]/glance
2) Configure the authentication entry in the [Keystone_authtoken] and [Paste_deploy] sections
[Keystone_authtoken]...auth_uri = Http://controller:5000auth_url = Http://controller:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = Defaultproject_name = Serviceusername = Glancepassword = glance[ Paste_deploy]...flavor = Keystone
3) Configure the location of local file system storage and image files in the [Glance_store] section
[Glance_store]...default_store = Filefilesystem_store_datadir =/data/glance/images/
4) Disable the NOOP message driver in the [DEFAULT] section, as this option is only relevant for the optional telemetry service
[Default]...notification_driver = NoOp
5) Open verbose log configuration in [DEFAULT] section for easy fault analysis and troubleshooting
[Default]...verbose = True
2.3 Edit the/etc/glance/glance-registry.conf configuration file to complete the configuration below
1) Configure database access in the [Database] section
Connection = Mysql://glance:[email Protected]/glance
2) Configure the authentication entry in the [Keystone_authtoken] and [Paste_deploy] sections
[Keystone_authtoken]...auth_uri = Http://controller:5000auth_url = Http://controller:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = Defaultproject_name = Serviceusername = Glancepassword = Glance
3) Disable the NOOP message driver in the [DEFAULT] section, as this option is only relevant for the optional telemetry service
[Paste_deploy]...flavor = Keystone
4) Open verbose log configuration in [DEFAULT] section for easy fault analysis and troubleshooting
[Default]...verbose = True
2.4 Initializing the Mirror service database
[Email protected]:~# su-s/bin/sh-c "Glance-manage db_sync" glance2015-09-01 06:17:25.166 18641 INFO migrate.versioning. API [-] 0-1 ... 2015-09-01 06:17:25.193 18641 INFO Glance.db.sqlalchemy.migrate_repo.schema [-] Creating table images ...
3. Installation Complete
1) Restart the image service
[Email protected]:~# service glance-registry restart[email protected]:~# service Glance-api restart
2 The SQLite database is created by default because the MySQL database is being used, so to delete the Qlite database file
Third, OpenStack Image service authentication
1) Configure the Image service client to use the API version 2.0
[Email protected]:~# echo "Export os_image_api_version=2" | Tee-a admin-openrc.sh demo-openrc.sh
2) Execute admin credentials
[Email protected]:~# Source admin-openrc.sh
3) Create a local zero directory
[Email protected]:~# mkdir/tmp/images
4) Download the image to this directory
[Email protected]:~# wget-p/tmp/images http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
5) Upload image to image service, image format is QCOW2.
[email protected]:~# glance image-create --name "cirros-0.3.4-x86_64" --file /tmp/images/cirros-0.3.4-x86_64-disk.img --disk-format qcow2 -- container-format bare --progress[=============================>] 100%+---------------- --+--------------------------------------+| property | Value |+------ ------------+--------------------------------------+| checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2015-09-11T07:04:31.000000 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | df54ff49-b167-4fed-987a-0ade3cbc9aca | | is_public | False | | min_disk | 0 | | min_ram | 0 | | name | cirros-0.3.4-x86_64 | | owner | d04d4985d62f42e2af2ddc35f442ffd9 | | protected | False | | size | 13287936 | | status | active | | updated_at | 2015-09-11T07:04:32.000000 | | virtual_size | None |+------------------+--------------------------------------+
6) Confirm image upload and verify properties
[email protected]:~# glance image-list+--------------------------------------+----------------- ----+-------------+------------------+----------+--------+| id | Name | disk format | container format | size | status |+------------------------------ --------+---------------------+-------------+------------------+----------+--------+| df54ff49-b167-4fed-987a-0ade3cbc9aca | cirros-0.3.4-x86_64 | qcow2 | bare | 13287936 | active |+--------------------------------------+---------------------+-------------+------------------+----------+------- -+
7) Delete the temporary directory image file
[Email protected]:~# rm-r/tmp/images/
Installation deployment of the OpenStack Mirroring Service (Image service)