部署在controller节点
配置数据库
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';? ? ? ?
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'127.0.0.1' IDENTIFIED BY 'glance';
Query OK, 0 rows affected (0.00 sec
MariaDB [(none)]> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
配置Glance服务认证
创建glance用户:
[email protected]:~# openstack user create --password-prompt glance
User Password:glance
Repeat User Password:glance
+----------+----------------------------------+
| Field? ? | Value? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+----------+----------------------------------+
| email? ? | None? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| enabled? | True? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| id? ? ? ?| ddcbca4dd1954923b6fd62f98110242b |
| name? ? ?| glance? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| username | glance? ? ? ? ? ? ? ? ? ? ? ? ? ?|
+----------+----------------------------------+
将admin角色添加给glance用户和service项目:
[email protected]:~# openstack role add --project service --user glance admin
+-------+----------------------------------+
| Field | Value? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+-------+----------------------------------+
| id? ? | 6d814860fbae4b9eb46c5e33835ba2a1 |
| name? | admin? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+-------+----------------------------------+
创建glance的服务实体:
[email protected]:~# openstack service create --name glance? --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field? ? ? ?| Value? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+-------------+----------------------------------+
| description | OpenStack Image service? ? ? ? ? |
| enabled? ? ?| True? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| id? ? ? ? ? | d5665f9b2f5645f6aaed5cbf74bad662 |
| name? ? ? ? | glance? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| type? ? ? ? | image? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+-------------+----------------------------------+
创建镜像服务的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? ? ? ? ? ?| b0ab3b1386174c3da615baddeb590d27 |
| internalurl? | http://controller:9292? ? ? ? ? ?|
| publicurl? ? | http://controller:9292? ? ? ? ? ?|
| region? ? ? ?| RegionOne? ? ? ? ? ? ? ? ? ? ? ? |
| service_id? ?| d5665f9b2f5645f6aaed5cbf74bad662 |
| service_name | glance? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| service_type | image? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+--------------+----------------------------------+
安装Glance
[email protected]:~# apt-get install glance python-glanceclient
配置Glance
/etc/glance/glance-api.conf?:
#[DEFAULT]部分,配置noop禁用通知驱动,因为这是为telemetry测量服务保留的
[DEFAULT]
notification_driver = noop
# [database]部分,配置数据库的连接
[database]
connection = mysql://glance:[email protected]/glance
#[keystone_authtoken]部分,配置身份认证服务访问
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
# [keystone_store]部分,配置镜像存储采用文件的形式,并且指定存储的路径
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
/etc/glance/glance-registry.conf:
[DEFAULT]
notification_driver = noop
[database]
connection = mysql://glance:[email protected]/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
[DEFAULT]
notification_driver = noop
初始化glance数据库:
[email protected]:~# su -s /bin/sh -c "glance-manage db_sync" glance
重启Glance服务:
[email protected]:~# service glance-registry restart
glance-registry stop/waiting
glance-registry start/running, process 28498
[email protected]:~# service glance-api restart
glance-api stop/waiting
glance-api start/running, process 28526
删除ubuntu默认创建的SQLite数据库:
[email protected]:~# rm -f /var/lib/glance/glance.sqlite
制作镜像
[email protected]:~#?echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh
[email protected]:~# source admin-openrc.sh
[email protected]:~# wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img?
使用QCOW2的磁盘格式和bare的容器格式将镜像上传到glance镜像服务中,并且设置为对所有的项目可见:
[email protected]:~# 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
查看镜像
[email protected]:~# glance image-list?
+--------------------------------------+---------------------+
| ID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| Name? ? ? ? ? ? ? ? |
+--------------------------------------+---------------------+
| 68657969-e3a0-4206-bbc8-cc15ee97daa5 | cirros-0.3.3-x86_64 |
+--------------------------------------+---------------------+
[email protected]:~# glance image-show 68657969-e3a0-4206-bbc8-cc15ee97daa5
+------------------+--------------------------------------+
| Property? ? ? ? ?| Value? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+------------------+--------------------------------------+
| checksum? ? ? ? ?| 133eae9fb1c98f45894a4e60d8736619? ? ?|
| container_format | bare? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| created_at? ? ? ?| 2019-08-16T09:03:58Z? ? ? ? ? ? ? ? ?|
| disk_format? ? ? | qcow2? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
| id? ? ? ? ? ? ? ?| 68657969-e3a0-4206-bbc8-cc15ee97daa5 |
| min_disk? ? ? ? ?| 0? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
| min_ram? ? ? ? ? | 0? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
| name? ? ? ? ? ? ?| cirros-0.3.3-x86_64? ? ? ? ? ? ? ? |
| owner? ? ? ? ? ? | c1d88707e8a04e889d151496421cfb92? ? ?|
| protected? ? ? ? | False? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
| size? ? ? ? ? ? ?| 13200896? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| status? ? ? ? ? ?| active? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| tags? ? ? ? ? ? ?| []? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| updated_at? ? ? ?| 2019-08-16T09:03:58Z? ? ? ? ? ? ? ? ?|
| virtual_size? ? ?| None? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| visibility? ? ? ?| public? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
+------------------+--------------------------------------+
原文地址:https://www.cnblogs.com/wshenjin/p/11365931.html
时间: 2024-11-07 07:38:01