安装并配置 Red Hat Enterprise Linux 和 CentOS 的控制器节点¶
本节描述了如何安装和配置代理服务,该服务处理对存储节点上运行的帐户、容器和对象服务的请求。为了简单起见,本指南在控制器节点上安装和配置代理服务。但是,您可以将代理服务运行在任何具有与存储节点网络连接的节点上。此外,您可以将代理服务安装和配置在多个节点上,以提高性能和冗余性。有关更多信息,请参阅部署指南。
本节适用于 Red Hat Enterprise Linux 9 和 CentOS Stream 9。
先决条件¶
代理服务依赖于身份验证和授权机制,例如 Identity 服务。但是,与其他服务不同,它还提供了一种内部机制,使其无需任何其他 OpenStack 服务即可运行。在配置对象存储服务之前,您必须创建服务凭证和 API 端点。
注意
对象存储服务在控制器节点上不使用 SQL 数据库。相反,它在每个存储节点上使用分布式 SQLite 数据库。
激活
admin凭证以访问仅管理员可用的 CLI 命令$ . admin-openrc
要创建 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 | +-------------+----------------------------------+
创建对象存储服务 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 | +--------------+----------------------------------+
安装和配置组件¶
注意
默认配置文件因发行版而异。您可能需要添加这些部分和选项,而不是修改现有的部分和选项。此外,配置片段中的省略号 (...) 表示您应该保留的潜在默认配置选项。
安装软件包
# dnf install openstack-swift-proxy python3-swiftclient \ python3-keystoneclient python3-keystonemiddleware \ memcached
注意
完整的 OpenStack 环境已经包含其中一些软件包。
从对象存储源代码仓库获取代理服务配置文件
# curl -o /etc/swift/proxy-server.conf https://opendev.org/openstack/swift/raw/branch/2025.2/etc/proxy-server.conf-sample
编辑
/etc/swift/proxy-server.conf文件并完成以下操作在
[DEFAULT]部分,配置绑定端口、用户和配置目录[DEFAULT] ... bind_port = 8080 user = swift swift_dir = /etc/swift
在
[pipeline:main]部分,删除tempurl和tempauth模块,并添加authtoken和keystoneauth模块[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