zoukankan      html  css  js  c++  java
  • Openstack_O版(otaka)部署_镜像服务glance部署

    安装和配置服务

    1. 建库建用户

    mysql -u root -p
    
    CREATE DATABASE glance;
    
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '123456';
    
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '123456';
    
    flush privileges;

    2. keystone认证操作

    上面提到过:所有后续项目的部署都统一放到一个租户service里,然后需要为每个项目建立用户,建管理员角色,建立关联

    . admin-openrc # 修改环境变量获取token
    
    openstack user create --domain default --password-prompt glance
    
    +---------------------+----------------------------------+
    | Field               | Value                            |
    +---------------------+----------------------------------+
    | domain_id           | 135e691ebbb74fefb5086970eac74706 |
    | enabled             | True                             |
    | id                  | e8febba19a724bc7b27e5f485f43104b |
    | name                | glance                           |
    | options             | {}                               |
    | password_expires_at | None                             |
    +---------------------+----------------------------------+
    
    openstack role add --project service --user glance admin

    建立服务实体

    openstack service create --name glance --description "OpenStack Image" image
    
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | OpenStack Image                  |
    | enabled     | True                             |
    | id          | c1334a6d30644f399acb9a40f6d7dac5 |
    | name        | glance                           |
    | type        | image                            |
    +-------------+----------------------------------+

    建端点

    openstack endpoint create --region RegionOne image public http://controller01:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 7c4e2a070c744518be0135fb34586ed4 |
    | interface    | public                           |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | c1334a6d30644f399acb9a40f6d7dac5 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller01:9292         |
    +--------------+----------------------------------+
    
    openstack endpoint create --region RegionOne image internal http://controller01:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 397aba332c94483ebe36a0f31c9206fc |
    | interface    | internal                         |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | c1334a6d30644f399acb9a40f6d7dac5 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller01:9292         |
    +--------------+----------------------------------+
    
    openstack endpoint create --region RegionOne image admin http://controller01:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | ffa5d536bb544d1f935efde4b29351db |
    | interface    | admin                            |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | c1334a6d30644f399acb9a40f6d7dac5 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller01:9292         |
    +--------------+----------------------------------+

    3. 安装软件

    1 yum install openstack-glance -y

    4. 初始化存放镜像的存储设备

    # 此处我们暂时用本地存储,但是无论哪种存储,都应该在glance启动前就已经有了,否则glance启动时通过驱动程序检索不到存储设备,
    
    # 即在glance启动后 新建的存储设备无法被glance识别到,需要重新启动glance才可以,因此我们将下面的步骤提到了最前面
    
    # 新建目录
    
    mkdir -p /var/lib/glance/images/
    
    chown glance. /var/lib/glance/images/

    5. 修改配置

    vim /etc/glance/glance-api.conf

    [database]
    
    # 这里的数据库连接配置是用来初始化生成数据库表结构,不配置无法生成数据库表结构
    
    # glance-api不配置database对创建vm无影响,对使用metada有影响
    
    # 日志报错:ERROR glance.api.v2.metadef_namespaces
    
    connection = mysql+pymysql://glance:123456@controller01/glance
    
    [keystone_authtoken]
    
    auth_url = http://controller01:5000
    
    memcached_servers = controller01:11211
    
    auth_type = password
    
    project_domain_name = default
    
    user_domain_name = default
    
    project_name = service
    
    username = glance
    
    password = 123456
    
    [paste_deploy]
    
    flavor = keystone
    
    [glance_store]
    
    stores = file,http
    
    default_store = file
    
    filesystem_store_datadir = /var/lib/glance/images/ 

    vim /etc/glance/glance-registry.conf

    [database]
    
    #这里的数据库配置是用来glance-registry检索镜像元数据
    
    connection = mysql+pymysql://glance:123456@controller01/glance

    6. 同步数据库

    此处会报一些关于future的问题,自行忽略

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

    7. 启动服务

    1 systemctl enable openstack-glance-api.service openstack-glance-registry.service
    2 systemctl start openstack-glance-api.service openstack-glance-registry.service

    验证操作

    . admin-openrc
    
    wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
    
    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       | 2018-02-02T03:15:25Z                                 |
    | disk_format      | qcow2                                                |
    | file             | /v2/images/86308a40-c496-4ca5-b84e-d9c10ffc0656/file |
    | id               | 86308a40-c496-4ca5-b84e-d9c10ffc0656                 |
    | min_disk         | 0                                                    |
    | min_ram          | 0                                                    |
    | name             | cirros                                               |
    | owner            | a3f24ce750034504876c0132c427306e                     |
    | protected        | False                                                |
    | schema           | /v2/schemas/image                                    |
    | size             | 13287936                                             |
    | status           | active                                               |
    | tags             |                                                      |
    | updated_at       | 2018-02-02T03:15:43Z                                 |
    | virtual_size     | None                                                 |
    | visibility       | public                                               |
    +------------------+------------------------------------------------------+
    
    openstack image list
    
    +--------------------------------------+--------+--------+
    | ID                                   | Name   | Status |
    +--------------------------------------+--------+--------+
    | 86308a40-c496-4ca5-b84e-d9c10ffc0656 | cirros | active |
    +--------------------------------------+--------+--------+

    参考博客 http://blog.51cto.com/egon09/1839667

  • 相关阅读:
    python3 -- 堆(heapq)
    二叉堆的实现(最大堆)
    解决layui layer.load() Ajax提交时,只在结束闪一下
    两个for循环嵌套,写成一个列表生成式
    time模块,计算当前时间和时间差
    私有化&property
    面向对象魔术方法之__str__()方法
    面向对象魔术方法-__del__()方法
    面向对象之魔术方法__init__()和__new__()
    Django的自定义标签
  • 原文地址:https://www.cnblogs.com/cq146637/p/8408843.html
Copyright © 2011-2022 走看看