安装并配置 Ubuntu 的控制器节点

本节描述了如何安装和配置代理服务,该服务处理对存储节点上运行的帐户、容器和对象服务的请求。为了简单起见,本指南在控制器节点上安装和配置代理服务。但是,您可以将代理服务运行在任何具有与存储节点网络连接的节点上。此外,您可以将代理服务安装和配置在多个节点上,以提高性能和冗余性。有关更多信息,请参阅部署指南

本节适用于 Ubuntu 14.04 (LTS)。

先决条件

代理服务依赖于身份验证和授权机制,例如 Identity 服务。但是,与其他服务不同,它还提供了一种内部机制,使其无需任何其他 OpenStack 服务即可运行。在配置对象存储服务之前,您必须创建服务凭证和 API 端点。

注意

对象存储服务在控制器节点上不使用 SQL 数据库。相反,它在每个存储节点上使用分布式 SQLite 数据库。

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

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

    • 创建 swift 用户

      $ openstack user create --domain default --password-prompt swift
      User Password:
      Repeat User Password:
      +-----------+----------------------------------+
      | Field     | Value                            |
      +-----------+----------------------------------+
      | domain_id | default                          |
      | enabled   | True                             |
      | id        | d535e5cbd2b74ac7bfb97db9cced3ed6 |
      | name      | swift                            |
      +-----------+----------------------------------+
      
    • admin 角色添加到 swift 用户

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

      注意

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

    • 创建 swift 服务实体

      $ openstack service create --name swift \
        --description "OpenStack Object Storage" object-store
      +-------------+----------------------------------+
      | Field       | Value                            |
      +-------------+----------------------------------+
      | description | OpenStack Object Storage         |
      | enabled     | True                             |
      | id          | 75ef509da2c340499d454ae96a2c5c34 |
      | name        | swift                            |
      | type        | object-store                     |
      +-------------+----------------------------------+
      
  3. 创建对象存储服务 API 端点

    $ openstack endpoint create --region RegionOne \
      object-store public http://controller:8080/v1/AUTH_%\(project_id\)s
    +--------------+----------------------------------------------+
    | Field        | Value                                        |
    +--------------+----------------------------------------------+
    | enabled      | True                                         |
    | id           | 12bfd36f26694c97813f665707114e0d             |
    | interface    | public                                       |
    | region       | RegionOne                                    |
    | region_id    | RegionOne                                    |
    | service_id   | 75ef509da2c340499d454ae96a2c5c34             |
    | service_name | swift                                        |
    | service_type | object-store                                 |
    | url          | http://controller:8080/v1/AUTH_%(project_id)s |
    +--------------+----------------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      object-store internal http://controller:8080/v1/AUTH_%\(project_id\)s
    +--------------+----------------------------------------------+
    | Field        | Value                                        |
    +--------------+----------------------------------------------+
    | enabled      | True                                         |
    | id           | 7a36bee6733a4b5590d74d3080ee6789             |
    | interface    | internal                                     |
    | region       | RegionOne                                    |
    | region_id    | RegionOne                                    |
    | service_id   | 75ef509da2c340499d454ae96a2c5c34             |
    | service_name | swift                                        |
    | service_type | object-store                                 |
    | url          | http://controller:8080/v1/AUTH_%(project_id)s |
    +--------------+----------------------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      object-store admin http://controller:8080/v1
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | ebb72cd6851d4defabc0b9d71cdca69b |
    | interface    | admin                            |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 75ef509da2c340499d454ae96a2c5c34 |
    | service_name | swift                            |
    | service_type | object-store                     |
    | url          | http://controller:8080/v1        |
    +--------------+----------------------------------+
    

安装和配置组件

注意

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

  1. 安装软件包

    # apt-get install swift swift-proxy python-swiftclient \
      python-keystoneclient python-keystonemiddleware \
      memcached
    

    注意

    完整的 OpenStack 环境已经包含其中一些软件包。

    1. 创建 /etc/swift 目录。

    2. 从对象存储源代码仓库获取代理服务配置文件

      # curl -o /etc/swift/proxy-server.conf https://opendev.org/openstack/swift/raw/branch/2025.2/etc/proxy-server.conf-sample
      
    3. 编辑 /etc/swift/proxy-server.conf 文件并完成以下操作

      • [DEFAULT] 部分,配置绑定端口、用户和配置目录

        [DEFAULT]
        ...
        bind_port = 8080
        user = swift
        swift_dir = /etc/swift
        
      • [pipeline:main] 部分,删除 tempurltempauth 模块,并添加 authtokenkeystoneauth 模块

        [pipeline:main]
        pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server
        

        注意

        不要更改模块的顺序。

        注意

        有关启用其他功能的其他模块的更多信息,请参阅 部署指南

      • [app:proxy-server] 部分,启用自动帐户创建

        [app:proxy-server]
        use = egg:swift#proxy
        ...
        account_autocreate = True
        
      • [filter:keystoneauth] 部分,配置操作员角色

        [filter:keystoneauth]
        use = egg:swift#keystoneauth
        ...
        operator_roles = admin,user
        
      • [filter:authtoken] 部分,配置 Identity 服务访问

        [filter:authtoken]
        paste.filter_factory = keystonemiddleware.auth_token:filter_factory
        ...
        www_authenticate_uri = http://controller:5000
        auth_url = http://controller:5000
        memcached_servers = controller:11211
        auth_type = password
        project_domain_id = default
        user_domain_id = default
        project_name = service
        username = swift
        password = SWIFT_PASS
        delay_auth_decision = True
        

        SWIFT_PASS 替换为您在 Identity 服务中为 swift 用户选择的密码。

        注意

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

      • [filter:cache] 部分,配置 memcached 位置

        [filter:cache]
        use = egg:swift#memcache
        ...
        memcache_servers = controller:11211