8.1. 创建数据库
mysql -u root -p
create database glance;
grant all privileges on glance.* to'glance'@'kilo' identified by 'glance_dbpass';
grant all privileges on glance.* to'glance'@'localhost' identified by 'glance_dbpass';
grant all privileges on glance.* to'glance'@'%' identified by 'glance_dbpass';
exit
8.2. 创建认证服务
source admin-openrc.sh
openstack user create --password-promptglance
User Password:(填写密码:glance_pass)
Repeat User Password:
+----------+----------------------------------+
| Field | Value |
+----------+----------------------------------+
| email | None |
| enabled | True |
| id | d0962c616ca645ca87916abc709e3195 |
| name | glance |
| username |glance |
+----------+----------------------------------+
openstack role add --project service --userglance admin
+-------+----------------------------------+
| Field |Value |
+-------+----------------------------------+
| id | 14b826a870464c67900a963d675cc8cb |
| name | admin |
+-------+----------------------------------+
openstack service create --name glance--description "Openstack Image Service" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description |Openstack Image Service |
| enabled | True |
| id | ae5bda0ebc10479ca156cb975c3a2eab |
| name | glance |
| type | image |
+-------------+----------------------------------+
8.3. 创建镜像服务API endpoint
openstack endpoint create --publicurlhttp://kilo:9292 --internal http://kilo:9292 --adminurl http://kilo:9292--region RegionOne image
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| adminurl | http://kilo:9292 |
| id | 43f4c5ce46744da29a33cabad834f6fa |
|internalurl | http://kilo:9292 |
| publicurl | http://kilo:9292 |
| region | RegionOne |
| service_id | ae5bda0ebc10479ca156cb975c3a2eab |
| service_name |glance |
| service_type |image |
+--------------+----------------------------------+
8.4. 安装glance
sudo apt-get install glancepython-glanceclient -y
8.5. 配置glance
sudo vim /etc/glance/glance-api.conf
[DEFAULT]
notification_driver = noop
verbose = True
[database]
connection =mysql://glance:glance_dbpass@kilo/glance
[keystone_authtoken]
auth_uri = http://kilo:5000
auth_url = http://kilo:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance_pass
revocation_cache_time = 10
[paste_deploy]
flavor=keystone
[glance_store]
default_store = file
filesystem_store_datadir =/var/lib/glance/images/
sudo vim /etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = noop
verbose = True
[database]
connection =mysql://glance:glance_dbpass@kilo/glance
[keystone_authtoken]
auth_uri = http://kilo:5000
auth_url = http://kilo:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance_pass
[paste_deploy]
flavor=keystone
8.6. 同步数据库
sudo bash -c "glance-managedb_sync" glance
8.7. 重启服务
sudo rm -f /var/lib/glance/glance.sqlite
sudo service glance-api restart
sudo service glance-registry restart
8.8. glance安装验证
8.8.1. 在每一个客户端脚本,配置镜像服务客户端使用 APIversion 2.0
echo "exportOS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
source admin-openrc.sh
8.8.2. 下载镜像
wgethttp://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img
8.8.3. 上传镜像
glance image-create --name"cirros-0.3.3-x86_64" --file cirros-0.3.3-x86_64-disk.img--disk-format qcow2 --container-format bare --visibility public --progress
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum |133eae9fb1c98f45894a4e60d8736619 |
|container_format | bare |
| created_at | 2015-05-25T06:46:43Z |
|disk_format | qcow2 |
| id |e056a34b-8226-4885-9b30-982dbf36a5dc |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.3-x86_64 |
| owner |9e4ff200c6994bd6bd6e589c21afa2f8 |
| protected | False |
| size | 13200896 |
| status | active |
| tags | [] |
| updated_at | 2015-05-25T06:46:44Z |
|virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
8.8.4. 确认成功
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| ID | Name | Disk Format | Container Format |Size | Status |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
|e056a34b-8226-4885-9b30-982dbf36a5dc | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+