• Openstack(八)部署镜像服务glance


     

    8.1glance镜像服务介绍

    Glance是OpenStack镜像服务组件,glance服务默认监听在9292端口,其接收REST API请求,然后通过其他模块(glance-registry及image store)来完成诸如镜像的获取、上传、删除等操作,Glance提供restful API可以查询虚拟机镜像的metadata,并且可以获得镜像,通过Glance,虚拟机镜像可以被存储到多种存储上,比如简单的文件存储或者对象存储(比如OpenStack中swift项目)是在创建虚拟机的时候,需要先把镜像上传到glance,对镜像的列出镜像、删除镜像和上传镜像都是通过glance进行理,glance有两个主要的服务,一个是glace-api接收镜像的删除上传和读取,一个是glance-Registry。

    glance-registry负责与mysql数据交互,用于存储或获取镜像的元数据(metadata),提供镜像元数据相关的REST接口,通过glance-registry可以向数据库中写入或获取镜像的各种数据,glance-registyr监听的端口是9191,glance数据库中有两张表,一张是glance表,一张是imane property表,image表保存了镜像格式、大小等信息,image property表保存了镜像的定制化信息。

    image store 是一个存储的接口层,通过这个接口glance可以获取镜像,image store支持的存储有Amazon的S3、openstack本身的swift、还有ceph、glusterFS、sheepdog等分布式存储,image store是镜像保存与读取的接口,但是它只是一个接口,具体的实现需要外部的支持,glance不需要配置消息队列,但是需要配置数据库和keystone。

    官方部署文档:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/glance.html

    8.2控制端安装glance

    # yum install -y openstack-glance

    8.3配置glance服务

    8.3.1创建并初始化数据库

    # mysql

    > create database glance;

    >  grant all on glance.* to 'glance'@'%' identified by 'glance';

    8.3.2使用VIP验证数据库

     

    8.3.3编辑配置文件

    #  vim /etc/glance/glance-api.conf

    1798:[database]

    1826:connection = mysql+pymysql://glance:glance@192.168.10.100/glance

    1915:[glance_store]

    1942:stores = file,http

    1974:default_store = file

    2293:filesystem_store_datadir = /var/lib/glance/images

    3282:[keystone_authtoken]

    3283:auth_uri = http://192.168.10.100:5000

    3284:auth_url = http://192.168.10.100:35357

    3285:memcached_servers = 192.168.10.100:11211

    3286:auth_type = password

    3287:project_domain_name = default

    3288:user_domain_name = default

    3289:project_name = service

    3290:username = glance

    3291:password = glance

    4243:[paste_deploy]

    4268:flavor = keystone

    # vim glance-registry.conf

    1088:[database]

    1116:connection = mysql+pymysql://glance:glance@192.168.10.100/glance

    1205:[keystone_authtoken]

    1206:auth_uri = http://192.168.10.100:5000

    1207:auth_url = http://192.168.10.100:35357

    1208:memcached_servers = 192.168.10.100:11211

    1209:auth_type = password

    1210:project_domain_name = default

    1211:user_domain_name = default

    1212:project_name = service

    1213:username = glance

    1214:password = glance

    2137:[paste_deploy]

    2162:flavor = keystone

    8.3.4初始化glance数据库

    # su -s /bin/sh -c "glance-manage db_sync" glance

    Option "verbose" from group "DEFAULT" is deprecated for removal.  Its value may be silently ignored in the future.

    /usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1241: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo

    _db.sqlalchemy.enginefacade  expire_on_commit=expire_on_commit, _conf=conf)

    INFO  [alembic.runtime.migration] Context impl MySQLImpl.

    INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

    INFO  [alembic.runtime.migration] Running upgrade  -> liberty, liberty initial

    INFO  [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table

    INFO  [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server

    INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata01, add visibility to and remove is_public from images

    INFO  [alembic.runtime.migration] Context impl MySQLImpl.

    INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

    Upgraded database to: ocata01, current revision(s): ocata01

    8.3.5配置haproxy代理glance

    #负载服务器

    # vim  /etc/haproxy/haproxy.cfg

    listen glance-api

        bind 192.168.10.100:9292

        mode tcp

        log global

        balance source

        server glance-api1 192.168.10.201:9292 check inter 5000 rise 3 fall 3

    listen glance

        bind 192.168.10.100:9191

        mode tcp

        log global

        balance source

    server glance1 192.168.10.201:9191 check inter 5000 rise 3 fall 3

    8.3.6验证haproxy端口

    # systemctl  restart haproxy

    8.4启动glance并设置为开机启动

    # systemctl enable openstack-glance-api.service openstack-glance-registry.service

    # systemctl start openstack-glance-api.service openstack-glance-registry.service

    8.5验证glance端口

    8.6 glance服务日志

    8.7glance服务注册

    #控制端配置

    # source  admin-ocata.sh

    8.7.1创建glance服务:

    #  openstack service create --name glance --description "OpenStack Image" image

    +-------------+----------------------------------+

    | Field       | Value                            |

    +-------------+----------------------------------+

    | description | OpenStack Image                  |

    | enabled     | True                             |

    | id          | d032525e64644c55a9e89a2fe4dfc950 |

    | name        | glance                           |

    | type        | image                            |

    +-------------+----------------------------------+

    8.7.2创建公有endpoint:

    # openstack endpoint create --region RegionOne image public   http://192.168.10.100:9292

    +--------------+----------------------------------+

    | Field        | Value                            |

    +--------------+----------------------------------+

    | enabled      | True                             |

    | id           | 222519c9932c4a6cb63a6aaab0b31533 |

    | interface    | public                           |

    | region       | RegionOne                        |

    | region_id    | RegionOne                        |

    | service_id   | d032525e64644c55a9e89a2fe4dfc950 |

    | service_name | glance                           |

    | service_type | image                            |

    | url          | http://192.168.10.100:9292       |

    +--------------+----------------------------------+

    8.7.3创建私有endpoint:

    # openstack endpoint create --region RegionOne image internal http://192.168.10.100:9292

    +--------------+----------------------------------+

    | Field        | Value                            |

    +--------------+----------------------------------+

    | enabled      | True                             |

    | id           | 7b5e62d0c32d4947b8e726fcd4a1472f |

    | interface    | internal                         |

    | region       | RegionOne                        |

    | region_id    | RegionOne                        |

    | service_id   | d032525e64644c55a9e89a2fe4dfc950 |

    | service_name | glance                           |

    | service_type | image                            |

    | url          | http://192.168.10.100:9292       |

    +--------------+----------------------------------+

    8.7.4创建管理endpoint:

    [root@linux-host1 ~]# openstack endpoint create --region RegionOne image admin   http://192.168.10.100:9292

    +--------------+----------------------------------+

    | Field        | Value                            |

    +--------------+----------------------------------+

    | enabled      | True                             |

    | id           | 2d4ed97d78cf4117bb7b57c020379ec5 |

    | interface    | admin                            |

    | region       | RegionOne                        |

    | region_id    | RegionOne                        |

    | service_id   | d032525e64644c55a9e89a2fe4dfc950 |

    | service_name | glance                           |

    | service_type | image                            |

    | url          | http://192.168.10.100:9292       |

    +--------------+----------------------------------+

    8.7.5验证glance服务注册

    8.8验证glance服务

    8.9测试glance上传镜像:

    #  wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

    # source  admin-ocata.sh

    # openstack image create "cirros"   --file  /root/cirros-0.3.5-x86_64-disk.img   --disk-format qcow2 --container-format bare   --public

    +------------------+------------------------------------------------------+

    | Field            | Value                                                |

    +------------------+------------------------------------------------------+

    | checksum         | f8ab98ff5e73ebab884d80c9dc9c7290                     |

    | container_format | bare                                                 |

    | created_at       | 2017-09-14T14:16:56Z                                 |

    | disk_format      | qcow2                                                |

    | file             | /v2/images/172ac611-38b5-4ac5-8b04-b64ab6ee4481/file |

    | id               | 172ac611-38b5-4ac5-8b04-b64ab6ee4481                 |

    | min_disk         | 0                                                    |

    | min_ram          | 0                                                    |

    | name             | cirros                                               |

    | owner            | 62577e15f178420ba85eda9fce49db86                     |

    | protected        | False                                                |

    | schema           | /v2/schemas/image                                    |

    | size             | 13267968                                             |

    | status           | active                                               |

    | tags             |                                                      |

    | updated_at       | 2017-09-14T14:16:57Z                                 |

    | virtual_size     | None                                                 |

    | visibility       | public                                               |

    +------------------+------------------------------------------------------+

    8.10验证glance镜像

    #  glance image-list

    #  openstack image list

  • 相关阅读:
    laravel路由和MVC
    laravel目录介绍
    laravel下载安装
    Mac 程序员的十种武器
    Python中列表的copy方法
    Ubuntu 安装vim失败解决
    Linux userAdd 增加用户如果没有配置文件情况解决
    Ubuntu 软件管理
    awk工具详解
    httpsClient
  • 原文地址:https://www.cnblogs.com/wangshuyang/p/8670949.html
Copyright © 2020-2023  润新知