OpenStack Swift集羣部署流程與簡單使用

以前介紹了《OpenStack Swift All In One安裝部署流程與簡單使用》,那麼接下來就說一說Swift集羣部署吧。php

1. 簡介html

  本文檔詳細描述了使用兩臺PC部署一個小型Swift集羣的過程,並給出一些簡單的使用實例。本文檔假定以下前提條件:node

  1. 使用Ubuntu操做系統。
  2. 每臺機器都運行Swift的全部服務,既是Proxy Server,又是Storage Server,用戶能夠向任何一臺機器發起存儲服務請求。
  3. 採用Swift自帶的TempAuth做爲用戶的身份與權限認證。
  4. 全部機器構成memcached集羣來提供Token緩存服務。
  5. 全部操做均在root用戶下進行,並使用root做爲Swift的用戶和組。
  6. 全部機器都運行在局域網中。
  7. 使用迴環設備和XFS文件系統做爲Swift底層存儲。

  閱讀本文檔前,能夠先閱讀文檔《Swift All In One安裝部署流程》,學習Swift單機部署的相關知識。python

 2. 安裝部署linux

2.1 準備環境nginx

 

PC 1git

PC 2github

機器類型:sql

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 版本說明

  本文檔基於:

  1. 官方文檔:Swift 1.7.7-dev documentation -> Instructions for a Multiple Server Swift Installation (Ubuntu)
  2. Swift版本:1.7.6
  3. python-swiftclient版本:1.2.0

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

