OpenStack 学习笔记(四):OpenStack glance服务搭建
——先决条件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
# 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
# openstack role add --project service --user glance admin 4.) create image service
# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | e67a6d01628149b897be0a7795feb10a |
| name | glance |
| type | image |
+-------------+----------------------------------+ 5.)Create the Image service API endpoints
# openstack endpoint create --region RegionOne image 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 | image |
| url | http://192.168.100.120:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne image 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 | image |
| url | http://192.168.100.120:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne image 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 | image |
| url | http://192.168.100.120:9292 |
+--------------+----------------------------------+
——glance服务搭建配置
6.)安装glance
# yum -y install openstack-glance python-glanceclient python-crypto
7.)配置glance
# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
# vim /etc/glance/glance-api.conf
1:
378: debug = true
405: log_file = /var/log/glance/glance-api.log
618:
641: connection = mysql://glance:glance@localhost:3306/glance
741: stores = file,http
746: default_store = file
1025: filesystem_store_datadir = /var/lib/glance/images
1111:
1112: auth_uri = http://192.168.100.120:5000
1113: auth_url = http://192.168.100.120:35357
1114: memcached_servers = 192.168.100.120:11211
1115: auth_type = password
1116: project_domain_name = default
1117: user_domain_name = default
1118: project_name = service
1119: username = glance
1120: password = glance
1696: flavor = keystone
# vim /etc/glance/glance-registry.conf
1:
179: debug = true
206: log_file = /var/log/glance/glance-registry.log
359:
382: connection = mysql://glance:glance@localhost:3306/glance
836:
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 = glance
1402: flavor = keystone
8.) 同步数据库
# glance-manage db_sync
# mysql -uglance -pglance -e 'use 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 |
+----------------------------------+
9.) Start glance service
# chown -R glance:glance /var/log/glance
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
# systemctl status openstack-glance-api.service openstack-glance-registry.service
]# 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 image
# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -P /soft
10.2)Upload the image to the Image service
# openstack image 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/images/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/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2016-05-26T06:03:52Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
# openstack image list
+--------------------------------------+---------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------+--------+
| 138d731b-0372-4237-9187-62f7885ac147 | cirros-0.3.4-x86_64 | active |
+--------------------------------------+---------------------+--------+
页:
[1]