- 代理服务器(swift-proxy-server):接受对象存储API和HTTP请求以上传文件、修改元数据和创建容器,也向浏览器提供文件或容器的列表。为了改进性能,代理服务器可以使用可选的缓存,通常选择memcache与代理服务器一起部署。
- 账户服务(account-server):管理对象存储中的账户。
- 容器服务(container-server):管理对象存储中容器或文件夹的映射。
- 对象服务(object-server):管理存储节点上的实际对象,比如文件。
- WSGI中间层:处理认证,通常是身份服务(KeyStone)。
- 周期性进程:在集群中执行各种维护任务,比如复制(replicator)服务确保集群中数据的一致性和可用性,其它还包括:auditor,updater和reaper。
代理服务依赖于认证和授权机制,如果使用身份服务完成认证和授权的话,则在配置管理swift之前,首先要在keystone中创建swift的认证信息和endpoint。对象存储在控制节点上不适用sql数据库。由于之前已经成功部署了KeyStone,所以这里就不在赘述KeyStone的安装过程,直接进入Swift的安装。本次安装是在单节点的虚拟机进行的,也就是控制节点和存储节点部署在相同的主机中,操作系统为CentOS7.1。首先在KeyStone中创建Swift的用户、服务及endpoint,具体命令及结果如下:
[openstack@localhost ~]$ keystone user-create --name swift --pass 123456 +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | | | enabled | True | | id | ed4f45ac3e8a4ac683d54b642e61ac04 | | name | swift | | username | swift | +----------+----------------------------------+ keystone user-role-add --user swift --role admin --tenant service [openstack@localhost ~]$ keystone service-create --name swift --type object-store +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | | | enabled | True | | id | 094cc0da43e348f8b792f77ef99f8e7e | | name | swift | | type | object-store | +-------------+----------------------------------+ [openstack@localhost ~]$ keystone endpoint-create --region regionOne --service swift --publicurl 'http://localhost:8080/v1/AUTH_%(tenant_id)s' --internalurl 'http://localhost:8080/v1/AUTH_%(tenant_id)s' --adminurl 'http://localhost:8080/v1/AUTH_%(tenant_id)s' +-------------+-----------------------------------------------------------------+ | Property | Value | +-------------+-----------------------------------------------------------------+ | adminurl | http://locoalhost:8080/v1/ | | id | c0da7d196e204e038766740e405dbbce | | internalurl | http://locoalhost:8080/v1/AUTH_2835009c452b4d408f95ff5a920fc877 | | publicurl | http://locoalhost:8080/v1/AUTH_2835009c452b4d408f95ff5a920fc877 | | region | regionOne | | service_id | 094cc0da43e348f8b792f77ef99f8e7e | +-------------+-----------------------------------------------------------------+然后安装proxy-server,swift客户端、memcached等:yum install openstack-swift-proxy python-swiftclient python-keystone-auth-token python-keystonemiddleware memcached。上面命令中的python-keystone-auth-token是无法安装的,当使用yum安装时将会报如下的异常信息:没有可用软件包 python-keystone-auth-token。经过在OpenStack的官网确认,该问题属于文档中的错误,直接忽略该问题或者执行yum install openstack-swift-proxy python-swiftclient python-keystonemiddleware memcached。安装执行完毕后,执行下面的命令下载proxy-server.conf文件:
curl -o /etc/swift/proxy-server.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/proxyserver.conf-sample下载完成后需要对文件中的配置参数进行修改,修改的具体内容如下: @H_502_25@
[DEFAULT] ... bind_port = 8080 user = swift swift_dir = /etc/swift
- 在[pipeline:main]中,启用合适的模块:
[pipeline:main] pipeline = authtoken cache healthcheck keystoneauth proxy-logging proxy-server@H_502_25@
[app:proxy-server] ... allow_account_management = true account_autocreate = true
- 在[filter:keystoneauth]中配置合适的操作角色;
[filter:keystoneauth] use = egg:swift#keystoneauth ... operator_roles = admin,_member_
- 在[filter:authtoken]中配置认证服务的相关信息:
[filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory ... auth_uri = http://localhost:5000/v2.0 identity_uri = http://localhost:35357 admin_tenant_name = service admin_user = swift admin_password = SWIFT_PASS #指定为使用keystone创建swift用户时设置的密码,比如123456 delay_auth_decision = true
- 在[filter:cache]中,配置memcached的位置:
[filter:cache] ... memcache_servers = 127.0.0.1:11211这样就完成了proxy-server的安装和部署,可以使用systemctl启动该服务了,但目前先不启动该服务,直到部署配置存储服务后。在安装存储服务之前,先为存储服务指定存储目录,这需要将磁盘分区挂载到存储目录。根据官方的安装手册,挂载的磁盘必须具备分区表,也就是该磁盘已经分区完毕。经过测试,该磁盘具备几个分区不重要,但必须执行了分区,可以使用fdisk命令进行磁盘分区操作。虽然Swift支持各种文件系统,但根据测试XFS文件系统具有最好的性能和稳定性,所以对磁盘分区后,比如/dev/sdb1,需要使用命令mkfs.xfs对/dev/sdb1进行格式化:mkfs.xfs /dev/sdb1。格式化完成后,创建挂载目录:mkdir -p /srv/node/,然后编辑/etc/fstab,添加下面语句: