2011年12月3日土曜日

OpenStack Swift の開発環境を整える


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


Swift Developer になろう!


準備

BasicインストールしたSL6 x64で構築(selinux/iptables off)

最低限のパッケージをインストール
[root@swift-dev ~]# yum install -y gcc
[root@swift-dev ~]# yum install -y python-devel python-setuptools python-tools
[root@swift-dev ~]# yum install -y xinetd rsync memcached


開発用ユーザを作成
[root@swift-dev ~]# groupadd -g 101 swift
[root@swift-dev ~]# useradd -u 1001 -g 101 -d /opt/swift -m -s /bin/bash swift
[root@swift-dev ~]# passwd swift



virtualenv、virtualenvwrapperのインストール

[root@swift-dev ~]# easy_install virtualenv
[root@swift-dev ~]# easy_install virtualenvwrapper

[root@swift-dev ~]# su - swift

[swift@swift-dev ~]$ vim ./.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
source `which virtualenvwrapper.sh`

[swift@swift-dev ~]$ logout
[root@swift-dev ~]# su - swift
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/get_env_details
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/prermproject
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/postrmproject


Swift用ワークの作成とライブラリのインストール

[swift@swift-dev ~]$ mkvirtualenv swift-1.4.4-dev
New python executable in swift-1.4.4-dev/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/swift-1.4.4-dev/bin/predeactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/swift-1.4.4-dev/bin/postdeactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/swift-1.4.4-dev/bin/preactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/swift-1.4.4-dev/bin/postactivate
virtualenvwrapper.user_scripts creating /opt/swift/.virtualenvs/swift-1.4.4-dev/bin/get_env_details
(swift-1.4.4-dev)[swift@swift-dev ~]$

(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install configobj
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install eventlet
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install greenlet
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install httplib2
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install netifaces
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install paste
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install pastedeploy
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install routes
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install simplejson
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install sqlalchemy
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install webob==1.0.8
(swift-1.4.4-dev)[swift@swift-dev ~]$ pip install xattr

* WebOBは最新版を入れると動かない。これに該当するみたい。

(swift-1.4.4-dev)[swift@swift-dev ~]$ pip freeze
Paste==1.7.5.1
PasteDeploy==1.5.0
Routes==1.12.3
SQLAlchemy==0.7.3
WebOb==1.0.8
configobj==4.7.2
eventlet==0.9.16
greenlet==0.3.1
httplib2==0.7.2
netifaces==0.6
simplejson==2.2.1
xattr==0.6.2


Swiftのインストール

(swift-1.4.4-dev)[swift@swift-dev ~]$ wget http://launchpad.net/swift/essex/1.4.4/+download/swift-1.4.4.tar.gz
(swift-1.4.4-dev)[swift@swift-dev ~]$ tar zxvf swift-1.4.4.tar.gz
(swift-1.4.4-dev)[swift@swift-dev ~]$ mv swift-1.4.4 swift-1.4.4.org
(swift-1.4.4-dev)[swift@swift-dev ~]$ cd swift-1.4.4.org/
(swift-1.4.4-dev)[swift@swift-dev swift-1.4.4.org]$ cp -R swift ~/.virtualenvs/swift-1.4.4-dev/lib/python2.6/site-packages/

(swift-1.4.4-dev)[swift@swift-dev swift-1.4.4.org]$ cd
(swift-1.4.4-dev)[swift@swift-dev ~]$ pwd

(swift-1.4.4-dev)[swift@swift-dev ~]$ ./swift-1.4.4.org/bin/swift-ring-builder
swift-ring-builder 1.3

省略

Quick list: add create list_parts rebalance remove search set_info
            set_min_part_hours set_weight validate write_ring
Exit codes: 0 = operation successful
            1 = operation completed with warnings
            2 = error

これでSwiftが動くようになる。サーバ機能(account,container,object,proxy)を動かすには設定ファイル等の周辺環境も必要なので、こちらを参照して設定する。

python setup.py build
python setup.py install

してもいい。

0 件のコメント:

コメントを投稿