OpenStack之Swift操作指南

來源:互聯網
上載者:User
swift-ring-builder account.builder create 18 3 1
swift-ring-builder container.builder create 18 3 1
swift-ring-builder object.builder create 18 3 1


swift-ring-builder account.builder add z1-127.0.0.1:6002/sda1 100
swift-ring-builder container.builder add z1-127.0.0.1:6001/sda1 100
swift-ring-builder object.builder add z1-127.0.0.1:6000/sda1 100


swift-ring-builder account.builder
swift-ring-builder container.builder
swift-ring-builder object.builder


swift-ring-builder account.builder rebalance
swift-ring-builder container.builder rebalance
swift-ring-builder object.builder rebalance


swift-ring-builder account.builder search z1
swift-ring-builder account.builder set_min_part_hours 2
swift-ring-builder account.builder remove :6012
swift-ring-builder account.builder set_info :6022 10.28.1.216:6022/sdb2_account2
驗證配置
swauth-prep -K swauthkey -A https://localhost:8089/auth/
添加使用者
swauth-add-user -K swauthkey -A https://localhost:8089/auth/ -a system root testpass
swauth-list -K swauthkey -A https://localhost:8089/auth/
查詢某個賬戶下的資訊:
swauth-list -K swauthkey -A https://localhost:8089/auth/ system
查看某個賬戶下的某個使用者的資訊
swauth-list -K swauthkey -A https://10.28.1.97:8089/auth/ system root
swauth-delete-user -K swauthkey -A https://localhost:8089/auth/ system root


swauth-delete-account -K swauthkey -A https://localhost:8089/auth/ sys
curl -k -v -H 'X-Storage-User: buy360:root' -H 'X-Storage-Pass: testpass' https://localhost:8089/auth/v1.0
swauth-add-account -K swauthkey -A https://localhost:8089/auth/ system
/var/log/messages
/etc/init.d/memcached
dd if=/dev/zero  of=/srv/swift-disk bs=1G count=20
mkfs.xfs /srv/swift-disk(檔案系統必須是xfs)
echo "mount /srv/swift-disk /mnt/sdb1 -o loop" >> /etc/rc.local
掛載 mount /srv/swift-disk /mnt/sdb1 -o loop 
啟動同步服務 /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
將同步命令加入開機啟動 echo "/usr/bin/rsync --daemon  --config=/etc/rsyncd.conf" >> /etc/rc.local




擷取X-Storage-Url和X-Auth-Token
curl -k -v -H 'X-Storage-User: system:root' -H 'X-Storage-Pass: testpass' https://localhost:443/auth/v1.0
驗證X-Auth-Token
curl -k -v -H 'X-Auth-Token: AUTH_tk8f5cbb6c6f3d41d98172c10fc59ad1d3'  https://10.28.1.216:8089/v1/AUTH_aa002b51-24e5-4385-806f-1087ec9c2fa8






. 檢測 swift 命令是否工作正常 (輸出應為 zero containers, zero objects, 和 zero bytes):
swift  -A https://localhost:8089/auth/v1.0  -U system:root -K testpass stat
 Account: AUTH_cfc10b95-6033-4fd2-b4c5-c6a7c73a4478
Containers: 0
   Objects: 0
     Bytes: 0
Accept-Ranges: bytes
查看賬戶相關資訊
swift  -A https://localhost:8089/auth/v1.0  -U system:root -K testpass stat -v
StorageURL: https://localhost:8089/v1/AUTH_cfc10b95-6033-4fd2-b4c5-c6a7c73a4478
Auth Token: AUTH_tk70a2e31982bb4a68881d563a19da6883
   Account: AUTH_cfc10b95-6033-4fd2-b4c5-c6a7c73a4478
Containers: 2
   Objects: 38
     Bytes: 12562615
Accept-Ranges: bytes


上傳檔案到myfiles容器中:
swift  -A https://localhost:8089/auth/v1.0  -U buy360:root -K testpass upload myfiles 123.txt
建立容器:
swift  -A https://localhost:8089/auth/v1.0  -U buy360:root -K testpass post myfiles
 下載myfiles容器中的所有檔案
swift  -A https://10.28.1.97:8089/auth/v1.0  -U buy360:root -K testpass download myfiles *
下載某個賬戶下面的所有內容
swift  -A https://localhost:8089/auth/v1.0  -U system:root -K testpass  download --all
將對象下載到指定檔案
 swift  -A https://localhost:8089/auth/v1.0  -U system:root -K testpass  download myfiles swift.conf -o liu.test
列出所有容器
swift  -A https://localhost:8089/auth/v1.0  -U buy360:root -K testpass list
列出首碼為my的容器
swift  -A https://localhost:8089/auth/v1.0   -U buy360:root -K testpass list -p my
查看容器myfiles中的對象
swift  -A https://localhost:8089/auth/v1.0  -U buy360:root -K testpass list myfiles
將對象分段上傳
swift  -A https://localhost:443/auth/v1.0  -U system:root -K testpass upload largeobject -S 1024000 account.builder 




定位賬戶,容器,Object Storage Service的位置:swift-get-nodes










必須將檔案夾組跟使用者佈建為swift,不然報錯
chown swift:swift /mnt/sdb1/*
當試著上傳一個大於5G的對象,就會報錯
-bash-4.1# swift  -A https://localhost:8089/auth/v1.0  -U system:root -K testpass upload largeobject /tmp/swiftdev1
Object PUT failed: https://10.28.1.216:8089/v1/AUTH_72d3e323-b8e3-47ce-af21-95e96690436b/largeobject//tmp/swiftdev1 413 Request Entity Too Large
swauth-prep -K swauthkey -A https://localhost:8089/auth/


swift Could not create the main auth account:將代碼重新安裝一次


sqlite資料庫
.h on 查詢的時候顯示表欄位


查詢當前資料庫的表結構
 select * from sqlite_master WHERE type = "table"; 








glance add name="test-1" is_public=true < /home/images/euca-centos-5.3-x86_64.tar.gz 
/usr/bin/glance-control api restart




swift設計上的缺點:
1)上傳的時候,不應該多分上傳,而是應該上傳一份,然後讓它自己複製多分
2)每次加入一個節點,進行rebalance的操作的時候,會重新進行分區號的分配,可能會涉及到大量對象的移動
/usr/bin/glance-control registry restart

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.