openstack_swift源代码分析——Swift单机部署

时间:2024-03-10 08:54:58

本文对在单机部署swift 当中每个细节做具体的介绍,并对配置做对应的解释

PC物理机    Ubuntu-12.04-desktop-64位

Swift 版本号:1.13.1

Swift-client   1.2.0

注意:本文全部操作都是在root权限下进行的。

1 、下载swift 和swift-client 源码,本文利用git从github获取其源码

     获取swift源码

     git clone https://github.com/openstack/swift.git

     获取python版swift-client源码

     git clone https://github.com/openstack/python-swiftclient.git

2 、安装依赖包

   利用pythoncharm 或者 装有pydev插件的eclipse打开下载的swift源码,在swift-master下 requirements.txt中列出了须要安装的依赖包。并列出了其版本 

dnspython>=1.9.4
eventlet>=0.9.15
greenlet>=0.3.1
netifaces>=0.5
pastedeploy>=1.3.3
simplejson>=2.0.9
xattr>=0.4

安装相关依赖包(swift 和swift-client),另 ubuntu12.04自带了rsync 不须要另行安装

# apt-get install python-software-properties
# add-apt-repository ppa:swift-core/release
# apt-get update
# apt-get install curl gcc git-core memcached python-coverage python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3 xfsprogs python-eventlet python-greenlet python-pastedeploy python-netifaces python-pip
# pip install mock

3、安装swift 和swift-client

1 在root根文件夹下创建文件夹

mkdir ~/bin

2 进例如以下载的swift 文件夹中

cd ~/swift

3 执行setup.py 文件

python setup.py develop

此过程会检查之前安装的依赖包的正确性 并会将swift-master/bin 下的一些swift启动文件的命令增加到/usr/local/bin下。我们在使用swift命令时就说通过/usr/local/bin下的命令然后再映射到详细的swift-master/bin 下的详细文件里的。

4 进入下载的swift-client文件夹下

# cd ~/python-swiftclient

5 运行安装

# python setup.py develop

6  编辑文件~/.bashrc,并在文件尾加入例如以下内容:

export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf


export PATH=${PATH}:~/bin

7 运行

# . ~/.bashrc

创建/var/run/swift文件夹,并改动其权限。

该文件夹是Swift执行时所需的。用于存放各个服务进程的pid文件等内容。

# mkdir -p /var/run/swift


# chown root:root /var/run/swift

9. /var/run/swift文件夹在操作系统关闭后会消失,因此须要在操作系统再次启动时进行创建。我们能够编辑/etc/rc.local文件,在exit 0 之前加入例如以下内容来实现该文件夹的自己主动创建

mkdir -p /var/run/swift


chown root:root /var/run/swif  

4 、使用回环设备作为存储

1 创建存储目录

# mkdir /srv

在存储目录中创建XFS格式的回环设备。即/srv/swift-disk文件。

# dd if=/dev/zero of=/srv/swift-disk bs=1024 count=0 seek=20000000
# mkfs.xfs -f -i size=1024 /srv/swift-disk

如上命令 第一条 if=/dev/zero 表示空输入。of=/srv/swift-disk 表示输出到指定文件;bs=1024 表示输入输出的块大小(Byte)。count=0表示拷贝0个块,块大小由bs指定;seek=20000000从输出文件开头跳过20000000个块后再開始复制。

也就是创建一个20G的文件。为创建回环设备做准备。

第二条命令 xfs表示创建的是XFS格式的回环设备。-i size=1024。当数据小于1024KB时。写入inode中,当数据大于1024KB时,写入block中,默认值为256KB;还能够考虑设置-l size=128m,可显著提升XFS文件系统删除文件、复制文件等操作的速度。但须要大内存的支持,默认值的是10m。第二条命令的结果是在上述文件的基础上创建了XFS回环设备。

3 在文件 /etc/fstab尾部增加例如以下内容:

/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0

4. 创建回环设备挂载点目录,并运行挂载。

# mkdir /mnt/sdb1
# mount /mnt/sdb1

5 创建四个子节点目录

# mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4

6. 改变挂载点目录的权限

