zz:OpenStack Swift All In One安裝部署流程與簡單使用

https://www.cnblogs.com/fczjuever/archive/2013/05/11/3073151.htmlhtml

首先要感謝liu大神的翻譯與試驗,http://www.cnblogs.com/yuki-lau/node


 簡介python

  本文詳細描述使用單臺服務器部署一個Swift開發版本的過程,單臺服務器運行全部Swift服務,並模擬運行具備4個結點的Swift集羣。其中,這裏的「服務器」能夠是物理機也能夠是虛擬機。linux

  已驗證的部署環境:git

  • VMWare 7.1.2     Ubuntu-11.10-desktop-32位
  • PC物理機           Ubuntu-11.10-desktop-64位
  • PC物理機           Ubuntu-12.04-desktop-64位

版本說明

  本文檔基於:github

  請確保安裝的Swift版本和本文檔中的版本相同。若有問題,請參考官網的更新文檔。sql


1. 安裝依賴包和核心代碼json

1. 以root身份登陸。swift

# sudo su - rootapi

 

2. 安裝必須的依賴包、庫。

# 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用戶和組。在此,咱們直接使用root做爲用戶名和組名。

  接下來,須要選擇使用一個分區做爲存儲(Using a partition for storage)或使用一個迴環設備做爲存儲(Using a loopback device for storage),本文檔使用迴環設備做爲存儲。若但願使用一個單獨的分區做爲存儲,請參閱這裏

 


 

2. 使用迴環設備做爲存儲

1. 建立存儲文件夾。

# mkdir /srv

 

2. 調整seek的值,能夠建立一個更大或更小的分區。

# dd if=/dev/zero of=/srv/swift-disk bs=1024 count=0 seek=1000000

# mkfs.xfs -i size=1024 /srv/swift-disk

 

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. 建立4個子節點文件夾。

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

 

6. 改變權限,root:root對應<your-user-name>:<your-group-name>。

# chown root:root /mnt/sdb1/*

 

7. 爲4個子節點建立同步連接。

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

 

8. 建立server等文件夾,並改編權限。注意,不要忘記/etc/swift /srv/[1-4]/最後一個「/」。

# 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

 


 

3. 設置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/swift

 

5. 重啓rsyslog服務。

# service rsyslog restart

 


 

5. 獲取代碼並設置測試環境

  若不打算在全root權限下安裝Swift,則須要切換回guest權限。此處,咱們所有使用root安裝。

1. 建立文件夾。

# mkdir ~/bin

 

2. 從git上獲取swift代碼,下載到本地。

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

 

3. 安裝Swift的開發版本。

# cd ~/swift

# python setup.py develop

# cd ..

 

4. 從git上獲取python-swiftclient代碼,下載到本地。

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

 

5. 安裝python-swiftclient的開發版本。

# cd ~/python-swiftclient

# python setup.py develop

# cd ..

 

6. 編輯文件~/.bashrc,並在文件尾添加以下內容:

export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf

export PATH=${PATH}:~/bin

 

7. 執行。

# . ~/.bashrc

 


 

6. 配置結點

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,內容以下。注意,若是使用的是單獨分區存儲須要將/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,內容以下:

#!/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 1

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

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

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

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 1

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

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

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

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 1

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

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

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

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)。

# cd ~/swift

# ./.unittests

 

8. 運行swift,出現「Unable to increase file descriptor limit.  Running as non-root?」警告爲正常現象,沒必要理會。

# startmain

 


 

8. 簡單使用

  完成安裝部署後,可使用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.

 

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

* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)

> GET /auth/v1.0 HTTP/1.1

> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15

> 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-Storage-Token: AUTH_tk6474e5ee0cb04832b9d2a168e1a164d8

< X-Auth-Token: AUTH_tk6474e5ee0cb04832b9d2a168e1a164d8

< Content-Length: 0

< Date: Mon, 04 Jul 2011 01:36:57 GMT

* Connection #0 to host 127.0.0.1 left intact

*Closing connection #0

 

2. 檢查帳戶。注意,X-Auth-Token:與<token-from-x-auth-token-above>之間存在一個空格,必定不能丟。

# curl -v -H 'X-Auth-Token: <token-from-x-auth-token-above>'  <url-from-x-storage-url-above>

 

3. 檢查Swift工做。

# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat

   正確狀況下,應該輸出如下信息:

Account: AUTH_test

Containers: 0

