码迷,mamicode.com
首页 > 其他好文 > 详细

openstack swift 源码分析之swift单机部署

时间:2014-05-10 10:15:44      阅读:703      评论:0      收藏:0      [点我收藏+]

标签:swift   部署   

本文对在单机部署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) 中具体找到。关于配置文件中每一个选项的意义可以到官方部署指导具体查看

bubuko.com,布布扣bubuko.com,布布扣

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地址和端口号,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 bubuko.com,布布扣https://auth.api.rackspacecloud.com/v1.0 -U user -K api_key stat -v

  swift --os-auth-url bubuko.com,布布扣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 bubuko.com,布布扣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: bubuko.com,布布扣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" bubuko.com,布布扣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 bubuko.com,布布扣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做使用做测试











openstack swift 源码分析之swift单机部署,布布扣,bubuko.com

openstack swift 源码分析之swift单机部署

标签:swift   部署   

原文地址:http://blog.csdn.net/xianghonglee/article/details/24962723

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!