——先决条件
1.)创建数据库
MariaDB [(none)]> CREATE DATABASE glance;Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> GRANT ALL ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> GRANT ALL ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance'; Query OK, 0 rows affected (0.00 sec)
2.) create glance user
[root@openstack ~]# openstack user create --domain default --password glance glance+-----------+----------------------------------+| Field | Value |+-----------+----------------------------------+| domain_id | 505647f0f06e408e9d176da82a6684f1 || enabled | True || id | fa8739bf463a40e5a1945c700c16b8a8 || name | glance |+-----------+----------------------------------+
3.) Add the admin role to the glance user and service project
[root@openstack ~]# openstack role add --project service --user glance admin
4.) create p_w_picpath service
[root@openstack ~]# openstack service create --name glance --description "OpenStack Image" p_w_picpath+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image || enabled | True || id | e67a6d01628149b897be0a7795feb10a || name | glance || type | p_w_picpath |+-------------+----------------------------------+
5.)Create the Image service API endpoints
[root@openstack ~]# openstack endpoint create --region RegionOne p_w_picpath public http://192.168.100.120:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 68c611cc0add4c178b7f1d58df0843af || interface | public || region | RegionOne || region_id | RegionOne || service_id | e67a6d01628149b897be0a7795feb10a || service_name | glance || service_type | p_w_picpath || url | http://192.168.100.120:9292 |+--------------+----------------------------------+[root@openstack ~]# openstack endpoint create --region RegionOne p_w_picpath internal http://192.168.100.120:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 716335ae9a8f46f9b9b175ae7e381aa9 || interface | internal || region | RegionOne || region_id | RegionOne || service_id | e67a6d01628149b897be0a7795feb10a || service_name | glance || service_type | p_w_picpath || url | http://192.168.100.120:9292 |+--------------+----------------------------------+[root@openstack ~]# openstack endpoint create --region RegionOne p_w_picpath admin http://192.168.100.120:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | b92d362f5d0d49d0a78cbc3ea3ed63f1 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | e67a6d01628149b897be0a7795feb10a || service_name | glance || service_type | p_w_picpath || url | http://192.168.100.120:9292 |+--------------+----------------------------------+
——glance服务搭建配置
6.)安装glance
[root@openstack ~]# yum -y install openstack-glance python-glanceclient python-crypto
7.)配置glance
[root@openstack ~]# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak[root@openstack ~]# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak[root@openstack ~]# vim /etc/glance/glance-api.conf 1: [DEFAULT] 378: debug = true 405: log_file = /var/log/glance/glance-api.log 618: [database] 641: connection = mysql://glance:glance@localhost:3306/glance 741: stores = file,http 746: default_store = file1025: filesystem_store_datadir = /var/lib/glance/p_w_picpaths1111: [keystone_authtoken]1112: auth_uri = http://192.168.100.120:50001113: auth_url = http://192.168.100.120:353571114: memcached_servers = 192.168.100.120:112111115: auth_type = password1116: project_domain_name = default1117: user_domain_name = default1118: project_name = service1119: username = glance1120: password = glance1696: flavor = keystone[root@openstack ~]# vim /etc/glance/glance-registry.conf 1: [DEFAULT] 179: debug = true 206: log_file = /var/log/glance/glance-registry.log 359: [database] 382: connection = mysql://glance:glance@localhost:3306/glance 836: [keystone_authtoken] 837: auth_uri = http://192.168.100.120:5000 838: auth_url = http://192.168.100.120:35357 839: memcached_servers = 192.168.100.120:11211 840: auth_type = password 841: project_domain_name = default 842: user_domain_name = default 843: project_name = service 844: username = glance 845: password = glance1402: flavor = keystone
8.) 同步数据库
[root@openstack ~]# glance-manage db_sync[root@openstack ~]# mysql -uglance -pglance -e 'use 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 |+----------------------------------+
9.) Start glance service
[root@openstack ~]# chown -R glance:glance /var/log/glance[root@openstack ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service[root@openstack ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service[root@openstack ~]# systemctl status openstack-glance-api.service openstack-glance-registry.service[root@openstack ~]]# netstat -antup|egrep '9191|9292'|grep LISTEN tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 5529/python2 tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 5530/python2
10.)校验操作
10.1)Download the source p_w_picpath
[root@openstack ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -P /soft
10.2)Upload the p_w_picpath to the Image service
[root@openstack ~]# openstack p_w_picpath create "cirros-0.3.4-x86_64" \--file /soft/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-05-26T06:03:52Z || disk_format | qcow2 || file | /v2/p_w_picpaths/138d731b-0372-4237-9187-62f7885ac147/file || id | 138d731b-0372-4237-9187-62f7885ac147 || min_disk | 0 || min_ram | 0 || name | cirros-0.3.4-x86_64 || owner | e4f62edc6ed547109768b515be56044a || protected | False || schema | /v2/schemas/p_w_picpath || size | 13287936 || status | active || tags | || updated_at | 2016-05-26T06:03:52Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+[root@openstack ~]# openstack p_w_picpath list+--------------------------------------+---------------------+--------+| ID | Name | Status |+--------------------------------------+---------------------+--------+| 138d731b-0372-4237-9187-62f7885ac147 | cirros-0.3.4-x86_64 | active |+--------------------------------------+---------------------+--------+