安装和配置控制器节点

本节描述了如何在控制器节点上安装和配置块存储服务,代号为 cinder。此服务需要至少一个额外的存储节点来为实例提供卷。

先决条件

在安装和配置块存储服务之前,您必须创建数据库、服务凭证和 API 端点。

  1. 要创建数据库,请完成以下步骤

    1. 使用数据库访问客户端以 root 用户身份连接到数据库服务器

      $ mysql -u root -p
      
    2. 创建 cinder 数据库

      MariaDB [(none)]> CREATE DATABASE cinder;
      
    3. 授予对 cinder 数据库的适当访问权限

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

      CINDER_DBPASS 替换为合适的密码。

    4. 退出数据库访问客户端。

  2. 激活 admin 凭证以访问仅管理员可用的 CLI 命令

    $ . admin-openrc
    
  3. 要创建服务凭证,请完成以下步骤

    1. 创建一个 cinder 用户

       $ openstack user create --domain default --password-prompt cinder
      
      User Password:
      Repeat User Password:
      +---------------------+----------------------------------+
      | Field               | Value                            |
      +---------------------+----------------------------------+
      | domain_id           | default                          |
      | enabled             | True                             |
      | id                  | 9d7e33de3e1a498390353819bc7d245d |
      | name                | cinder                           |
      | options             | {}                               |
      | password_expires_at | None                             |
      +---------------------+----------------------------------+
      
    2. admin 角色添加到 cinder 用户

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

      注意

      此命令不会产生任何输出。

    3. 创建 cinderv3 服务实体

       $ openstack service create --name cinderv3 \
        --description "OpenStack Block Storage" volumev3
      
      +-------------+----------------------------------+
      | Field       | Value                            |
      +-------------+----------------------------------+
      | description | OpenStack Block Storage          |
      | enabled     | True                             |
      | id          | ab3bbbef780845a1a283490d281e7fda |
      | name        | cinderv3                         |
      | type        | volumev3                         |
      +-------------+----------------------------------+
      

      注意

      从 Xena 版本开始,块存储服务只需要一个服务实体。对于早期版本,请参阅该特定版本的文档。

  4. 创建块存储服务 API 端点

    $ openstack endpoint create --region RegionOne \
      volumev3 public http://controller:8776/v3/%\(project_id\)s
    
    +--------------+------------------------------------------+
    | Field        | Value                                    |
    +--------------+------------------------------------------+
    | enabled      | True                                     |
    | id           | 03fa2c90153546c295bf30ca86b1344b         |
    | interface    | public                                   |
    | region       | RegionOne                                |
    | region_id    | RegionOne                                |
    | service_id   | ab3bbbef780845a1a283490d281e7fda         |
    | service_name | cinderv3                                 |
    | service_type | volumev3                                 |
    | url          | http://controller:8776/v3/%(project_id)s |
    +--------------+------------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volumev3 internal http://controller:8776/v3/%\(project_id\)s
    
    +--------------+------------------------------------------+
    | Field        | Value                                    |
    +--------------+------------------------------------------+
    | enabled      | True                                     |
    | id           | 94f684395d1b41068c70e4ecb11364b2         |
    | interface    | internal                                 |
    | region       | RegionOne                                |
    | region_id    | RegionOne                                |
    | service_id   | ab3bbbef780845a1a283490d281e7fda         |
    | service_name | cinderv3                                 |
    | service_type | volumev3                                 |
    | url          | http://controller:8776/v3/%(project_id)s |
    +--------------+------------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volumev3 admin http://controller:8776/v3/%\(project_id\)s
    
    +--------------+------------------------------------------+
    | Field        | Value                                    |
    +--------------+------------------------------------------+
    | enabled      | True                                     |
    | id           | 4511c28a0f9840c78bacb25f10f62c98         |
    | interface    | admin                                    |
    | region       | RegionOne                                |
    | region_id    | RegionOne                                |
    | service_id   | ab3bbbef780845a1a283490d281e7fda         |
    | service_name | cinderv3                                 |
    | service_type | volumev3                                 |
    | url          | http://controller:8776/v3/%(project_id)s |
    +--------------+------------------------------------------+
    

安装和配置组件

  1. 安装软件包

    # zypper install openstack-cinder-api openstack-cinder-scheduler
    
  2. 编辑 /etc/cinder/cinder.conf 文件并完成以下操作

    1. [database] 部分,配置数据库访问

      [database]
      # ...
      connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
      

      CINDER_DBPASS 替换为您为块存储数据库选择的密码。

    2. [DEFAULT] 部分中,配置 RabbitMQ 消息队列访问

      [DEFAULT]
      # ...
      transport_url = rabbit://openstack:RABBIT_PASS@controller
      

      RABBIT_PASS 替换为您为 RabbitMQ 中的 openstack 帐户选择的密码。

    3. [DEFAULT][keystone_authtoken] 部分中,配置身份服务访问

      [DEFAULT]
      # ...
      auth_strategy = keystone
      
      [keystone_authtoken]
      # ...
      www_authenticate_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 = cinder
      password = CINDER_PASS
      

      CINDER_PASS 替换为您在身份服务中为 cinder 用户选择的密码。

      注意

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

    4. [DEFAULT] 部分中,配置 my_ip 选项以使用控制器节点的管理接口 IP 地址

      [DEFAULT]
      # ...
      my_ip = 10.0.0.11
      
  3. [oslo_concurrency] 部分中,配置锁路径

    [oslo_concurrency]
    # ...
    lock_path = /var/lib/cinder/tmp
    

配置 Compute 使用块存储

  1. 编辑 /etc/nova/nova.conf 文件并向其中添加以下内容

    [cinder]
    os_region_name = RegionOne
    

完成安装

  1. 重新启动 Compute API 服务

    # systemctl restart openstack-nova-api.service
    
  2. 启动块存储服务并配置它们在系统启动时启动

    # systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
    # systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service