OpenStack Swift Deployment Workshop

  1. Get the presentation OpenStack Swift Install Workshop
  2. Download SwiftWorkshop VirtualBox Image (663MB)
  3. Download and Install VirtualBox

OpenStack Swift App Development Workshop

  1. Get the App development presentation Swift App Development Workshop
  2. Get the code on github

Creating Virtualbox Environment

  • Virtualbox->File->Import Appliance…
  • Select the Swift VB 32bit Demo.ova file (or SwiftVB32bit.ova) and import it. Around 2.4 GB of local hard-disk space is required.
  • Start ‘Swift VB 32bit’ (the imported appliance may appear as ‘Swift VB 32bit Demo’)
  • SSH into port 3333 on your host OS. eg. ssh -p 3333 -l demo localhost
    • username: demo
    • password: password

Formatting Devices

$ sudo su -
# mkfs.xfs -f -i size=512 -L d1 /dev/sdb
# mkfs.xfs -f -i size=512 -L d2 /dev/sdc
# mkfs.xfs -f -i size=512 -L d3 /dev/sdd
# mkfs.xfs -f -i size=512 -L d4 /dev/sde

Handy Commands

Mounted Filesystems
# df
Formatted Filesystems
# blkid

Mounting Drives

# mkdir -p /srv/node/d1
# mkdir -p /srv/node/d2
# mkdir -p /srv/node/d3
# mkdir -p /srv/node/d4

# mount -t xfs -L d1 /srv/node/d1
# mount -t xfs -L d2 /srv/node/d2
# mount -t xfs -L d3 /srv/node/d3
# mount -t xfs -L d4 /srv/node/d4

Handy Commands

# for i in 1 2 3 4; do
> mkdir -p /srv/node/d$i
> mount -t xfs -L d$i /srv/node/d$i
> done
# chown -R swift:swift /srv/node

Creating the Builder Files

# cd /etc/swift
# 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

Create the Rings: Adding Devices

# cd /etc/swift
# p=0
# for t in object container account; do
> for i in 1 2 3 4; do
> swift-ring-builder $t.builder add z$i-127.0.0.1:600$p/d$i 100
> done
> let p++
> done

Validate your rings

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

Create the Rings: Do it

# cd /etc/swift
# swift-ring-builder account.builder rebalance
# swift-ring-builder container.builder rebalance
# swift-ring-builder object.builder rebalance

# ls /etc/swift/*.ring.gz
account.ring.gz container.ring.gz object.ring.gz

Extra Credit

# python
Python 2.7.1+ (r271:86832, Dec 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
>>> import pickle
>>> print pickle.load(open('object.builder'))

Let’s Start Swift!

# swift-init main restart 

Tail the log file

# tail -f /var/log/swift/all.log

Get a Token!

# curl -v -H 'X-Auth-User: admin:admin' -H 'X-Auth-Key: admin' http://127.0.0.1:8080/auth/v1.0/

< HTTP/1.1 200 OK
< X-Storage-Url: http://127.0.0.1:8080/v1/AUTH_admin
< X-Storage-Token: AUTH_tk265318ae5e7e46f1890a441c08b5247f
< X-Auth-Token: AUTH_tk265318ae5e7e46f1890a441c08b5247f
< X-Trans-Id: txc75adf112791425e82826d6e3989be4d
< Content-Length: 0

Extra Credit: Token in memcache?

# python
>>> import swift.common.memcached as memcached
>>> memcache = memcached.MemcacheRing(['127.0.0.1:11211'])
>>> print memcache.get('AUTH_/user/admin:admin')
AUTH_tk265318ae5e7e46f1890a441c08b5247f
>>> print memcache.get('AUTH_/token/AUTH_tk265318ae5e7e46f1890a441c08b5247f')

Use a Token!

Access the X-Storage-Url using the X-Auth-Token:

# curl -v -H 'X-Auth-Token: [the X-Auth-Token from previous step]' [X-Storage-Url value from previous step]

Uploading

# swift -U admin:admin -K admin -A http://127.0.0.1:8080/auth/v1.0/ upload test_container /vmlinuz

# swift -U admin:admin -K admin -A http://127.0.0.1:8080/auth/v1.0/ list test_container

Where is the object?

# cd /srv/node
# find . -name '*.data'
# swift-object-info /full/path/to/file.data
# swift-get-nodes /etc/swift/object.ring.gz AUTH_admin test_container vmlinuz

Replication

# swift-init account-replicator start
# swift-init container-replicator start
# swift-init object-replicator start

Is rsync running?

# rsync localhost::
# rsync localhost::account
# rsync localhost::container
# rsync localhost::object

DESTROY!!!!

# rm -rf /srv/node/d1/*
# tail -f /var/log/swift/all.log
# tail -f /var/log/rsyncd.log