博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
opens--glance
阅读量:4487 次
发布时间:2019-06-08

本文共 16278 字,大约阅读时间需要 54 分钟。

glance架构图:

glance架构:

由图可看到glance由三部分组成glance-api、glance-registry,db1.glance-api是后台运行的进程,对外提供RESTAPI,响应image查询获取和存储的调用,glance-api不会真正的处理请求,端口是92922.glance-registry是后台运行的服务进程,负责处理和存储Image的metadata,例如image的大小和类型,这部分数据是存在DB中的。端口是91913.DB存储着Image的metadata信息,默认是mysql,端口是3306

配置:

#修改glance-api.conf和 glance-registry.conf配置文件[root@master1 ~]# egrep -v "^$|^[#|\[]" /etc/glance/glance-api.conf connection = mysql+pymysql://glance:glance@192.168.142.166/glance ##连接数据库部分stores = file,http ##指定镜像存储方式和位置default_store = filefilesystem_store_datadir = /var/lib/glance/images/auth_uri = http://192.168.142.166:5000  ##配置keystone auth_url = http://192.168.142.166:35357memcached_servers = 192.168.142.166:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = glanceflavor = keystone[root@master1 ~]# egrep -v "^$|^[#|\[]" /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:glance@192.168.142.166/glanceauth_uri = http://192.168.142.166:5000auth_url = http://192.168.142.166:35357memcached_servers = 192.168.142.166:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = glanceflavor = keystone#同步数据库su -s /bin/sh -c "glance-manage db_sync" glance#验证[root@master1 ~]# 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                            |+----------------------------------+

  

 启动和开机自启动:

#设置开机启动并启动服务[root@master1 ~]# systemctl enable openstack-glance-api.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.[root@master1 ~]# systemctl enable openstack-glance-registry.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.[root@master1 ~]# systemctl start openstack-glance-api.service[root@master1 ~]# systemctl start openstack-glance-registry.service        [root@master1 ~]# netstat -tulnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    tcp        0      0 192.168.142.166:3306    0.0.0.0:*               LISTEN      2047/mysqld         tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      27891/python2       tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      1/systemd           tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1521/sshd           tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      919/beam            tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2264/master         tcp        0      0 0.0.0.0:9191            0.0.0.0:*               LISTEN      27908/python2       tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      919/beam            tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           tcp6       0      0 :::80                   :::*                    LISTEN      924/httpd           tcp6       0      0 :::22                   :::*                    LISTEN      1521/sshd           tcp6       0      0 ::1:25                  :::*                    LISTEN      2264/master         tcp6       0      0 :::35357                :::*                    LISTEN      924/httpd           tcp6       0      0 :::5672                 :::*                    LISTEN      919/beam            tcp6       0      0 :::5000                 :::*                    LISTEN      924/httpd           udp        0      0 127.0.0.1:323           0.0.0.0:*                           644/chronyd         udp        0      0 0.0.0.0:47474           0.0.0.0:*                           714/dhclient        udp        0      0 0.0.0.0:68              0.0.0.0:*                           714/dhclient        udp6       0      0 :::31455                :::*                                714/dhclient        udp6       0      0 ::1:323                 :::*                                644/chronyd

  

