前置き
GlusterFS3.3がリリースされましたので、あらためて、Swift-APIのセットアップ手順をまとめておきます。Beta版とは手順が変わっている部分があるのでご注意ください。Swift-APIについては、下記の資料を参考にしてください。
・GlusterFSのSwiftAPIを本家Swiftと 比較してみよう!
ここでは、GlusterFSのクラスタを構成する各ノード上で、直接、Swift-APIの機能を提供する構成をとります。(これは、Red Hat Storage 2.0での推奨構成となります。)
GlusterFSサーバの構成
gluster01, gluster02, gluster03の3ノードからなるクラスタを構成して、ボリュームvol01を作成します。
まずは、各ノードに共通の準備作業です。
各ノードにRHEL6.2を入れて、RHEL6.2のリポジトリを登録しておきます。名前解決は、ここでは、/etc/hostsで行います。
/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.122.31 gluster01 192.168.122.32 gluster02 192.168.122.33 gluster03
Brickに使用するファイルシステムを/dataにマウントしておきます(マウントポイントは環境に応じて変更して構いません)。マウントオプションには、必ず「user_xattr」を指定してください。ユーザ拡張属性にACL情報を保存するために必要となります。(XFSではデフォルトで有効なので、user_xattrの指定は不要です。)
GlusterFS3.0をインストールして、glusterdを起動します。
# yum localinstall \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-3.3.0-1.el6.x86_64.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-server-3.3.0-1.el6.x86_64.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-fuse-3.3.0-1.el6.x86_64.rpm # service glusterd start
ここからは、gluster01で作業します。peerを登録して、ボリュームvol01を作成、開始します。
# gluster peer probe gluster02 # gluster peer probe gluster03 # gluster peer status Number of Peers: 2 Hostname: gluster02 Uuid: 354b7e9c-fff8-4e00-b585-88fa1129fc72 State: Peer in Cluster (Connected) Hostname: gluster03 Uuid: dabae84c-c423-47fd-a3cf-e96b38f6fc8f State: Peer in Cluster (Connected) # gluster vol create vol01 gluster01:/data/brick01 gluster02:/data/brick01 gluster03:/data/brick01 Creation of volume vol01 has been successful. Please start the volume to access data. # gluster vol start vol01 Starting volume vol01 has been successful # gluster vol status Status of volume: vol01 Gluster process Port Online Pid ------------------------------------------------------------------------------ Brick gluster01:/data/brick01 24009 Y 1901 Brick gluster02:/data/brick01 24009 Y 2088 Brick gluster03:/data/brick01 24009 Y 2061 NFS Server on localhost 38467 Y 1906 NFS Server on gluster02 38467 Y 2093 NFS Server on gluster03 38467 Y 2067
Swift-APIの構成
各ノードに共通の作業です。
前提パッケージがEPELに含まれているので、EPELのリポジトリを登録した上で、Swift-APIのパッケージを導入します。
# yum localinstall http://ftp.osuosl.org/pub/fedora-epel/6/i386/epel-release-6-7.noarch.rpm # yum localinstall \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-1.4.8-4.el6.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-account-1.4.8-4.el6.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-container-1.4.8-4.el6.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-doc-1.4.8-4.el6.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-object-1.4.8-4.el6.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-plugin-1.0-2.noarch.rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/UFO/gluster-swift-proxy-1.4.8-4.el6.noarch.rpm
/etc/swift/proxy-server.confを次の内容で作成します。
/etc/swift/proxy-server.conf
[DEFAULT] user = root log_facility = LOG_LOCAL1 bind_ip = gluster01 bind_port = 443 cert_file = /etc/swift/cert.crt key_file = /etc/swift/cert.key [pipeline:main] pipeline = healthcheck cache tempauth proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true account_autocreate = true [filter:tempauth] use = egg:swift#tempauth #user_<account>_<user name> = <password> [.admin] user_vol01_admin = pas4vol01admin .admin user_vol01_user01 = pas4vol01user01 [filter:healthcheck] use = egg:swift#healthcheck [filter:cache] use = egg:swift#memcache memcache_servers = gluster01:11211,gluster02:11211,gluster03:11211
「bind_ip = gluster01」は、各ノードの(外部からアクセス可能なIPに対応する)ホスト名を指定します。これが無いと、リモートクライアントからのアクセスに失敗します。(参考)
「memcache_servers = gluster01:11211,gluster02:11211,gluster03:11211」では、各ノードのmemcachedを分散構成で共有使用するように指定しています。
[filter:tempauth]セクションは、書式に注意してください。コメントにあるように、下記の形式で特定のアカウントを使用するためのuser/passwordを指定します。管理者権限をつける場合は、最後の「.admin」を追加します。また、アカウント名は、そのアカウントが使用するボリューム名に一致させる必要があります。ここでは、「アカウント名 = vol01」となります。
#user_<account>_<user name> = <password> [.admin]
SSL認証用の証明書を作成します。
# pushd /etc/swift # openssl req -new -x509 -nodes -out cert.crt -keyout cert.key -days 36500 -subj "/C=JP/ST=Tokyo/CN=Swift API" # popd
memcachedとSwift-APIを起動します。chkconfigでサーバ起動時の自動起動も設定しておきます。
# service memcached start # swift-init main start Starting proxy-server...(/etc/swift/proxy-server.conf) Starting container-server...(/etc/swift/container-server/1.conf) Starting account-server...(/etc/swift/account-server/1.conf) Starting object-server...(/etc/swift/object-server/1.conf) # chkconfig memcached on # chkconfig gluster-swift-account on # chkconfig gluster-swift-container on # chkconfig gluster-swift-object on # chkconfig gluster-swift-proxy on
動作確認
認証トークンの取得
# curl -v -H 'X-Storage-User: vol01:admin' -H 'X-Storage-Pass:pas4vol01admin' -k https://gluster01:443/auth/v1.0 * About to connect() to gluster01 port 443 (#0) * Trying 192.168.122.31... connected * Connected to gluster01 (192.168.122.31) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * warning: ignoring value of ssl.verifyhost * skipping SSL peer certificate verification * SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: CN=Swift API,ST=Tokyo,C=JP * start date: 6月 01 07:03:43 2012 GMT * expire date: 5月 08 07:03:43 2112 GMT * common name: Swift API * issuer: CN=Swift API,ST=Tokyo,C=JP > GET /auth/v1.0 HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: gluster01 > Accept: */* > X-Storage-User: vol01:admin > X-Storage-Pass:pas4vol01admin > < HTTP/1.1 200 OK < X-Storage-Url: https://gluster01:443/v1/AUTH_vol01 < X-Storage-Token: AUTH_tk64fd7384f04a4883864997f6124c998e < X-Auth-Token: AUTH_tk64fd7384f04a4883864997f6124c998e < Content-Length: 0 < Date: Fri, 01 Jun 2012 23:20:58 GMT < * Connection #0 to host gluster01 left intact * Closing connection #0
コンテナcontainer01の作成
# TOKEN=AUTH_tk64fd7384f04a4883864997f6124c998e # curl -v -X PUT -H "X-Auth-Token: $TOKEN" https://gluster01:443/v1/AUTH_vol01/container01 -k * About to connect() to gluster01 port 443 (#0) * Trying 192.168.122.31... connected * Connected to gluster01 (192.168.122.31) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * warning: ignoring value of ssl.verifyhost * skipping SSL peer certificate verification * SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: CN=Swift API,ST=Tokyo,C=JP * start date: 6月 01 07:03:43 2012 GMT * expire date: 5月 08 07:03:43 2112 GMT * common name: Swift API * issuer: CN=Swift API,ST=Tokyo,C=JP > PUT /v1/AUTH_vol01/container01 HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: gluster01 > Accept: */* > X-Auth-Token: AUTH_tk64fd7384f04a4883864997f6124c998e > < HTTP/1.1 201 Created < Content-Length: 18 < Content-Type: text/html; charset=UTF-8 < Date: Fri, 01 Jun 2012 23:21:33 GMT < 201 Created * Connection #0 to host gluster01 left intact * Closing connection #0
コンテナ一覧の取得
# curl -v -X GET -H "X-Auth-Token: $TOKEN" https://gluster01:443/v1/AUTH_vol01 -k * About to connect() to gluster01 port 443 (#0) * Trying 192.168.122.31... connected * Connected to gluster01 (192.168.122.31) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * warning: ignoring value of ssl.verifyhost * skipping SSL peer certificate verification * SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: CN=Swift API,ST=Tokyo,C=JP * start date: 6月 01 07:03:43 2012 GMT * expire date: 5月 08 07:03:43 2112 GMT * common name: Swift API * issuer: CN=Swift API,ST=Tokyo,C=JP > GET /v1/AUTH_vol01 HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: gluster01 > Accept: */* > X-Auth-Token: AUTH_tk64fd7384f04a4883864997f6124c998e > < HTTP/1.1 200 OK < X-Account-Container-Count: 1 < X-Account-Object-Count: 0 < X-Bytes-Used: 0 < X-Object-Count: 0 < X-Account-Bytes-Used: 0 < X-Type: Account < X-Container-Count: 1 < Accept-Ranges: bytes < Content-Length: 12 < Content-Type: text/plain; charset=utf-8 < Date: Fri, 01 Jun 2012 23:22:11 GMT < container01 * Connection #0 to host gluster01 left intact * Closing connection #0
swiftコマンドによる使用例
# swift -A https://gluster01/auth/v1.0 -U vol01:admin -K pas4vol01admin post container02 # swift -A https://gluster01/auth/v1.0 -U vol01:admin -K pas4vol01admin list container01 container02 # swift -A https://gluster01/auth/v1.0 -U vol01:admin -K pas4vol01admin upload container01 /boot/vmlinuz-2.6.32-220.13.1.el6.x86_64 boot/vmlinuz-2.6.32-220.13.1.el6.x86_64 # swift -A https://gluster01/auth/v1.0 -U vol01:admin -K pas4vol01admin list container01 boot boot/vmlinuz-2.6.32-220.13.1.el6.x86_64 # swift -A https://gluster01/auth/v1.0 -U vol01:admin -K pas4vol01admin stat Account: AUTH_vol01 Containers: 2 Objects: 0 Bytes: 0 Accept-Ranges: bytes X-Bytes-Used: 0 X-Container-Count: 2 X-Object-Count: 0 X-Type: Account