美文网首页
5.2 安装和配置

5.2 安装和配置

作者: 坚果的野望 | 来源:发表于2017-08-02 15:40 被阅读0次

    本节描述如何在控制节点上安装和配置镜像服务,代号为 glance。为简单起见,该配置将映像存储在本地文件系统上。

    先决条件

    在安装和配置镜像服务之前,您必须创建一个数据库、服务凭证和 API 端点。

    1、要创建数据库,请完成以下步骤:
    使用数据库客户端以 root 用户连接到数据库服务器:

    # mysql
    

    创建 glance 数据库:

    MariaDB [(none)]> CREATE DATABASE glance;
    

    授予对 glance 数据库的适当访问权限:

    MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
      IDENTIFIED BY 'GLANCE_DBPASS';
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
      IDENTIFIED BY 'GLANCE_DBPASS';
    

    用适当的密码替换 GLANCE_DBPASS

    退出数据库客户端连接。

    2、Source admin 凭证获取对 admin 专用 CLI 命令的访问权限:

    $ . admin-openrc
    

    3、要创建服务凭据,请完成以下步骤:
    创建 glance 用户:

    $ openstack user create --domain default --password-prompt glance
    
    User Password:
    Repeat User Password:
    +---------------------+----------------------------------+
    | Field               | Value                            |
    +---------------------+----------------------------------+
    | domain_id           | default                          |
    | enabled             | True                             |
    | id                  | 3f4e777c4062483ab8d9edd7dff829df |
    | name                | glance                           |
    | options             | {}                               |
    | password_expires_at | None                             |
    +---------------------+----------------------------------+
    

    admin 角色添加到 glance 用户和 service 项目:

    $ openstack role add --project service --user glance admin
    

    这个命令不提供输出。

    创建 glance 服务实体:

    $ openstack service create --name glance \
      --description "OpenStack Image" image
    
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | OpenStack Image                  |
    | enabled     | True                             |
    | id          | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | name        | glance                           |
    | type        | image                            |
    +-------------+----------------------------------+
    

    4、创建镜像服务 API 端点:

    $ openstack endpoint create --region RegionOne \
      image public http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 340be3625e9b4239a6415d034e98aace |
    | interface    | public                           |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      image internal http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
    | interface    | internal                         |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      image admin http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 0c37ed58103f4300a84ff125a539032d |
    | interface    | admin                            |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    

    安装和配置组件

    默认配置文件因发行版而异。您可能需要添加这些部分和选项,而不是修改现有的部分和选项。同时,配置片段中的省略号 () 表示您应该保留的潜在的默认配置选项。

    1、安装包:

    apt install glance
    

    2、编辑 /etc/glance/glance-api.conf 文件并完成以下操作:
    [database] 部分,配置数据库访问:

    [database]
    # ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
    

    用您选择的镜像服务数据库的密码替换 GLANCE_DBPASS

    [keystone_authtoken][paste_deploy] 部分中,配置身份服务访问:

    [keystone_authtoken]
    # ...
    auth_uri = http://controller:5000
    auth_url = http://controller:35357
    memcached_servers = controller:11211
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    project_name = service
    username = glance
    password = GLANCE_PASS
    
    [paste_deploy]
    # ...
    flavor = keystone
    

    GLANCE_PASS 替换为在身份服务中为 glance 用户选择的密码。

    注释掉或删除 [keystone_authtoken] 部分中的其他选项。

    [glance_store] 部分,配置本地文件系统存储和镜像文件位置:

    [glance_store]
    # ...
    stores = file,http
    default_store = file
    filesystem_store_datadir = /var/lib/glance/images/
    

    3、编辑 /etc/glance/glance-registry.conf 文件并完成以下操作:
    [database] 部分,配置数据库访问:

    [database]
    # ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
    

    用您选择的镜像服务数据库的密码替换 GLANCE_DBPASS

    [keystone_authtoken][paste_deploy] 部分中,配置身份服务访问:

    [keystone_authtoken]
    # ...
    auth_uri = http://controller:5000
    auth_url = http://controller:35357
    memcached_servers = controller:11211
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    project_name = service
    username = glance
    password = GLANCE_PASS
    
    [paste_deploy]
    # ...
    flavor = keystone
    

    GLANCE_PASS 替换为在身份服务中为 glance 用户选择的密码。

    注释掉或删除 [keystone_authtoken] 部分中的其他选项。

    4、同步镜像服务数据库

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

    忽略该输出中的任何弃用消息。


    完成安装

    1、重启镜像服务:

    service glance-registry restart
    service glance-api restart
    

    相关文章

      网友评论

          本文标题:5.2 安装和配置

          本文链接:https://www.haomeiwen.com/subject/ymtylxtx.html