# chown root:root /mnt/sdb1/*

7 为4个子节点创建同步链接

# for x in {1..4}; do ln -s /mnt/sdb1/$x /srv/$x; done

8 创建server 等文件并改变权限 

# mkdir -p /etc/swift/object-server /etc/swift/container-server /etc/swift/account-server /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4 /var/run/swift
# chown -R root:root /etc/swift /srv/[1-4]/ /var/run/swift

9. 编辑文件/etc/rc.local,在exit 0 之前加入例如以下4行

# mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4
# chown root:root /var/cache/swift*
# mkdir -p /var/run/swift
# chown root:root /var/run/swift

5 设置Rsync

1 创建文件/etc/rsyncd.conf,内容例如以下

uid = root
gid = root
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1

[account6012]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/account6012.lock

[account6022]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/account6022.lock

[account6032]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/account6032.lock

[account6042]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/account6042.lock

[container6011]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/container6011.lock

[container6021]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/container6021.lock

[container6031]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/container6031.lock

[container6041]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/container6041.lock

[object6010]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/object6010.lock

[object6020]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/object6020.lock

[object6030]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/object6030.lock

[object6040]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/object6040.lock

2. 编辑文件/etc/default/rsync。设置參数RSYNC_ENABLE为true。

RSYNC_ENABLE=true

3. 启动rsync服务

# service rsync restart

4 设置独立日志

1 创建文件 /etc/rsyslog.d/10-swift.conf 内容例如以下

# 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/storage1.log
local2.notice           /var/log/swift/storage1.error
local2.*                ~


local3.*;local3.!notice /var/log/swift/storage2.log
local3.notice           /var/log/swift/storage2.error
local3.*                ~


local4.*;local4.!notice /var/log/swift/storage3.log
local4.notice           /var/log/swift/storage3.error
local4.*                ~


local5.*;local5.!notice /var/log/swift/storage4.log
local5.notice           /var/log/swift/storage4.error
local5.*                ~

2. 编辑文件/etc/rsyslog.conf,更改參数$PrivDropToGroup为adm

$PrivDropToGroup adm

3. 创建swift每小时的目录。

# mkdir -p /var/log/swift/hourly

4. 更改swift的log目录权限。

# chown -R syslog.adm /var/log/swift
# chmod -R g+w /var/log/swif

5. 重新启动rsyslog服务。

# service rsyslog restart

6 配置结点

这些配置信息的实例可在swift-master/doc/saio(swift all in one) 中详细找到。

关于配置文件里每个选项的意义能够到官方部署指导详细查看


1 创建文件/etc/swift/proxy-server.conf ,此文件为代理结点的配置歇息,内容例如以下

[DEFAULT]

bind_port = 8080
user = root
log_facility = LOG_LOCAL1
eventlet_debug = true
[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
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
[filter:proxy-logging]
use = egg:swift#proxy_logging

 2. 创建文件/etc/swift/swift.conf,文件内容例如以下:

[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = jtangfs

3. 创建文件/etc/swift/account-server/1.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6012
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]

[account-reaper]

4. 创建文件/etc/swift/account-server/2.conf,文件内容例如以下:

[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6022
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]

[account-reaper]

5. 创建文件/etc/swift/account-server/3.conf,文件内容例如以下:

[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6032
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true

[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]

[account-reaper]

6. 创建文件/etc/swift/account-server/4.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6042
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]

7. 创建文件/etc/swift/container-server/1.conf,文件内容例如以下:

[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6011
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]

8. 创建文件/etc/swift/container-server/2.conf,文件内容例如以下:

[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6021
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes

[container-updater]

[container-auditor]

[container-sync]

9. 创建文件/etc/swift/container-server/3.conf,文件内容例如以下:

[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6031
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]

10. 创建文件/etc/swift/container-server/4.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6041
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]

[container-sync]

11. 创建文件/etc/swift/object-server/1.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/1/node
mount_check = false

disable_fallocate = true
bind_port = 6010
user = root
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]

12. 创建文件/etc/swift/object-server/2.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6020
user = root
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]

vm_test_mode = yes