2.3 安裝軟件環境

  首先,PC1PC2安裝Swift所需的軟件環境(確保你的機器能夠訪問互聯網),例如,sqlite3做爲本地數據庫,memcached做爲Token緩存。Ubuntu-12.04已自帶rsync工具,所以不用另行安裝。

  • 第一條命令:if=/dev/zero表示空輸入,即自動填充0;of=/srv/swift-disk表示輸出到指定文件;bs=1024表示同時設置讀入/輸出的塊大小(字節),即每次讀入/輸出1024字節的數據塊;count=0表示拷貝0個塊,塊大小由bs指定;seek=50000000從輸出文件開頭跳過50000000個塊後再開始複製。第一條命令的結果是建立了一個50000000*1024字節大小的文件(約50GB,未自動填充0),爲建立迴環設備作準備。
  • 第二條命令:.xfs表示建立的是XFS格式的迴環設備;-i size=1024,當數據小於1024KB時,寫入inode中,當數據大於1024KB時,寫入block中,默認值爲256KB;還能夠考慮設置-l size=128m,可顯著提高XFS文件系統刪除文件、拷貝文件等操做的速度,但須要大內存的支持,默認值的是10m。第二條命令的結果是在上述文件的基礎上建立了XFS迴環設備。
  • Instructions for a Multiple Server Swift Installation (Ubuntu)
  • SAIO - Swift All In One
  • Swift 1.8.0-dev documentation -> Deployment Guide
  • OpenStack Hands on lab 2: Swift安裝並使用Keystone作身份驗證
  • OpenStack Swift Install Multi Node
  • Swift部署和動態擴展
  • Swift簡介(實爲深刻講解)
  • 在Ubuntu上安裝OpenStack Swift組件
  • 好文要頂 關注我 收藏該文
     
     
    0
    0
     
     
    16) 編輯 收藏 2.4 安裝Swift   在PC1和PC2上執行如下操做,安裝Swift服務:  1. 在主目錄(root用戶)下建立swift目錄。而後在該下建立bin目錄,用於存放咱們手動建立的Swift相關腳本文件。進入~/swift目錄,而後從git上獲取Swift和python-swiftclient源代碼,下載到本地。固然也可使用之前下載的1.7.6版本的Swift代碼和1.2.0版本的python-swiftclient代碼,將代碼目錄放至~/swift目錄下便可。    3. 而後使用上述代碼以開發的方式安裝Swift和python-swiftclient(假設Swift的代碼目錄爲~/swift/swift_1.7.6,python-swiftclient的代碼目錄爲~/swift/python-swiftclient_1.2.0)。最終,二者都會被安裝到python的dist-packages中。安裝過程當中,會自動檢查其所需的依賴項,並自動進行下載安裝。文件~/swift/swift_1.7.6/tools/pip-requires中(內容以下所示)記錄了Swift所需的依賴項,setup.py就是根據該文件來檢查依賴項的。    5. 相似的,文件~/swift/python-swiftclient_1.2.0/tools/pip-requires中(內容以下所示)記錄了python-swiftclient所需的依賴項。修改~/.bashrc文件,在文件尾部添加以下內容:(該文件包含當前用戶Bash Shell的環境變量信息,用以標明Swift測試配置文件路徑和啓動程序路徑)  /var/run/swift目錄在操做系統關閉後會消失,所以須要在操做系統再次啓動時進行建立。咱們能夠編輯/etc/rc.local文件,在exit 0 以前添加以下內容來實現該目錄的自動建立。  2.5 配置Storage Server2.5.1 配置存儲空間  Swift可以運行在任何支持擴展屬性的現代文件系統之上,Swift官方推薦用戶使用XFS文件系統。通過官方的驗證,認爲XFS文件系統能爲Swift的用例提供最佳的性能,而且經過了完整的穩定性測試。  對於任何一臺PC,咱們能夠選擇使用一個分區做爲存儲(Using a partition for storage),也可使用一個迴環設備做爲存儲(Using a loopback device for storage)。因爲實驗環境所限,本文檔使用迴環設備做爲存儲。若但願使用獨立分區做爲存儲,請參考官方文檔。咱們須要在每一臺PC上建立迴環設備,做爲每個Swift節點的數據存儲空間。在PC1和PC2上執行如下操做:  1. 選擇一個位置建立存儲文件夾。在存儲文件夾中建立XFS格式的迴環設備,即/srv/swift-disk文件。    4. 建立迴環設備掛載點文件夾,並執行掛載。改變掛載點文件夾的權限。  2.5.2 配置Swift  在PC1和PC2上建立Swift的配置文件目錄。   在PC1中建立配置文件/etc/swift/swift.conf,編輯其內容(以下所示),而後複製到PC2中的/etc/swift目錄下。該文件記錄了Swift使用的哈希後綴,用於一致性哈希計算。集羣中的每一個節點都必須保存該文件,而且徹底相同。 2.5.3 配置rsync  rsync是類Unix系統下的數據鏡像備份工具。Swift對象副本的複製更新是基於推送模式的。對象的複製更新使用rsync將文件同步到對等節點,Account和Container的複製更新則經過HTTP或rsync來推送數據庫文件上丟失的記錄。在PC1和PC2上建立rsync的配置文件/etc/rsyncd.conf,添加以下內容:(下面以PC1爲例,其中的address是PC1上rsync服務端監聽的IP地址,等待客戶端推送複製更新,這裏一樣推薦設置爲內網地址)   爲了使rsync可以開機啓動,須要在PC1和PC2上編輯配置文件/etc/default/rsync,將參數RSYNC_ENABLE設置爲true,而後啓動rsync服務。 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表示日誌標籤,與獨立日誌的配置有關)   2. 配置container存儲服務,建立配置文件/etc/swift/container-server.conf,並添加如下內容:   3. 配置object存儲服務,建立配置文件/etc/swift/object-server.conf,並添加如下內容: 2.5.5 配置獨立日誌(可選)  Swift默認將日誌信息輸出到文件/var/log/syslog中。若是要按照我的需求設置rsyslog,生成特有的Swift日誌文件,則須要在PC1和PC2上執行如下操做,完成獨立日誌的配置。  1. 建立日誌配置文件/etc/rsyslog.d/10-swift.conf,編輯內容以下:(增長account、container、object的日誌配置信息)   2. 編輯文件/etc/rsyslog.conf,更改參數$PrivDropToGroup爲adm。2.6.3 配置proxy-server   在PC1和PC2上建立proxy-server配置文件/etc/swift/proxy-server.conf,添加如下內容:   配置參數中: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的日誌配置信息:   2. 重啓rsyslog服務Ring共有三種,分別爲Account Ring、Container Ring、Object Ring。Ring須要在整個集羣中保持徹底相同,所以須要在某一臺PC上建立Ring文件,而後複製到其餘PC上。咱們將在PC1上進行Ring的建立,而後複製到PC2上。       首先,使用以下命令建立三個Ring。其中,18表示Ring的分區數爲218;2表示對象副本數爲2;1表示分區數據的遷移時間爲1小時(這個解釋有待證明)。   而後向三個Ring中添加存儲設備。其中z1和z2表示zone1和zone2;sdb1爲Swift使用的存儲空間,即上文掛在的迴環設備;100表明設備的權重。   Ring文件建立完畢後,能夠經過如下命令來查看剛纔添加的信息,以驗證是否輸入正確。若發現錯誤,以Account Ring爲例,可使用swift-ring-builder account.builder的刪除方法刪除已添加的設備,而後從新添加。2.7 建立Swift執行腳本 爲便於操做,咱們能夠在PC1和PC2上建立如下Swift腳本。  1. 建立~/swift/bin/remakerings腳本文件,添加如下內容,便可一鍵完成Ring的從新建立,固然具體內容須要根據實際環境進行修改。   2. 建立~/swift/bin/resetswift腳本文件,添加如下內容,便可一鍵清空Swift的對象數據和日誌,完成重置。注意:若是使用的是獨立分區存儲,則須要另行處理,例如將/srv/swift-disk替換爲/dev/sdb1等;若是沒有使用rsyslog做爲獨立日誌,則須要去掉「find /var/log/swift... 」和「sudo service rsyslog restart」這兩行。   3. 建立~/swift/bin/startmain腳本文件,添加如下內容,便可一鍵啓動Swift的基本服務,包括proxy-server、account-server、container-server和object-server。   4. 建立~/swift/bin/stopmain腳本文件,添加如下內容,便可一鍵關閉Swift的基本服務,包括proxy-server、account-server、container-server和object-server。   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。   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。   7. 完成腳本建立後,須要更改腳本權限,使之可以執行。 2.8 啓動與關閉Swift服務  因爲咱們是以開發的方式安裝Swift的,因此可以執行功能單元測試。若提示「Unable to read test config /etc/swift/test.conf – file not found」,可沒必要理會,或手動將配置文件~/swift/swift_1.7.6/test/sample.conf複製過去。   咱們須要在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?」警告爲正常現象,沒必要理會。   一樣的,咱們可使用~/swift/bin/stopmain腳本文件關閉Swift的基本服務;使用~/swift/bin/stopall腳本文件鍵關閉Swift的全部服務。 2.9 查看Swift幫助信息  完成安裝部署後,可使用swift --help命令查看Swift幫助信息。 3. 使用實例  啓動PC1和PC2上的Swift服務後,咱們交替地在PC1和PC2上執行操做,並隨機使用二者提供的storage-url,若是用戶驗證和存儲服務所有正確,則代表Swift集羣部署成功。3.1 用curl測試  咱們先使用curl測試幾個簡單的命令。  1. 在PC1上訪問192.168.3.52,進行tester用戶驗證,獲取Token和storage-url。   2. 在PC1上訪問192.168.3.52,查看test帳戶的狀態信息。   3. 在PC1上訪問192.168.3.53,查看test帳戶的狀態信息。   4. 在PC2上訪問192.168.3.52,查看test帳戶的狀態信息。    上述測試一切正常,代表curl測試經過。3.2 用Swift客戶端測試  接着,咱們使用Swift客戶端進行測試。  1. 在PC1上訪問192.168.3.53,查看test帳戶的狀態信息。    2. 在PC1上訪問192.168.3.52,在test帳戶下建立名爲myfiles的container。    3. 在PC1上訪問192.168.3.53,顯示test帳戶下的container列表。    4. 在PC2上訪問192.168.3.52,顯示test帳戶下的container列表。    5. 在PC2上訪問192.168.3.53,在剛纔建立的container下上傳文件。上傳完成後,Swift服務端會以完整路徑做爲文件名。    6. 在PC1上訪問192.168.3.52,顯示剛纔建立的container下的文件列表。    7. 在PC1上訪問192.168.3.52,下載剛纔上傳的文件。給定的文件名必須是其完整路徑,例如上傳的文件爲~/file,服務端記錄的文件名爲root/file,因而下載時也要給文件名root/file,而不能是file。最終,文件會被下載到~/root目錄下,成爲~/root/file。可使用額外的命令參數來決定下載位置,詳情參考swift --help。上述測試一切正常,代表Swift客戶端測試經過。 4. 參考連接4.1 官方鏈接     http://docs.openstack.org/developer/swift/howto_installmultinode.html     http://docs.openstack.org/developer/swift/development_saio.html     http://docs.openstack.org/developer/swift/deployment_guide.html4.2 非官方連接     http://liangbo.me/index.php/2012/03/29/openstack-hands-on-lab-2-swift-installation-with-keystone/     http://blog.csdn.net/zzcase/article/details/6578520     http://www.kissthink.com/archive/4175.html     http://www.cnblogs.com/Bob-FD/archive/2012/07/25/2608413.html     http://blog.csdn.net/zoushidexing/article/details/7860226   標籤: OpenStack, Swift, 雲存儲  « 上一篇:OpenStack Swift All In One安裝部署流程與簡單使用» 下一篇:OpenStack Keystone安裝部署流程 posted @ 2013-07-29 22:52 最初的幸福ever 閱讀(7246) 評論(   評論列表

    # 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

    # chown -R root:root /srv/node

    # mkdir -p /etc/swift

    # chown -R root:root /etc/swift/

    [swift-hash]

    # random unique string that can never change (DO NOT LOSE)

    swift_hash_path_suffix = jtangfs

    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

    # perl -pi -e 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync

    # service rsync restart

    [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]

    [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]

    [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]

    # 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.*                ~

    [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

    # 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.*                ~

    # 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

    # 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

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

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

    #!/bin/bash

     

    swift-init main start

    #!/bin/bash

     

    swift-init main stop

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

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

    # chmod +x ~/swift/bin/*

    # cd ~/swift/swift_1.7.6

    # ./.unittests

    # startmain

    # startall

    # stopmain

    # stopall

    # 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.

    # 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

    # 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

    # 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

    # 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

    # 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

    # swift -A http://192.168.3.52:8080/auth/v1.0 -U test:tester -K testing post myfiles

     

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

    myfiles

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

    myfiles

    # swift -A http://192.168.3.53:8080/auth/v1.0 -U test:tester -K testing upload myfiles ~/file

    root/file

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

    root/file

    相關文章
    相關標籤/搜索