安装并配置控制节点

安装并配置控制节点

这个部分描述如何在控制节点上安装和配置块设备存储服务,即 cinder。这个服务需要至少一个额外的存储节点,以向实例提供卷。

先决条件

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

  1. 完成下面的步骤以创建数据库:

    • 用数据库连接客户端以 root 用户连接到数据库服务器:

      $ mysql -u root -p
      
    • 创建 cinder 数据库:

      mysql> CREATE DATABASE cinder;
      
    • 允许 cinder 数据库合适的访问权限:

      mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
        IDENTIFIED BY 'CINDER_DBPASS';
      mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
        IDENTIFIED BY 'CINDER_DBPASS';
      

      用合适的密码替换 CINDER_DBPASS

    • 退出数据库客户端。

  2. 获得 admin 凭证来获取只有管理员能执行的命令的访问权限:

    $ . admin-openrc
    
  3. 要创建服务证书,完成这些步骤:

    • 创建一个 cinder 用户:

      $ openstack user create --domain default --password-prompt cinder
      
      User Password:
      Repeat User Password:
      +---------------------+----------------------------------+
      | Field               | Value                            |
      +---------------------+----------------------------------+
      | domain_id           | default                          |
      | enabled             | True                             |
      | id                  | 0dbcdd0968dd4c948eacf9eb60d82b46 |
      | name                | cinder                           |
      | password_expires_at | None                             |
      +---------------------+----------------------------------+
      
    • 添加 admin 角色到 cinder 用户上。

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

      注解

      这个命令执行后没有输出。

    • 创建 cindercinderv2 服务实体:

      $ openstack service create --name cinder \
        --description "OpenStack Block Storage" volume
      
      +-------------+----------------------------------+
      | Field       | Value                            |
      +-------------+----------------------------------+
      | description | OpenStack Block Storage          |
      | enabled     | True                             |
      | id          | ab3bbbef780845a1a283490d281e7fda |
      | name        | cinder                           |
      | type        | volume                           |
      +-------------+----------------------------------+
      
      $ openstack service create --name cinderv2 \
        --description "OpenStack Block Storage" volumev2
      
      +-------------+----------------------------------+
      | Field       | Value                            |
      +-------------+----------------------------------+
      | description | OpenStack Block Storage          |
      | enabled     | True                             |
      | id          | eb9fd245bdbc414695952e93f29fe3ac |
      | name        | cinderv2                         |
      | type        | volumev2                         |
      +-------------+----------------------------------+
      

    注解

    块设备存储服务要求两个服务实体。

  4. 创建块设备存储服务的 API 入口点:

    $ openstack endpoint create --region RegionOne \
      volume public http://controller:8776/v1/%\(tenant_id\)s
    
      +--------------+-----------------------------------------+
      | Field        | Value                                   |
      +--------------+-----------------------------------------+
      | enabled      | True                                    |
      | id           | 03fa2c90153546c295bf30ca86b1344b        |
      | interface    | public                                  |
      | region       | RegionOne                               |
      | region_id    | RegionOne                               |
      | service_id   | ab3bbbef780845a1a283490d281e7fda        |
      | service_name | cinder                                  |
      | service_type | volume                                  |
      | url          | http://controller:8776/v1/%(tenant_id)s |
      +--------------+-----------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volume internal http://controller:8776/v1/%\(tenant_id\)s
    
      +--------------+-----------------------------------------+
      | Field        | Value                                   |
      +--------------+-----------------------------------------+
      | enabled      | True                                    |
      | id           | 94f684395d1b41068c70e4ecb11364b2        |
      | interface    | internal                                |
      | region       | RegionOne                               |
      | region_id    | RegionOne                               |
      | service_id   | ab3bbbef780845a1a283490d281e7fda        |
      | service_name | cinder                                  |
      | service_type | volume                                  |
      | url          | http://controller:8776/v1/%(tenant_id)s |
      +--------------+-----------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volume admin http://controller:8776/v1/%\(tenant_id\)s
    
      +--------------+-----------------------------------------+
      | Field        | Value                                   |
      +--------------+-----------------------------------------+
      | enabled      | True                                    |
      | id           | 4511c28a0f9840c78bacb25f10f62c98        |
      | interface    | admin                                   |
      | region       | RegionOne                               |
      | region_id    | RegionOne                               |
      | service_id   | ab3bbbef780845a1a283490d281e7fda        |
      | service_name | cinder                                  |
      | service_type | volume                                  |
      | url          | http://controller:8776/v1/%(tenant_id)s |
      +--------------+-----------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volumev2 public http://controller:8776/v2/%\(tenant_id\)s
    
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | 513e73819e14460fb904163f41ef3759        |
    | interface    | public                                  |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | eb9fd245bdbc414695952e93f29fe3ac        |
    | service_name | cinderv2                                |
    | service_type | volumev2                                |
    | url          | http://controller:8776/v2/%(tenant_id)s |
    +--------------+-----------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
    
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | 6436a8a23d014cfdb69c586eff146a32        |
    | interface    | internal                                |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | eb9fd245bdbc414695952e93f29fe3ac        |
    | service_name | cinderv2                                |
    | service_type | volumev2                                |
    | url          | http://controller:8776/v2/%(tenant_id)s |
    +--------------+-----------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
    
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | e652cf84dd334f359ae9b045a2c91d96        |
    | interface    | admin                                   |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | eb9fd245bdbc414695952e93f29fe3ac        |
    | service_name | cinderv2                                |
    | service_type | volumev2                                |
    | url          | http://controller:8776/v2/%(tenant_id)s |
    +--------------+-----------------------------------------+
    

    注解

    块设备存储服务每个服务实体都需要端点。

安全并配置组件

  1. 安装软件包:

    # yum install openstack-cinder
    
  1. 编辑 /etc/cinder/cinder.conf,同时完成如下动作:

    • [database] 部分,配置数据库访问:

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

      用你为块设备存储数据库选择的密码替换 CINDER_DBPASS

    • 在``[DEFAULT]``部分,配置``RabbitMQ``消息队列访问权限:

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

      用你在 “RabbitMQ” 中为 “openstack” 选择的密码替换 “RABBIT_PASS”。

    • 在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:

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

      CINDER_PASS 替换为你在认证服务中为 cinder 用户选择的密码。

      注解

      [keystone_authtoken] 中注释或者删除其他选项。

    • [DEFAULT 部分,配置``my_ip`` 来使用控制节点的管理接口的IP 地址。

      [DEFAULT]
      ...
      my_ip = 10.0.0.11
      
    • [oslo_concurrency] 部分,配置锁路径:

      [oslo_concurrency]
      ...
      lock_path = /var/lib/cinder/tmp
      
  1. 初始化块设备服务的数据库:

    # su -s /bin/sh -c "cinder-manage db sync" cinder
    

    注解

    忽略输出中任何不推荐使用的信息。

配置计算节点以使用块设备存储

  • 编辑文件 /etc/nova/nova.conf 并添加如下到其中:

    [cinder]
    os_region_name = RegionOne
    

完成安装

  1. 重启计算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
    
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.