#创建glance的service和endpoint[root@master1 ~]# openstack service create --name glance --description "Openstack Image" image +-------------+----------------------------------+| Field       | Value                            |+-------------+----------------------------------+| description | Openstack Image                  || enabled     | True                             || id          | 5afa06c614ae49d490ed75df9557ca83 || name        | glance                           || type        | image                            |+-------------+----------------------------------+[root@master1 ~]# openstack service list+----------------------------------+----------+----------+| ID                               | Name     | Type     |+----------------------------------+----------+----------+| 1677633e96b94161a265154f1412800b | keystone | identity || 5afa06c614ae49d490ed75df9557ca83 | glance   | image    |+----------------------------------+----------+----------+[root@master1 ~]#  openstack endpoint create --region RegionOne image public http://192.168.142.166:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | f31a37215ffa4d0190e5144f82b16697 || interface    | public                           || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 5afa06c614ae49d490ed75df9557ca83 || service_name | glance                           || service_type | image                            || url          | http://192.168.142.166:9292      |+--------------+----------------------------------+[root@master1 ~]#  openstack endpoint create --region RegionOne image internal http://192.168.142.166:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 8d6c17e786ad47b2835a0e8b2056d957 || interface    | internal                         || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 5afa06c614ae49d490ed75df9557ca83 || service_name | glance                           || service_type | image                            || url          | http://192.168.142.166:9292      |+--------------+----------------------------------+[root@master1 ~]#  openstack endpoint create --region RegionOne image admin http://192.168.142.166:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | b1767ca08bb744ad937048113d0ce8d7 || interface    | admin                            || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 5afa06c614ae49d490ed75df9557ca83 || service_name | glance                           || service_type | image                            || url          | http://192.168.142.166:9292      |+--------------+----------------------------------+[root@master1 ~]#  openstack endpoint list+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------------+| ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                             |+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------------+| 123331222f2642858293d16952da34f8 | RegionOne | keystone     | identity     | True    | admin     | http://192.168.142.166:35357/v3 || 506f61f1ced645ac86a17d9ac5825bf8 | RegionOne | keystone     | identity     | True    | public    | http://192.168.142.166:5000/v3  || 8d6c17e786ad47b2835a0e8b2056d957 | RegionOne | glance       | image        | True    | internal  | http://192.168.142.166:9292     || b1767ca08bb744ad937048113d0ce8d7 | RegionOne | glance       | image        | True    | admin     | http://192.168.142.166:9292     || d5a953110c4049a4ac9f0b338d5d7145 | RegionOne | keystone     | identity     | True    | internal  | http://192.168.142.166:5000/v3  || f31a37215ffa4d0190e5144f82b16697 | RegionOne | glance       | image        | True    | public    | http://192.168.142.166:9292     |+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------------+[root@master1 ~]# lsadmin.sh  anaconda-ks.cfg  checkUrl.sh  pstack.sh[root@master1 ~]# openstack image list[root@master1 ~]# glance image-list+----+------+| ID | Name |+----+------++----+------+

  

 上传镜像:

[root@master1 ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img--2017-07-11 14:25:41--  http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img正在解析主机 download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85, 2607:f298:6:a036::bd6:a72a正在连接 download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:13287936 (13M) [text/plain]正在保存至: “cirros-0.3.4-x86_64-disk.img”100%[===============================================================================================================================>] 13,287,936   840KB/s 用时 61s    2017-07-11 14:26:44 (211 KB/s) - 已保存 “cirros-0.3.4-x86_64-disk.img” [13287936/13287936])[root@master1 ~]#  openstack image create "cirros" \>   --file cirros-0.3.4-x86_64-disk.img \>   --disk-format qcow2 --container-format bare \>   --public+------------------+------------------------------------------------------+| Field            | Value                                                |+------------------+------------------------------------------------------+| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     || container_format | bare                                                 || created_at       | 2017-07-11T06:27:47Z                                 || disk_format      | qcow2                                                || file             | /v2/images/af67976a-92ea-4d08-8296-86cb76e3954b/file || id               | af67976a-92ea-4d08-8296-86cb76e3954b                 || min_disk         | 0                                                    || min_ram          | 0                                                    || name             | cirros                                               || owner            | 3e83baa0b3d64188b036ce423002aac7                     || protected        | False                                                || schema           | /v2/schemas/image                                    || size             | 13287936                                             || status           | active                                               || tags             |                                                      || updated_at       | 2017-07-11T06:27:49Z                                 || virtual_size     | None                                                 || visibility       | public                                               |+------------------+------------------------------------------------------+[root@master1 ~]# openstack image list+--------------------------------------+--------+--------+| ID                                   | Name   | Status |+--------------------------------------+--------+--------+| af67976a-92ea-4d08-8296-86cb76e3954b | cirros | active |+--------------------------------------+--------+--------+

 glance常用命令