[object-updater]

[object-auditor]

13. 创建文件/etc/swift/object-server/3.conf。文件内容例如以下:

[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6030
user = root
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes

[object-updater]
[object-auditor]

14. 创建文件/etc/swift/object-server/4.conf,文件内容例如以下

[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6040
user = root
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]

7 创建swift执行脚本

1. 创建脚本~/bin/resetswift(bin文件夹为我们開始创建的bin文件夹),内容例如以下。注意,假设使用的是单独分区存储须要将/srv/swift-disk替换为/dev/sdb1;假设没有创建rsyslog作为独立日志,则须要移除find /var/log/swift... 这一行

#!/bin/bash

swift-init all stop
find /var/log/swift -type f -exec rm -f {} \;
sudo umount /mnt/sdb1
sudo mkfs.xfs -f -i size=1024 /srv/swift-disk
sudo mount /mnt/sdb1
sudo mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
sudo chown root:root /mnt/sdb1/*
mkdir -p /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4
sudo rm -f /var/log/debug /var/log/messages /var/log/rsyncd.log /var/log/syslog
find /var/cache/swift* -type f -name *.recon -exec rm -f {} \;
sudo service rsyslog restart
sudo service memcached restart

2. 创建脚本~/bin/remakerings,这个脚本的主要功能是创建三个ring。把设备加入到ring中,并reblance环,在创建3个ring时 18 表示 partion数目为 2**18。3为副本个数,1 表示数据的迁移时间。

#!/bin/bash


cd /etc/swift



rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz

swift-ring-builder object.builder create 18 3 1

swift-ring-builder object.builder add z1-127.0.0.1:6010/sdb1 100     #z1 表示 zone1 127.0.0.1:6010 为设备ip地址和port号,sdb1为设备的存储空间,100代表权重 这些都会调用swift-master/bin/swift-ring-builder 中的main方#法然后再代用swift-master/swift/cli/ringbuilder下的详细方法。

ring代码分析将在下一篇博客中详细介绍

swift-ring-builder object.builder add z2-127.0.0.1:6020/sdb2 100


swift-ring-builder object.builder add z3-127.0.0.1:6030/sdb3 100

swift-ring-builder object.builder add z4-127.0.0.1:6040/sdb4 100

swift-ring-builder object.builder rebalance

swift-ring-builder container.builder create 18 3 1

swift-ring-builder container.builder add z1-127.0.0.1:6011/sdb1 100

swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 100

swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 100

swift-ring-builder container.builder add z4-127.0.0.1:6041/sdb4 100

swift-ring-builder container.builder rebalance

swift-ring-builder account.builder create 18 3 1
swift-ring-builder account.builder add z1-127.0.0.1:6012/sdb1 100

swift-ring-builder account.builder add z2-127.0.0.1:6022/sdb2 100

swift-ring-builder account.builder add z3-127.0.0.1:6032/sdb3 100

swift-ring-builder account.builder add z4-127.0.0.1:6042/sdb4 100

swift-ring-builder account.builder rebalance

3 创建~bin/startmain

#!/bin/bash

swift-init main start 

4. 创建脚本~/bin/startrest

#!/bin/bash


swift-init rest start

5. 更改脚本权限。

# chmod +x ~/bin/*

6. 创建rings。

# remakerings


7. 执行功能单元測试,出现“Unable to read test config /etc/swift/test.conf – file not found”。可不必理会。或手动复制过去(配置文件在swift/test/sample.conf)。此过程会执行swift/test 下全部单元測试样例

# cd ~/swift
# ./.unittests

8. 执行swift。出现“Unable to increase file descriptor limit.  Running as non-root?”警告为正常现象,不必理会。

# startmain

8 測试安装

至此swift 单节点部署已经完毕,以下能够通过swift-client測试swift

root权限

输入 swift --help 会罗列出详细的命令介绍

 Usage: swift [--version] [--help] [--snet] [--verbose]
             [--debug] [--info] [--quiet] [--auth <auth_url>]
             [--auth-version <auth_version>] [--user <username>]
             [--key <api_key>] [--retries <num_retries>]
             [--os-username <auth-user-name>] [--os-password <auth-password>]
             [--os-tenant-id <auth-tenant-id>]
             [--os-tenant-name <auth-tenant-name>]
             [--os-auth-url <auth-url>] [--os-auth-token <auth-token>]
             [--os-storage-url <storage-url>] [--os-region-name <region-name>]
             [--os-service-type <service-type>]
             [--os-endpoint-type <endpoint-type>]
             [--os-cacert <ca-certificate>] [--insecure]
             [--no-ssl-compression]
             <subcommand> ...

Command-line interface to the OpenStack Swift API.

Positional arguments:
  <subcommand>
    delete               Delete a container or objects within a container.
    download             Download objects from containers.
    list                 Lists the containers for the account or the objects
                         for a container.
    post                 Updates meta information for the account, container,
                         or object; creates containers if not present.
    stat                 Displays information for the account, container,
                         or object.
    upload               Uploads files or directories to the given container
    capabilities         List cluster capabilities.


Examples:
  swift -A https://auth.api.rackspacecloud.com/v1.0 -U user -K api_key stat -v

  swift --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant \
      --os-username user --os-password password list

  swift --os-auth-token 6ee5eb33efad4e45ab46806eac010566 \
      --os-storage-url https://10.1.5.2:8080/v1/AUTH_ced809b6a4baea7aeab61a \
      list

  swift list --lh

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.
  --debug               Show the curl commands and results of all http queries
                        regardless of result status.
  --info                Show the curl commands and results  of all http
                        queries which return an error.
  -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.
  -R RETRIES, --retries=RETRIES
                        The number of times to retry a failed connection.
  --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]. Used
                        with --os-storage-url to bypass the usual
                        username/password authentication.
  --os-storage-url=<storage-url>
                        OpenStack storage URL. Defaults to
                        env[OS_STORAGE_URL]. Overrides the storage url
                        returned during auth. Will bypass authentication when
                        used with --os-auth-token.
  --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].
  --os-cacert=<ca-certificate>
                        Specify a CA bundle file to use in verifying a TLS
                        (https) server certificate. Defaults to
                        env[OS_CACERT].
  --insecure            Allow swiftclient to access servers without having to
                        verify the SSL certificate. Defaults to
                        env[SWIFTCLIENT_INSECURE] (set to \'true\' to enable).
  --no-ssl-compression  This option is deprecated and not used anymore. SSL
                        compression should be disabled by default by the
                        system SSL library.

1 首先获取X-Storage-Url 和 X-Auth-Token

# curl -v -H \'X-Storage-User: test:tester\' -H \'X-Storage-Pass: testing\' http://127.0.0.1:8080/auth/v1.0

响应结果为

 * About to connect() to 127.0.0.1 port 8080 (#0)
*   Trying 127.0.0.1... 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: 127.0.0.1:8080
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing

< HTTP/1.1 200 OK
< X-Storage-Url: http://127.0.0.1:8080/v1/AUTH_test
< X-Auth-Token: AUTH_tk3984540e8df1412895d7fbcaad096f78
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tk3984540e8df1412895d7fbcaad096f78
< X-Trans-Id: tx3e63bc74bbf44fc387e19-005365e658
< Content-Length: 0
< Date: Sun, 04 May 2014 07:03:52 GMT

* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0

2、在账户下创建一个名为my_toncainer的 container

 curl -X PUT -D - -H "X-Auth_Token:AUTH_tk3984540e8df1412895d7fbcaad096f78" http://127.0.0.1:8080/v1/AUTH_test/my_container
响应结果为:

 HTTP/1.1 201 Created
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx23e4f15a3adc4c9fbc0ec-005365e806
Date: Sun, 04 May 2014 07:11:09 GMT

3 在my_container中下上传文件。

 swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing upload my_container  /home/kinglion/books/MySQL2ndEdition.pdf 
响应结果

home/kinglion/books/MySQL2ndEdition.pdf

其它 curl命令 大家能够自己试着应用,当然大家也能够基于swift-client 做一些http请要求的命令,对swift做使用做測试