Glance Mirroring Service:
Glance consists of three main components: Glance-api, glance-registry, and image store
GLANCE-API: Accepts the creation, deletion, and read requests of the system image.
Glance-registry: Mirrored registration Service for cloud systems
Glance installation:
[[email protected] ~]# yum -y install openstack-glance python-glance python-glanceclient[[email protected] ~]# vim /etc/glance/glance-api.conf [database]connection=mysql://glance:[email protected]/glance[[email protected] ~]# vim /etc/glance/glance-registry.conf [database]connection=mysql://glance:[email protected]/glance
To synchronize the database:
[[email protected] ~]# su-s/bin/sh-c "Glance-manage db_sync" Glanceno handlers could be found for Logge R "Oslo_config.cfg" (can be ignored)
[[email protected] ~]# mysql-uglance-pglance-h192.168.56.11welcome to the MariaDB Monitor. Commands End With; or \g.your MariaDB connection ID is 16Server version:10.1.20-mariadb MariaDB servercopyright (c), Oracle, Mari ADB Corporation Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MariaDB [(None)]> use Glance;database changedmariadb [glance]> show tables;+----------------------------------+ | Tables_in_glance |+----------------------------------+| artifact_blob_locations | | Artifact_blobs | | artifact_dependencies | | artifact_properties | | Artifact_tags | | Artifacts | | image_locations | | Image_members | | image_properties | | Image_tags | | Images | | 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) MariaDB [glance]> Exitby E
To create a glance User:
[[email protected] ~]# openstack user create --domain default --password=glance glance+-----------+----------------------------------+| Field | Value |+-----------+----------------------------------+| domain_id | default || enabled | True || id | 85b0cebbbb9f4cc890cdeff577ee0989 || name | glance |+-----------+----------------------------------+
Add the glance user to the service project and give admin permission;
[[email protected] ~]# openstack role add --project service --user glance admin
Configuration glance:
[[email protected] ~]# vim /etc/glance/glance-api.conf [keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = glance[paste_deploy]flavor=keystone[DEFAULT]verbose=Truenotification_driver = noop[glance_store]default_store=filefilesystem_store_datadir=/var/lib/glance/images/
[[email protected] ~]# vim /etc/glance/glance-registry.conf [keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = glance[paste_deploy]flavor=keystone
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-api.conf verbose=Truenotification_driver = noopconnection=mysql://glance:[email protected]/glancedefault_store=filefilesystem_store_datadir=/var/lib/glance/images/auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = glanceflavor=keystone
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-registry.conf connection=mysql://glance:[email protected]/glanceauth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = glanceflavor=keystone
To start the Glance service:
[[email protected] ~]# systemctl enable openstack-glance-apiCreated symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.[[email protected] ~]# systemctl enable openstack-glance-registryCreated symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.[[email protected] ~]# systemctl start openstack-glance-api[[email protected] ~]# systemctl start openstack-glance-registry
Openstack-glance-api Listening Port 9292,openstack-glance-registry listening port 9191;
[[email protected] ~]# netstat-tnlpactive Internet connections (only servers) Proto recv-q send-q Local Address Foreign Address State Pid/program name TCP 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 970/beam.smp TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 142 7/master TCP 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 13004/python2 TCP 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 970/beam.smp TCP 0 0 0.0.0.0 : 11211 0.0.0.0:* LISTEN 2105/memcached TCP 0 0 0.0.0.0:9292 0.0.0 .0:* LISTEN 12983/python2 TCP 0 0 0.0.0.0:4369 0.0.0.0:* LIS TEN 1/systemd TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 969/sshd TCP6 0 0:: 1:25:::* LISTEN 1427/master tcp6 0 0::: 35357 :::* LISTEN 3754/httpd tcp6 0 0::: No:::* LISTEN 3754/httpd tcp6 0 0::: 5672:::* LISTEN 970 /BEAM.SMP TCP6 0 0::: 3306:::* LISTEN 1250/mysqld TCP6 0 0:: 1:11211:::* LISTEN 2105/memcached tcp6 0 0::: 80 :::* LISTEN 3754/httpd tcp6 0 0::: +:::* LISTEN 969/sshd
Keytone Registration Glance Service:
To create the Glance service:
[[email protected] ~]# openstack service create --name glance --description "OpenStack Image service" image +-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image service || enabled | True || id | d7f04da42efc4c6c8b75c1848385598c || name | glance || type | image |+-------------+----------------------------------+
Extranet registration:
[[email protected] ~]# openstack endpoint create --region RegionOne image public http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 08ee7445c6094fcaa8499f6223cd055f || interface | public || region | RegionOne || region_id | RegionOne || service_id | d7f04da42efc4c6c8b75c1848385598c || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
Intranet Registration:
[[email protected] ~]# openstack endpoint create --region RegionOne image internal http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 95134907b0b547f9a1e2c0cbf2a10137 || interface | internal || region | RegionOne || region_id | RegionOne || service_id | d7f04da42efc4c6c8b75c1848385598c || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
Admin registration:
[[email protected] ~]# openstack endpoint create --region RegionOne image admin http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | b8892b9813bc4f43af23bfeb373534b7 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | d7f04da42efc4c6c8b75c1848385598c || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
Glance Environment variables:
[[email protected] ~]# echo "export OS_IMAGE_API_VERSION=2" > | tee -a admin-openrc.sh demo-openrc.shexport OS_IMAGE_API_VERSION=2
[[email protected] ~]# cat admin-openrc.sh export OS_PROJECT_DOMAIN_ID=defaultexport OS_USER_DOMAIN_ID=defaultexport OS_PROJECT_NAME=adminexport OS_TENANT_NAME=adminexport OS_USERNAME=adminexport OS_PASSWORD=adminexport OS_AUTH_URL=http://192.168.56.11:35357/v3export OS_IDENTITY_API_VERSION=3export OS_IMAGE_API_VERSION=2
[[email protected] ~]# cat demo-openrc.sh export OS_PROJECT_DOMAIN_ID=defaultexport OS_USER_DOMAIN_ID=defaultexport OS_PROJECT_NAME=demoexport OS_TENANT_NAME=demoexport OS_USERNAME=demoexport OS_PASSWORD=demoexport OS_AUTH_URL=http://192.168.56.11:5000/v3export OS_IDENTITY_API_VERSION=3export OS_IMAGE_API_VERSION=2
[[email protected] ~]# glance image-list+----+------+| ID | Name |+----+------++----+------+
Download Image:
[[email protected] ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
Upload Image:
[[email protected] ~]# glance image-create--name "Cirros"--file cirros-0.3.4-x86_64-disk.img--disk-format Qcow2 --container-format bare--visibility public--progress[=============================>] 100%+------------------+- -------------------------------------+| Property | Value |+------------------+--------------------------------------+| Checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | Container_format | Bare | | Created_at | 2018-10-07t09:56:40z | | Disk_format | Qcow2 | | ID | 0297b83c-f9d7-4c19-ab05-762fd4616c49 | | Min_disk | 0 | | Min_ram | 0 | | name | Cirros | | Owner | D7064a9e91934300b28cccc787161fdb | | protected | False | | Size| 13287936 | | Status | active | | tags | [] || Updated_at | 2018-10-07t09:56:41z | | Virtual_size | None | | Visibility | Public |+------------------+--------------------------------------+
[[email protected] ~]# glance image-list+--------------------------------------+--------+| ID | Name |+--------------------------------------+--------+| 0297b83c-f9d7-4c19-ab05-762fd4616c49 | cirros |+--------------------------------------+--------+
[[email protected] ~]# cd /var/lib/glance/images/[[email protected] images]# ll总用量 12980-rw-r-----. 1 glance glance 13287936 10月 7 17:56 0297b83c-f9d7-4c19-ab05-762fd4616c49[[email protected] images]# file 0297b83c-f9d7-4c19-ab05-762fd4616c49 0297b83c-f9d7-4c19-ab05-762fd4616c49: QEMU QCOW Image (v2), 41126400 bytes
Openstack-liberty Version Glance service Deployment (II)