Objects: 0

Bytes: 0

Accept-Ranges: bytes

 

4. 建立container,建立一個名稱爲container_test的container(目錄),注意使用當前的token。

# curl -X PUT -D -  -H "X-Auth_Token:AUTH_tk6474e5ee0cb04832b9d2a168e1a164d8" http://127.0.0.1:8080/v1/AUTH_test/container_test

   正確狀況下,應該獲得如下信息:

HTTP/1.1 201 Created

Content-Length: 0

Content-Type: text/html; charset=UTF-8

Date: Mon, 04 Jul 2011 01:39:38 GMT

 

5. 查看test用戶的container列表,發現只有一個目錄:container_test。

# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing list

container_test

 

6. 上傳Object(文件),上傳hello文件到container_test目錄中。

# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing upload container_test /root/hello

root/hello

 

7. 查看目錄中的內容,查看container_test目錄中的內容。

# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing list container_test

root/hello

 

8. 下載Object(文件)下載container_test下的object。

# swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing download  container_test

   將container_test目錄內的全部內容下載到目前所在目錄。注意:若是上傳文件的時候,有嵌套目錄,則上傳到Swift上後,也是以嵌套目錄的形式存在,下載後,會在當前目錄建立同樣的嵌套目錄。


 補充說明:

  如今已經完成SAIO的部署了,下面介紹一下系統環境的改變:

  1. ~/swift目錄下存放Swift與python-swiftclient的源代碼與執行腳本。

  • ~/swift/bin目錄下存放執行腳本。
  • ~/swift/swift_1.7.6目錄下存放Swift的源代碼。
  • ~/swift/python-swiftclient_1.2.0目錄下存放Swift客戶端的源代碼。

  2. /usr/local/lib/python2.7/dist-packages、/usr/share/pyshared、/usr/bin、/usr/local/bin等目錄下存放Swift與python-swiftclient安裝後的程序文件。

  3. Swift的迴環設備掛載在/mnt/sdb1目錄上。

  4. 迴環設備對應的文件爲/srv/swift-disk。

  5. 四個存儲節點對應的實際存儲空間(即共享上述迴環設備)——/mnt/sdb1/一、/mnt/sdb1/二、/mnt/sdb1/三、/mnt/sdb1/4。

  6. 四個存儲節點指向實際存儲空間的軟連接——/srv/一、/srv/二、/srv/三、/srv/4。

  7. 四個存儲節點的對應的虛擬掛載點——/srv/1/node/sdb一、/srv/2/node/sdb二、/srv/2/node/sdb二、/srv/2/node/sdb2。

  8. Swift運行時所需目錄/var/run/swift,用於存放各個服務進程的pid文件等內容。

  9. Swift臨時緩存的目錄(姑且這麼理解)——/var/cache/swift、/var/cache/swift二、/var/cache/swift三、/var/cache/swift4。

  10. /etc/swift目錄中存放Swift自身的配置文件。

  • /etc/swift/object-server目錄中存放四個存儲節點的Object Server配置文件。
  • /etc/swift/container-server目錄中存放四個存儲節點的Container Server配置文件。
  • /etc/swift/account-server目錄中存放四個存儲節點的Account Server配置文件。
  • /etc/swift/proxy-server.conf爲Proxy Server的配置文件。
  • /etc/swift/swift.conf爲Swift哈希後綴的配置文件。
  • backups目錄、*.builder文件和*.ring.rz文件都是Ring的相關文件,其中*.ring.rz文件記錄了生成的Ring。
  • test.conf文件是Swift單元測試所需的文件。

  11. /var/log/swift目錄下存放rsyslog獨立日誌工具輸出的日誌文件。

  12. 其餘被建立的文件:

  • /etc/rsyncd.conf,做爲rsync數據鏡像備份工具的配置文件。
  • /etc/rsyslog.d/10-swift.conf,做爲rsyslog獨立日誌工具的配置文件。

  13. 其餘被修改的文件:

  • /etc/fstab,迴環設備掛載相關配置文件。
  • /etc/rc.local,使得系統在啓動時自動建立一些Swift所需的目錄,這些目錄可能在系統關閉後丟失。
  • /etc/default/rsync,使rsync能開機啓動。
  • /etc/rsyslog.conf,改變rsyslog工具所在的Group。
  • ~/.bashrc,使新增的環境變量生效。
相關文章
相關標籤/搜索