2011年12月2日金曜日

OpenStack Swift1.4.x を10分で動かす(rpm/yum編)


このエントリーをはてなブックマークに追加


とにかく速攻でSwiftを動かしてどんな感じか確かめてみたい人向け。


必要なもの

・Scientific Linux 6.1 x64(仮想環境上でも可能)
・ディスク空き10GBくらい
・インターネット接続


ディスクイメージの作成

# mkdir -p /swift/disk{0..4}

# for i in {0..4}
> do
> dd if=/dev/zero of=/mnt/disk$i bs=1024k count=1024
> done

# for i in {0..4}
> do
> mkfs.ext4 /mnt/disk$i
> done


パッケージの導入

# rpm -ihv http://yum.griddynamics.net/yum/master/openstack/openstack-repo-2011.3-0.2.noarch.rpm
# yum install -y openstack-swift* xinetd rsysnc memcached


デバイスのマウント

# for i in {0..4}
> do
> mount -o loop,noatime,nodiratime,user_xattr /mnt/disk$i /swift/disk$i
> done

# chown -R swift:swift /swift


/etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 0.0.0.0

[account]
max connections = 25
path = /swift
read only = false
lock file = /var/lock/account.lock

[container]
max connections = 25
path = /swift
read only = false
lock file = /var/lock/container.lock

[object]
max connections = 25
path = /swift
read only = false
lock file = /var/lock/object.lock


/etc/xinetd.d/rsync
service rsync
{
        disable = no
#       flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}


/etc/swift/account-server.conf
[DEFAULT]
devices = /swift
bind_ip = 0.0.0.0
workers = 2

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]

[account-auditor]

[account-reaper]


/etc/swift/container-server.conf
[DEFAULT]
devices = /swift
bind_ip = 0.0.0.0
workers = 2

[pipeline:main]
pipeline = container-server

[app:container-server]
use = egg:swift#container

[container-replicator]

[container-updater]

[container-auditor]

[container-sync]



/etc/swift/object-server.conf
[DEFAULT]
devices = /swift
bind_ip = 0.0.0.0
workers = 2

[pipeline:main]
pipeline = object-server

[app:object-server]
use = egg:swift#object

[object-replicator]

[object-updater]

[object-auditor]



/etc/swift/proxy-server.conf
[DEFAULT]
#cert_file = /etc/swift/cert.crt
#key_file = /etc/swift/cert.key
bind_ip = 0.0.0.0
bind_port = 8080
workers = 8
user = swift

[pipeline:main]
pipeline = healthcheck cache tempauth proxy-server

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true

[filter:tempauth]
use = egg:swift#tempauth
user_system_root = testpass .admin

[filter:healthcheck]
use = egg:swift#healthcheck

[filter:cache]
use = egg:swift#memcache
memcache_servers = 127.0.0.1:11211


/etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = swift1234


Ringの作成

# cd /etc/swift/

# for i in {account,container,object}
> do
> swift-ring-builder $i.builder create 10 3 1
> done

# swift-ring-builder account.builder add z0-127.0.0.1:6002/disk0 100
# swift-ring-builder account.builder add z1-127.0.0.1:6002/disk1 100
# swift-ring-builder account.builder add z2-127.0.0.1:6002/disk2 100
# swift-ring-builder account.builder add z3-127.0.0.1:6002/disk3 100
# swift-ring-builder account.builder add z4-127.0.0.1:6002/disk4 100
# swift-ring-builder account.builder rebalance

# swift-ring-builder container.builder add z0-127.0.0.1:6001/disk0 100
# swift-ring-builder container.builder add z1-127.0.0.1:6001/disk1 100
# swift-ring-builder container.builder add z2-127.0.0.1:6001/disk2 100
# swift-ring-builder container.builder add z3-127.0.0.1:6001/disk3 100
# swift-ring-builder container.builder add z4-127.0.0.1:6001/disk4 100
# swift-ring-builder container.builder rebalance

# swift-ring-builder object.builder add z0-127.0.0.1:6000/disk0 100
# swift-ring-builder object.builder add z1-127.0.0.1:6000/disk1 100
# swift-ring-builder object.builder add z2-127.0.0.1:6000/disk2 100
# swift-ring-builder object.builder add z3-127.0.0.1:6000/disk3 100
# swift-ring-builder object.builder add z4-127.0.0.1:6000/disk4 100
# swift-ring-builder object.builder rebalance


起動

# /etc/init.d/xinetd start
# /etc/init.d/memcached start
# swift-init all start


確認

# swift -A http://127.0.0.1:8080/auth/v1.0 -U system:root -K testpass upload container1 account.builder container.builder object.builder

# swift -A http://127.0.0.1:8080/auth/v1.0 -U system:root -K testpass list container1
account.builder
container.builder
object.builder

# swift -A http://127.0.0.1:8080/auth/v1.0 -U system:root -K testpass stat
Account: AUTH_system
Containers: 1
Objects: 3
Bytes: 24408
Accept-Ranges: bytes

0 件のコメント:

コメントを投稿