安装并配置控制节点

安装并配置控制节点

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

前提条件

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

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

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

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

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

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

      用合适的密码替换 CINDER_DBPASS

    • 退出数据库客户端。

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

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

    • 创建一个 cinder 用户:

      $ openstack user create --domain default --password-prompt cinder
      User Password:
      Repeat User Password:
      +-----------+----------------------------------+
      | Field     | Value                            |
      +-----------+----------------------------------+
      | domain_id | default                          |
      | enabled   | True                             |
      | id        | bb279f8ffc444637af38811a5e1f0562 |
      | name      | cinder                           |
      +-----------+----------------------------------+
      
    • 添加 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. 安装软件包:

    # apt-get install cinder-api cinder-scheduler python-cinderclient
    
  1. 编辑 /etc/cinder/cinder.conf,同时完成如下操作:

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

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

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

    • 在 “[DEFAULT]” 和 “[oslo_messaging_rabbit]”部分,配置 “RabbitMQ” 消息队列访问:

      [DEFAULT]
      ...
      rpc_backend = rabbit
      
      [oslo_messaging_rabbit]
      ...
      rabbit_host = controller
      rabbit_userid = openstack
      rabbit_password = RABBIT_PASS
      

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

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

      [DEFAULT]
      ...
      auth_strategy = keystone
      
      [keystone_authtoken]
      ...
      auth_uri = http://controller:5000
      auth_url = http://controller:35357
      auth_plugin = password
      project_domain_id = default
      user_domain_id = 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
      
    • (可选的)为帮助排错,在 “[DEFAULT]”部分启用详细日志。

      [DEFAULT]
      ...
      verbose = True
      
  2. 初始化块设备服务的数据库:

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

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

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

    [cinder]
    os_region_name = RegionOne
    

完成安装

  1. 重启计算API 服务:

    # service nova-api restart
    
  2. 重启块设备存储服务:

    # service cinder-scheduler restart
    # service cinder-api restart
    
  3. 默认情况下,Ubuntu 上的安装包会自动创建一个 SQLite 数据库。

    因为这里配置使用SQL 数据库服务器,所以你可以SQLite 服务库文件:

    # rm -f /var/lib/cinder/cinder.sqlite
    
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.