本章节描述如何安装和配置在存储节点上处理account,container和object服务请求的代理服务。为了简单起见,本指南在控制节点安装和配置代理服务。不过,你可以在任何与存储节点网络联通的节点上运行代理服务。另外,你可以在多个节点安装和配置代理服务提高性能和冗余。更多信息,参考`Deployment Guide <http://docs.openstack.org/developer/swift/deployment_guide.html>`__。
代理服务依赖于诸如身份认证服务所提供的认证和授权机制。但是,与其他服务不同,它也提供了一个内部机制可以在没有任何其他OpenStack服务的情况下运行。不过为了简单起见,本指南引用:doc:`keystone`中的身份认证服务。在你配置对象存储服务前,你必须创建服务凭证和API端点。
注解
对象存储服务不使用控制节点上的SQL数据库。而是使用在每个存储节点的分布式SQLite数据库。
获得 admin 凭证来获取只有管理员能执行的命令的访问权限:
$ . admin-openrc
要创建身份认证服务的凭证,完成这些步骤:
创建 swift 用户:
$ openstack user create --domain default --password-prompt swift User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | e0353a670a9e496da891347c589539e9 | | enabled | True | | id | d535e5cbd2b74ac7bfb97db9cced3ed6 | | name | swift | +-----------+----------------------------------+
给 swift 用户添加 admin 角色:
$ 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_%\(tenant_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_%(tenant_id)s | +--------------+----------------------------------------------+ $ openstack endpoint create --region RegionOne \ object-store internal http://controller:8080/v1/AUTH_%\(tenant_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_%(tenant_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 | +--------------+----------------------------------+
注解
默认配置文件在各发行版本中可能不同。你可能需要添加这些部分,选项而不是修改已经存在的部分和选项。另外,在配置片段中的省略号(...)表示默认的配置选项你应该保留。
安装软件包:
# apt-get install swift swift-proxy python-swiftclient \ python-keystoneclient python-keystonemiddleware \ memcached
注解
完整的 OpenStack 环境已经包含了这些包的其中一部分。
创建 /etc/swift 目录。
从对象存储的仓库源中获取代理服务的配置文件:
# curl -o /etc/swift/proxy-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/mitaka
编辑文件 /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
注解
不要改变模块的顺序。
注解
更多关于启用其他模块的额外功能的信息,请参考`Deployment Guide <http://docs.openstack.org/developer/swift/deployment_guide.html>`__。
在 [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] 部分,配置认证服务访问。
[filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory ... 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 = swift password = SWIFT_PASS delay_auth_decision = True
使用你在身份认证服务中选择的 swift 用户密码来替换 SWIFT_PASS 。
注解
注释或者删除掉在 [filter:authtoken] 部分的所有其他的内容。
在 [filter:cache] 部分,配置 memcached 的位置:
[filter:cache] use = egg:swift#memcache ... memcache_servers = controller:11211
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.