[root@master1 ~]# glance image-list+--------------------------------------+--------+| ID                                   | Name   |+--------------------------------------+--------+| 1b5bb43d-1589-46c0-8d86-b2868c840fdf |        || af67976a-92ea-4d08-8296-86cb76e3954b | cirros |+--------------------------------------+--------+

  

[root@master1 ~]# glance image-show af67976a-92ea-4d08-8296-86cb76e3954b #af...4b 是image-id+------------------+--------------------------------------+| Property         | Value                                |+------------------+--------------------------------------+| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     || container_format | bare                                 || created_at       | 2017-07-11T06:27:47Z                 || disk_format      | qcow2                                || id               | af67976a-92ea-4d08-8296-86cb76e3954b || min_disk         | 0                                    || min_ram          | 0                                    || name             | cirros                               || owner            | 3e83baa0b3d64188b036ce423002aac7     || protected        | False                                || size             | 13287936                             || status           | active                               || tags             | []                                   || updated_at       | 2017-07-11T06:27:49Z                 || virtual_size     | None                                 || visibility       | public                               |+------------------+--------------------------------------+

  

[root@master1 ~]# glance image-create+------------------+--------------------------------------+| Property         | Value                                |+------------------+--------------------------------------+| checksum         | None                                 || container_format | None                                 || created_at       | 2017-07-15T05:34:10Z                 || disk_format      | None                                 || id               | 1b5bb43d-1589-46c0-8d86-b2868c840fdf || min_disk         | 0                                    || min_ram          | 0                                    || name             | None                                 || owner            | 3e83baa0b3d64188b036ce423002aac7     || protected        | False                                || size             | None                                 || status           | queued                               || tags             | []                                   || updated_at       | 2017-07-15T05:34:10Z                 || virtual_size     | None                                 || visibility       | private                              |+------------------+--------------------------------------+

  

[root@master1 ~]# glance image-delete 1b5bb43d-1589-46c0-8d86-b2868c840fdf

glance遇到问题如何troubleshooting

01.开启debug

[root@master1 log]# grep "debug" /etc/glance/glance-api.conf # The hostname/IP of the pydev process listening for debug connections#pydev_worker_debug_host = 
#pydev_worker_debug_port = 5678#debug = false #设置为true即可#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d# Verbosity of SQL debugging information: 0=None, 100=Everything.# Deprecated group/name - [DEFAULT]/sql_connection_debug#connection_debug = 0

02.查看/var/log/glance目录下的日志

转载于:https://www.cnblogs.com/wanyp/p/7150390.html

你可能感兴趣的文章
HTML(XHTML)基础知识(五)——【table】
查看>>
asp.net中常用的26个优化性能的方法
查看>>
Android项目目录结构分析
查看>>
JavaScript学习总结(四)——this、原型链、javascript面向对象
查看>>
阅读笔记 Vox Populi: Collecting High-Quality Labels from a Crowd
查看>>
poj 1459
查看>>
Solr(5.1.0) 与Tomcat 从0开始安装与配置
查看>>
Python 面向对象(三)
查看>>
openstack云主机硬盘复制查询
查看>>
写个神经网络,让她认得我`(๑•ᴗ•๑)(Tensorflow,opencv,dlib,cnn,人脸识别)
查看>>
程序员做开发,前台、后台、测试哪个累?
查看>>
《程序是怎样跑起来的》第三章
查看>>
Jquery回到顶部效果
查看>>
开园第一笔
查看>>
Spark项目之电商用户行为分析大数据平台之(七)数据调研--基本数据结构介绍...
查看>>
原来fb可以在一个工程里面输出多个swf模块
查看>>
Codeforces Round #271 (Div. 2) E. Pillars 线段树优化dp
查看>>
Codeforces Round #FF (Div. 2) D. DZY Loves Modification 优先队列
查看>>
[SPOJ705]不同的子串
查看>>
【学习】logger
查看>>