openstack_swift源代碼分析——Swift單機部署

本文對在單機部署swift 當中每一個細節作具體的介紹,並對配置作對應的解釋html

PC物理機    Ubuntu-12.04-desktop-64位node

Swift 版本號:1.13.1python

Swift-client   1.2.0linux

注意:本文所有操做都是在root權限下進行的。git

1 、下載swift 和swift-client 源碼,本文利用git從github獲取其源碼

     獲取swift源碼github

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

     獲取python版swift-client源碼json

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

2 、安裝依賴包

   利用pythoncharm 或者 裝有pydev插件的eclipse打開下載的swift源碼,在swift-master下 requirements.txt中列出了需要安裝的依賴包。並列出了其版本 swift

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

三、安裝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

二、在帳戶下建立一個名爲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作使用作測試

相關文章
相關標籤/搜索