5-openstack之glance

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了5-openstack之glance相关的知识,希望对你有一定的参考价值。

5.1 glance的部署

[[email protected]~]# yum  -y install openstack-glancepython-glance python-glanceclient
Glance一定会链接数据库,glance一定会链接keystone,存储配置,配置到哪个地方

 技术分享

5.2 glance-api的配置

[[email protected]~]# grep ‘^[a-z]‘ /etc/glance/glance-api.conf
verbose = true #开启debug日志
connection =mysql://glance:[email protected]/glance #mysql数据库连接  #database模块
default_store =file        #keystone_keystone_authtoken模块
filesystem_store_datadir= /var/lib/glance/images
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers= 192.168.56.11:11211
auth_type =password
project_domain_name= default
user_domain_name= default
project_name =service
username = glance
password = glance
driver = noop  #不适用消息队列 
flavor = keystone  #paste_deploy模块

5.3 glance-registry配置

[email protected]~]# grep ‘^[a-z]‘ /etc/glance/glance-registry.conf
connection =mysql://glance:[email protected]/glance
auth_uri =http://192.168.56.11:5000
auth_url =http://192.168.56.11:35357
memcached_servers= 192.168.56.11:11211
auth_type = password
project_domain_name= default
user_domain_name= default
project_name =service
username = glance
password = glance
flavor = keystone
[[email protected]~]#

5.4 同步glance数据库

su -s/bin/sh -c "glance-manage db_sync" glance
检查数据库同步状况
[[email protected]~]# mysql -h 192.168.56.11  -uglance-pglance  -e "use glance;showtables;"
+----------------------------------+
|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                            |
+----------------------------------+
[[email protected]~]#

5.5 往keystone注册

 5.5.1创建glance的域

[[email protected]~]# openstack user create --domain default --password=glance glance
+---------------------+----------------------------------+
|Field               | Value                            |
+---------------------+----------------------------------+
|domain_id           |d1d9728ef1d64905b1ebf54982dc7991 |
|enabled             | True                             |
| id                  |7a0adc3305d24ea4bc1d1a8abb51b410 |
|name                | glance                           |
|password_expires_at | None                             |
+---------------------+----------------------------------+
[[email protected]~]#

 5.5.2 为glance添加角色

 openstack role add --project service --userglance admin

5.6 启动glance-api 和glance-registry

[[email protected]~]# systemctl enable openstack-glance-api
Created symlinkfrom /etc/systemd/system/multi-user.target.wants/openstack-glance-api.serviceto /usr/lib/systemd/system/openstack-glance-api.service.
[[email protected]~]# systemctl enable openstack-glance-registry
Created symlinkfrom /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.serviceto /usr/lib/systemd/system/openstack-glance-registry.service.
[[email protected]~]#
[[email protected]~]# systemctl start  openstack-glance-api
[[email protected]~]# systemctl start  openstack-glance-registry
glance-registry9191端口
glance-api   9292端口

5.7创建对内,对外还有管理节点

[[email protected]~]# openstack service create --name glance --description "OpenStack Imagesservice" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description |OpenStack Images service         |
| enabled     | True                             |
| id          | 2c60396cbd3d4421ad9d298263e0e733 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
[[email protected]~]#
[[email protected]~]# openstack endpoint  create --regionRegionOne image public http://192.168.56.11:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 710081d984f54eb78b9dfa704c8f104f |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2c60396cbd3d4421ad9d298263e0e733 |
| service_name |glance                           |
| service_type |image                            |
| url          | http://192.168.56.11:9292        |
+--------------+----------------------------------+
[[email protected]~]#
[[email protected]~]# openstack endpoint  create --regionRegionOne image internal http://192.168.56.11:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 9c6260f82e0b49a2a32969e7108f704b |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2c60396cbd3d4421ad9d298263e0e733 |
| service_name |glance                           |
| service_type |image                            |
| url          | http://192.168.56.11:9292        |
+--------------+----------------------------------+
[[email protected]~]# openstack endpoint  create --regionRegionOne image admin http://192.168.56.11:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 470c6e79c23c4a0188ef3099b62030ab |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2c60396cbd3d4421ad9d298263e0e733 |
| service_name |glance                           |
| service_type |image                            |
| url          | http://192.168.56.11:9292        |
+--------------+----------------------------------+

5.8 添加glance-api的调用版本号

在admin-openstack.shdemo-openstack.sh 里面要有
exportOS_IMAGE_API_VERSION=2

5.9 测试是否成功

[[email protected]~]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+
[[email protected]~]#

5.10 下载一个镜像测试

wgethttp://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

5.11 上传镜像到glance

 openstack image create "cirros" \  --file cirros-0.3.4-x86_64-disk.img \  --disk-format qcow2 --container-format bare \  --public

5.12 再次查看镜像

[[email protected]~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
|2a71519f-59c6-4f11-994e-7d55c3e82110 | cirros |
+--------------------------------------+--------+
[[email protected]~]#

5.13说明镜像存放的目录

[[email protected]]# pwd
/var/lib/glance/images
[[email protected]]# ls
2a71519f-59c6-4f11-994e-7d55c3e82110#id一样的
[[email protected]]#


本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1883667

以上是关于5-openstack之glance的主要内容,如果未能解决你的问题,请参考以下文章

云原生之Docker实战使用Docker部署glances系统监控工具

linux网络命令之glances

系统之眼!Linux系统性能监控工具Glances

OpenStack入门之核心组件梳理——Glance篇

Openstack 实战讲解之-----------04-控制节点glance服务安装配置

openstack之glance