美文网首页
OpenStack部署-3安装glance

OpenStack部署-3安装glance

作者: CC_06fa | 来源:发表于2018-09-02 14:57 被阅读11次

    安装glance

    glance为虚拟机提供虚拟机的镜像服务,其本身不负责实际的存储

    安装必备条件
    1. 创建数据库
      使用root帐号登录数据库
    mysql -u root -p
    

    创建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';
    
    
    1. 获取admin用户的环境变量,并创建服务认证
    . admin-openrc
    
    1. 要创建服务凭据
    • 创建glance user
    openstack user create --domain default --password-prompt glance
    +---------------------+----------------------------------+
    | Field               | Value                            |
    +---------------------+----------------------------------+
    | domain_id           | default                          |
    | enabled             | True                             |
    | id                  | 3f4e777c4062483ab8d9edd7dff829df |
    | name                | glance                           |
    | options             | {}                               |
    | password_expires_at | None                             |
    +---------------------+----------------------------------+
    
    
    • 把admin用户添加到glance用户和项目中
    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                            |
    +-------------+----------------------------------+
    
    1. 创建镜像服务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. 安装软件包
    yum install openstack-glance
    
    1. 编辑 /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:5000
    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_store] 字段, 设置本地文件系统及镜像存储位置
    [glance_store]
    # ...
    stores = file,http
    default_store = file
    filesystem_store_datadir = /var/lib/glance/images/
    
    1. 编写 /etc/glance/glance-registry.conf 文件并完成以下操作
    • 在 [database]字段, 设置数据库接入
    [database]
    # ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
    
    • 在 [keystone_authtoken] 及[paste_deploy] 字段, 设置用户服务
    [keystone_authtoken]
    # ...
    auth_uri = http://controller:5000
    auth_url = http://controller:5000
    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 可以替换为可用的密码

    1. 填充image服务数据库
    su -s /bin/sh -c "glance-manage db_sync" glance
    
    结束安装并配置
    # systemctl enable openstack-glance-api.service \
      openstack-glance-registry.service
    # systemctl start openstack-glance-api.service \
      openstack-glance-registry.service
    

    相关文章

      网友评论

          本文标题:OpenStack部署-3安装glance

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