之前介绍了《OpenStack Swift All In One安装部署流程与简单使用》,那么接下来就说一说Swift集群部署吧。
1. 简介
本文档详细描述了使用两台PC部署一个小型Swift集群的过程,并给出一些简单的使用实例。本文档假定如下前提条件:
- 使用Ubuntu操作系统。
- 每台机器都运行Swift的所有服务,既是Proxy Server,又是Storage Server,用户可以向任何一台机器发起存储服务请求。
- 采用Swift自带的TempAuth作为用户的身份与权限认证。
- 所有机器构成memcached集群来提供Token缓存服务。
- 所有操作均在root用户下进行,并使用root作为Swift的用户和组。
- 所有机器都运行在局域网中。
- 使用回环设备和XFS文件系统作为Swift底层存储。
阅读本文档前,可以先阅读文档《Swift All In One安装部署流程》,学习Swift单机部署的相关知识。
2. 安装部署
2.1 准备环境
| PC 1 | PC 2 |
机器类型: | PC物理机 | PC物理机 |
操作系统: | Ubuntu-12.04-desktop-64位 | Ubuntu-12.04-desktop-64位 |
用户类型: | root | root |
数据库: | sqlite3 | sqlite3 |
IP地址: | 192.168.3.52(局域网) | 192.168.3.53(局域网) |
Proxy Server: | 是 | 是 |
Storage Server: | 是 | 是 |
Auth: | TempAuth | TempAuth |
Token缓存: | memcached | memcached |
2.2 版本说明
本文档基于:
- 官方文档:Swift 1.7.7-dev documentation -> Instructions for a Multiple Server Swift Installation (Ubuntu)
- Swift版本:1.7.6
- python-swiftclient版本:1.2.0
请确保安装的Swift版本与本文档中的版本相同。如有问题,请参考官网的更新文档。
2.3 安装软件环境
首先,在PC1和PC2上安装Swift所需的软件环境(确保你的机器可以访问互联网),例如,sqlite3作为本地数据库,memcached作为Token缓存。Ubuntu-12.04已自带rsync工具,因此不用另行安装。
# cd ~/swift # git clone https://github.com/openstack/swift.git # git clone https://github.com/openstack/python-swiftclient.git |
eventlet>=0.9.15 greenlet>=0.3.1 netifaces>=0.6 pastedeploy>=1.3.3 simplejson>=2.0.9 xattr>=0.4 python-swiftclient |
mkdir -p /var/run/swift chown root:root /var/run/swift |
/srv/swift-disk /srv/node/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
4. 创建回环设备挂载点文件夹,并执行挂载。改变挂载点文件夹的权限。# chown -R root:root /srv/node
2.5.2 配置Swift 在PC1和PC2上创建Swift的配置文件目录。# mkdir -p /etc/swift
# chown -R root:root /etc/swift/
在PC1中创建配置文件/etc/swift/swift.conf,编辑其内容(如下所示),然后复制到PC2中的/etc/swift目录下。该文件记录了Swift使用的哈希后缀,用于一致性哈希计算。集群中的每个节点都必须保存该文件,并且完全相同。[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = jtangfs
2.5.3 配置rsync rsync是类Unix系统下的数据镜像备份工具。Swift对象副本的复制更新是基于推送模式的。对象的复制更新使用rsync将文件同步到对等节点,Account和Container的复制更新则通过HTTP或rsync来推送数据库文件上丢失的记录。在PC1和PC2上创建rsync的配置文件/etc/rsyncd.conf,添加如下内容:(下面以PC1为例,其中的address是PC1上rsync服务端监听的IP地址,等待客户端推送复制更新,这里同样推荐设置为内网地址)uid = root
gid = root
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.3.52
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock
为了使rsync能够开机启动,需要在PC1和PC2上编辑配置文件/etc/default/rsync,将参数RSYNC_ENABLE设置为true,然后启动rsync服务。# perl -pi -e 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync
# service rsync restart
2.5.4 配置存储服务(account, container, object) 在PC1和PC2上执行以下操作,以完成每个节点上的account、container和object存储服务的配置。下面以PC1上的操作为例。 1. 配置account存储服务,创建配置文件/etc/swift/account-server.conf,并添加以下内容:(其中,devices参数表示Parent directory of where devices are mounted,默认值为/srv/node;log_facility表示日志标签,与独立日志的配置有关)[DEFAULT]
devices = /srv/node
mount_check = false
bind_ip = 192.168.3.52
bind_port = 6002
workers = 4
user = root
log_facility = LOG_LOCAL4
[pipeline:main]
pipeline = account-server
[app:account-server]
use = egg:swift#account
[account-replicator]
[account-auditor]
[account-reaper]
2. 配置container存储服务,创建配置文件/etc/swift/container-server.conf,并添加以下内容:[DEFAULT]
devices = /srv/node
mount_check = false
bind_ip = 192.168.3.52
bind_port = 6001
workers = 4
user = root
log_facility = LOG_LOCAL3
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
[container-updater]
[container-auditor]
[container-sync]
3. 配置object存储服务,创建配置文件/etc/swift/object-server.conf,并添加以下内容:[DEFAULT]
devices = /srv/node
mount_check = false
bind_ip = 192.168.3.52
bind_port = 6000
workers = 4
user = root
log_facility = LOG_LOCAL2
[pipeline:main]
pipeline = object-server
[app:object-server]
use = egg:swift#object
[object-replicator]
[object-updater]
[object-auditor]
2.5.5 配置独立日志(可选) Swift默认将日志信息输出到文件/var/log/syslog中。如果要按照个人需求设置rsyslog,生成特有的Swift日志文件,则需要在PC1和PC2上执行以下操作,完成独立日志的配置。 1. 创建日志配置文件/etc/rsyslog.d/10-swift.conf,编辑内容如下:(增加account、container、object的日志配置信息)# Uncomment the following to have a log containing all logs together
#local1,local2,local3,local4,local5.* /var/log/swift/all.log
# Uncomment the following to have hourly proxy logs for stats processing
$template HourlyProxyLog,"/var/log/swift/hourly/%$YEAR%%$MONTH%%$DAY%%$HOUR%"
#local1.*;local1.!notice ?HourlyProxyLog
local2.*;local2.!notice /var/log/swift/object.log
local2.notice /var/log/swift/ object.error
local2.* ~
local3.*;local3.!notice /var/log/swift/container.log
local3.notice /var/log/swift/ container.error
local3.* ~
local4.*;local4.!notice /var/log/swift/account.log
local4.notice /var/log/swift/ account.error
local4.* ~
2. 编辑文件/etc/rsyslog.conf,更改参数$PrivDropToGroup为adm。2.6.3 配置proxy-server 在PC1和PC2上创建proxy-server配置文件/etc/swift/proxy-server.conf,添加以下内容:[DEFAULT]
bind_port = 8080
user = root
workers = 8
log_facility = LOG_LOCAL1
[pipeline:main]
pipeline = healthcheck cache tempauth proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
reseller_prefix = AUTH
# account和token的命名前缀,注意此处不可以加“_”。
# 例如X-Storage-Url为http://192.168.3.52:8080/v1/AUTH_test
# 例如X-Auth-Token为AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
token_life = 86400
# token的有效期,单位:秒。
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
memcache_servers = 192.168.3.52:11211,192.168.3.53:11211
[filter:proxy-logging]
use = egg:swift#proxy_logging
配置参数中:memcache_servers指定memcached地址,可配置为集群,以“,”分隔;workers为工作线程数,推荐配置为CPU核心数的2-4倍;“user_admin_admin = admin .admin .reseller_admin”中,user_为前缀,第一个“admin”为账户名,第二个“admin”为用户名,第三个“admin为”密码,“.admin”为角色信息,“.reseller_admin”表示超级管理员角色(可操作任何账户)。 “user_admin_admin = admin .admin .reseller_admin”后面还可以增加一项<storage-url>,显示地指定Swift为该用户提供的存储服务入口(PC1为admin用户提供的默认值是http://192.168.3.52:8080/v1/AUTH_admin)。admin用户通过认证后,Swift会把Token和该<storage-url>返回给用户,此后admin用户可以使用该<storage-url>访问Swift来请求存储服务。特别值得说明的是,如果在Proxy Server前面增加了负载均衡器(如nginx),那么该<storage-url>应该指向负载均衡器,使得用户在通过认证后,向负载均衡器发起存储请求,再由负载均衡器将请求均衡地分发给Proxy Server集群。此时的<storage-url>形如http://<LOAD_BALANCER_HOSTNAME>:<PORT>/v1/AUTH_admin。 Swift同时支持http和https协议,本文档中我们使用http协议,若想使用https协议,则需要进行ssl的配置,具体操作请查看参考链接中的内容。2.6.4 配置独立日志(可选) 上文中已经做了说明,此处可用于设置Proxy Server的独立日志,需要在PC1和PC2上执行以下操作,完成其配置。 1. 编辑日志配置文件/etc/rsyslog.d/10-swift.conf,增加proxy的日志配置信息:# Uncomment the following to have a log containing all logs together
#local1,local2,local3,local4,local5.* /var/log/swift/all.log
# Uncomment the following to have hourly proxy logs for stats processing
$template HourlyProxyLog,"/var/log/swift/hourly/%$YEAR%%$MONTH%%$DAY%%$HOUR%"
#local1.*;local1.!notice ?HourlyProxyLog
local1.*;local1.!notice /var/log/swift/proxy.log
local1.notice /var/log/swift/ proxy.error
local1.* ~
local2.*;local2.!notice /var/log/swift/object.log
local2.notice /var/log/swift/ object.error
local2.* ~
local3.*;local3.!notice /var/log/swift/container.log
local3.notice /var/log/swift/ container.error
local3.* ~
local4.*;local4.!notice /var/log/swift/account.log
local4.notice /var/log/swift/ account.error
local4.* ~
2. 重启rsyslog服务Ring共有三种,分别为Account Ring、Container Ring、Object Ring。Ring需要在整个集群中保持完全相同,因此需要在某一台PC上创建Ring文件,然后复制到其他PC上。我们将在PC1上进行Ring的创建,然后复制到PC2上。 首先,使用如下命令创建三个Ring。其中,18表示Ring的分区数为218;2表示对象副本数为2;1表示分区数据的迁移时间为1小时(这个解释有待证实)。# cd /etc/swift
# swift-ring-builder account.builder create 18 2 1
# swift-ring-builder container.builder create 18 2 1
# swift-ring-builder object.builder create 18 2 1
然后向三个Ring中添加存储设备。其中z1和z2表示zone1和zone2;sdb1为Swift使用的存储空间,即上文挂在的回环设备;100代表设备的权重。# cd /etc/swift
# swift-ring-builder account.builder add z1-192.168.3.52:6002/sdb1 100
# swift-ring-builder container.builder add z1-192.168.3.52:6001/sdb1 100
# swift-ring-builder object.builder add z1-192.168.3.52:6000/sdb1 100
# swift-ring-builder account.builder add z2-192.168.3.53:6002/sdb1 100
# swift-ring-builder container.builder add z2-192.168.3.53:6001/sdb1 100
# swift-ring-builder object.builder add z2-192.168.3.53:6000/sdb1 100
Ring文件创建完毕后,可以通过以下命令来查看刚才添加的信息,以验证是否输入正确。若发现错误,以Account Ring为例,可以使用swift-ring-builder account.builder的删除方法删除已添加的设备,然后重新添加。2.7 创建Swift执行脚本 为便于操作,我们可以在PC1和PC2上创建以下Swift脚本。 1. 创建~/swift/bin/remakerings脚本文件,添加以下内容,即可一键完成Ring的重新创建,当然具体内容需要根据实际环境进行修改。#!/bin/bash
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
swift-ring-builder account.builder create 18 2 1
swift-ring-builder container.builder create 18 2 1
swift-ring-builder object.builder create 18 2 1
swift-ring-builder account.builder add z1-192.168.3.52:6002/sdb1 100
swift-ring-builder container.builder add z1-192.168.3.52:6001/sdb1 100
swift-ring-builder object.builder add z1-192.168.3.52:6000/sdb1 100
swift-ring-builder account.builder add z2-192.168.3.53:6002/sdb1 100
swift-ring-builder container.builder add z2-192.168.3.53:6001/sdb1 100
swift-ring-builder object.builder add z2-192.168.3.53:6000/sdb1 100
swift-ring-builder account.builder rebalance
swift-ring-builder container.builder rebalance
swift-ring-builder object.builder rebalance
2. 创建~/swift/bin/resetswift脚本文件,添加以下内容,即可一键清空Swift的对象数据和日志,完成重置。注意:如果使用的是独立分区存储,则需要另行处理,例如将/srv/swift-disk替换为/dev/sdb1等;如果没有使用rsyslog作为独立日志,则需要去掉“find /var/log/swift... ”和“sudo service rsyslog restart”这两行。#!/bin/bash
swift-init all stop
find /var/log/swift -type f -exec rm -f {} \;
sudo umount /srv/node/sdb1
sudo mkfs.xfs -f -i size=1024 /srv/swift-disk
sudo mount /srv/node/sdb1
sudo chown root:root /srv/node/sdb1
sudo rm -f /var/log/debug /var/log/messages /var/log/rsyncd.log /var/log/syslog
sudo service rsyslog restart
sudo service rsync restart
sudo service memcached restart
3. 创建~/swift/bin/startmain脚本文件,添加以下内容,即可一键启动Swift的基本服务,包括proxy-server、account-server、container-server和object-server。#!/bin/bash
swift-init main start
4. 创建~/swift/bin/stopmain脚本文件,添加以下内容,即可一键关闭Swift的基本服务,包括proxy-server、account-server、container-server和object-server。#!/bin/bash
swift-init main stop
5. 创建~/swift/bin/startall脚本文件,添加以下内容,即可一键启动Swift的所有服务,包括proxy-server、account-server、account-replicator 、account-auditor、container-server、container-replicator、container-updater、container-auditor、object-server、object-replicator、object-updater、object-auditor。#!/bin/bash
swift-init proxy start
swift-init account-server start
swift-init account-replicator start
swift-init account-auditor start
swift-init container-server start
swift-init container-replicator start
swift-init container-updater start
swift-init container-auditor start
swift-init object-server start
swift-init object-replicator start
swift-init object-updater start
swift-init object-auditor start
6. 创建~/swift/bin/stopall脚本文件,添加以下内容,即可一键关闭Swift的所有服务,包括proxy-server、account-server、account-replicator 、account-auditor、container-server、container-replicator、container-updater、container-auditor、object-server、object-replicator、object-updater、object-auditor。#!/bin/bash
swift-init proxy stop
swift-init account-server stop
swift-init account-replicator stop
swift-init account-auditor stop
swift-init container-server stop
swift-init container-replicator stop
swift-init container-updater stop
swift-init container-auditor stop
swift-init object-server stop
swift-init object-replicator stop
swift-init object-updater stop
swift-init object-auditor stop
7. 完成脚本创建后,需要更改脚本权限,使之能够执行。# chmod +x ~/swift/bin/*
2.8 启动与关闭Swift服务 由于我们是以开发的方式安装Swift的,所以能够执行功能单元测试。若提示“Unable to read test config /etc/swift/test.conf – file not found”,可不必理会,或手动将配置文件~/swift/swift_1.7.6/test/sample.conf复制过去。# cd ~/swift/swift_1.7.6
# ./.unittests
我们需要在PC1和PC2上启动Proxy Server和Storage Server的服务。为了便于操作,我们直接使用上文中创建的脚本文件(在~/swift/bin目录下)运行Swift。可以使用~/swift/bin/startmain脚本文件启动Swift的基本服务;或使用~/swift/bin/startall脚本文件键启动Swift的所有服务。若提示“Unable to increase file descriptor limit. Running as non-root?”警告为正常现象,不必理会。# startmain
或
# startall
同样的,我们可以使用~/swift/bin/stopmain脚本文件关闭Swift的基本服务;使用~/swift/bin/stopall脚本文件键关闭Swift的所有服务。# stopmain
或
# stopall
2.9 查看Swift帮助信息 完成安装部署后,可以使用swift --help命令查看Swift帮助信息。# swift --help
Usage: swift <command> [options] [args]
Commands:
stat [container] [object]
Displays information for the account, container, or object depending on the
args given (if any).
list [options] [container]
Lists the containers for the account or the objects for a container. -p or
--prefix is an option that will only list items beginning with that prefix.
-d or --delimiter is option (for container listings only) that will roll up
items with the given delimiter (see Cloud Files general documentation for
what this means).
upload [options] container file_or_directory [file_or_directory] [...]
Uploads to the given container the files and directories specified by the
remaining args. -c or --changed is an option that will only upload files
that have changed since the last upload. -S <size> or --segment-size <size>
and --leave-segments are options as well (see --help for more).
post [options] [container] [object]
Updates meta information for the account, container, or object depending on
the args given. If the container is not found, it will be created
automatically; but this is not true for accounts and objects. Containers
also allow the -r (or --read-acl) and -w (or --write-acl) options. The -m
or --meta option is allowed on all and used to define the user meta data
items to set in the form Name:Value. This option can be repeated. Example:
post -m Color:Blue -m Size:Large
download --all OR download container [options] [object] [object] ...
Downloads everything in the account (with --all), or everything in a
container, or a list of objects depending on the args given. For a single
object download, you may use the -o [--output] <filename> option to
redirect the output to a specific file or if "-" then just redirect to
stdout.
delete [options] --all OR delete container [options] [object] [object] ...
Deletes everything in the account (with --all), or everything in a
container, or a list of objects depending on the args given. Segments of
manifest objects will be deleted as well, unless you specify the
--leave-segments option.
Example:
swift -A https://auth.api.rackspacecloud.com/v1.0 -U user -K key stat
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-s, --snet Use SERVICENET internal network
-v, --verbose Print more info
-q, --quiet Suppress status output
-A AUTH, --auth=AUTH URL for obtaining an auth token
-V AUTH_VERSION, --auth-version=AUTH_VERSION
Specify a version for authentication. Defaults to 1.0.
-U USER, --user=USER User name for obtaining an auth token.
-K KEY, --key=KEY Key for obtaining an auth token.
--os-username=<auth-user-name>
Openstack username. Defaults to env[OS_USERNAME].
--os-password=<auth-password>
Openstack password. Defaults to env[OS_PASSWORD].
--os-tenant-id=<auth-tenant-id>
OpenStack tenant ID. Defaults to env[OS_TENANT_ID]
--os-tenant-name=<auth-tenant-name>
Openstack tenant name. Defaults to
env[OS_TENANT_NAME].
--os-auth-url=<auth-url>
Openstack auth URL. Defaults to env[OS_AUTH_URL].
--os-auth-token=<auth-token>
Openstack token. Defaults to env[OS_AUTH_TOKEN]
--os-storage-url=<storage-url>
Openstack storage URL. Defaults to env[OS_STORAGE_URL]
--os-region-name=<region-name>
Openstack region name. Defaults to env[OS_REGION_NAME]
--os-service-type=<service-type>
Openstack Service type. Defaults to
env[OS_SERVICE_TYPE]
--os-endpoint-type=<endpoint-type>
Openstack Endpoint type. Defaults to
env[OS_ENDPOINT_TYPE]
--insecure Allow swiftclient to access insecure keystone server.
The keystone's certificate will not be verified.
3. 使用实例 启动PC1和PC2上的Swift服务后,我们交替地在PC1和PC2上执行操作,并随机使用两者提供的storage-url,如果用户验证和存储服务全部正确,则表明Swift集群部署成功。3.1 用curl测试 我们先使用curl测试几个简单的命令。 1. 在PC1上访问192.168.3.52,进行tester用户验证,获取Token和storage-url。# curl -k -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://192.168.3.52:8080/auth/v1.0
* About to connect() to 192.168.3.52 port 8080 (#0)
* Trying 192.168.3.52... connected
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.3.52:8080
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://192.168.3.52:8080/v1/AUTH_test
< X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
< Content-Length: 0
< Date: Wed, 20 Mar 2013 06:13:15 GMT
<
* Connection #0 to host 192.168.3.52 left intact
* Closing connection #0
2. 在PC1上访问192.168.3.52,查看test账户的状态信息。# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.52:8080/v1/AUTH_test
* About to connect() to 192.168.3.52 port 8080 (#0)
* Trying 192.168.3.52... connected
> GET /v1/AUTH_test HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.3.52:8080
> Accept: */*
> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Accept-Ranges: bytes
< X-Timestamp: 1363760036.52552
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< Content-Type: text/html; charset=UTF-8
< X-Account-Object-Count: 0
< Date: Wed, 20 Mar 2013 06:13:56 GMT
<
* Connection #0 to host 192.168.3.52 left intact
* Closing connection #0
3. 在PC1上访问192.168.3.53,查看test账户的状态信息。# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.53:8080/v1/AUTH_test
* About to connect() to 192.168.3.53 port 8080 (#0)
* Trying 192.168.3.53... connected
> GET /v1/AUTH_test HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.3.53:8080
> Accept: */*
> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Accept-Ranges: bytes
< X-Timestamp: 1363760036.52552
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< Content-Type: text/html; charset=UTF-8
< X-Account-Object-Count: 0
< Date: Wed, 20 Mar 2013 06:15:19 GMT
<
* Connection #0 to host 192.168.3.53 left intact
* Closing connection #0
4. 在PC2上访问192.168.3.52,查看test账户的状态信息。# curl -k -v -H 'X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1' http://192.168.3.52:8080/v1/AUTH_test
* About to connect() to 192.168.3.52 port 8080 (#0)
* Trying 192.168.3.52... connected
> GET /v1/AUTH_test HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 192.168.3.52:8080
> Accept: */*
> X-Auth-Token: AUTH_tk440e9bd9a9cb46d6be07a5b6a585f7d1
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Accept-Ranges: bytes
< X-Timestamp: 1363760036.52552
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< Content-Type: text/html; charset=UTF-8
< X-Account-Object-Count: 0
< Date: Wed, 20 Mar 2013 06:17:01 GMT
<
* Connection #0 to host 192.168.3.52 left intact
* Closing connection #0
上述测试一切正常,表明curl测试通过。3.2 用Swift客户端测试 接着,我们使用Swift客户端进行测试。 1. 在PC1上访问192.168.3.53,查看test账户的状态信息。# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing stat
Account: AUTH_test
Containers: 0
Objects: 0
Bytes: 0
Accept-Ranges: bytes
X-Timestamp: 1363760036.52552
Content-Type: text/plain; charset=utf-8
2. 在PC1上访问192.168.3.52,在test账户下创建名为myfiles的container。# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing post myfiles
3. 在PC1上访问192.168.3.53,显示test账户下的container列表。
# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing list
myfiles
4. 在PC2上访问192.168.3.52,显示test账户下的container列表。# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing list
myfiles
5. 在PC2上访问192.168.3.53,在刚才创建的container下上传文件。上传完成后,Swift服务端会以完整路径作为文件名。# swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing upload myfiles ~/file
root/file
6. 在PC1上访问192.168.3.52,显示刚才创建的container下的文件列表。# swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing list myfiles
root/file
7. 在PC1上访问192.168.3.52,下载刚才上传的文件。给定的文件名必须是其完整路径,例如上传的文件为~/file,服务端记录的文件名为root/file,于是下载时也要给文件名root/file,而不能是file。最终,文件会被下载到~/root目录下,成为~/root/file。可以使用额外的命令参数来决定下载位置,详情参考swift --help。上述测试一切正常,表明Swift客户端测试通过。 4. 参考链接4.1 官方连接 Instructions for a Multiple Server Swift Installation (Ubuntu) http://docs.openstack.org/developer/swift/howto_installmultinode.html SAIO - Swift All In One http://docs.openstack.org/developer/swift/development_saio.html Swift 1.8.0-dev documentation -> Deployment Guide http://docs.openstack.org/developer/swift/deployment_guide.html4.2 非官方链接 OpenStack Hands on lab 2: Swift安装并使用Keystone做身份验证 http://liangbo.me/index.php/2012/03/29/openstack-hands-on-lab-2-swift-installation-with-keystone/ OpenStack Swift Install Multi Node http://blog.csdn.net/zzcase/article/details/6578520 Swift部署和动态扩展 http://www.kissthink.com/archive/4175.html Swift简介(实为深入讲解) http://www.cnblogs.com/Bob-FD/archive/2012/07/25/2608413.html 在Ubuntu上安装OpenStack Swift组件 http://blog.csdn.net/zoushidexing/article/details/7860226 标签: OpenStack, Swift, 云存储 好文要顶 关注我 收藏该文