gluster objectストレージを試してみた

Glusterfsではバージョン3.3以降でHTTPで読み書きが出来る機能(Objectストレージ, 以下UFO) が追加されている。
これについて、Scientific linux 6.3 + glusterfs 3.3.1 (ノード名: scfc-virt2)で確認した。

基本的には本家(?)の記事が参考になるが、パッケージ置き場の追加は手動で行う必要があるので注意。
https://access.redhat.com/site/documentation/en-US/Red_Hat_Storage/2.0/html/Administration_Guide/chap-User_Guide-UFO.html

パッケージ置き場としては、こちらを使用した。
http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.1/EPEL.repo/glusterfs-epel.repo

パッケージインストール

yum install glusterfs-server glusterfs-swift glusterfs-swift-proxy glusterfs-swift-account glusterfs-swift-container glusterfs-swift-object glusterfs-swift-plugin
※ swift関連のパッケージは全てインストールしないと上手く動作しないので注意

ボリューム作成

まずボリュームを作成する。ボリューム名は後で使用するUFOの設定と合わせる必要があるので注意。(ここでは"test"を使用)

service glusterd start
mkdir /root/glusterfs/
cd /root/glusterfs/
mkdir test
gluster volume create test scfc-virt2:/root/glusterfs/test/
gluster volume list
gluster volume start test
mount -t glusterfs localhost:/test /mnt/
ls /mnt/
umount /mnt

Swift部分の設定変更

まずSSL設定とユーザー設定を実施した。(SSL設定はオプションと思われる)

/etc/swift以下のdiff はこちらになる。

 diff --git a/proxy-server.conf b/proxy-server.conf
 index 1fcde8e..61e14d0 100644
 --- a/proxy-server.conf
 +++ b/proxy-server.conf
 @@ -3,6 +3,12 @@ bind_port = 8080
 user = root
 log_facility = LOG_LOCAL1
 
 +bind_port = 443
 +cert_file = /etc/swift/cert.crt
 +key_file = /etc/swift/cert.key
 +
 +
 +
 [pipeline:main]
 pipeline = healthcheck cache tempauth proxy-server
 
 @@ -14,6 +20,10 @@ account_autocreate = true
 [filter:tempauth]
 use = egg:swift#tempauth
 
 +
 +user_test_tester = testing .admin
 +
 +
 [filter:healthcheck]
 use = egg:swift#healthcheck

※ 事前にSSL鍵を作っておく必要あり

# cd /etc/swift
# openssl req -new -x509 -nodes -out cert.crt -keyout cert.key

Swift 起動

[root@scfc-virt2 ~]# 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)
[root@scfc-virt2 ~]# 

※ 上手くいかない場合 /var/log/messages を確認する。。

動作確認

認証を実施:
# curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass:testing' -k https://localhost:443/auth/v1.0
 ///
 < HTTP/1.1 200 OK
 < X-Storage-Url: https://127.0.0.1:443/v1/AUTH_test
 < X-Storage-Token: AUTH_tkbf93f02e7e6842bb98374849cedcb6d1
 < X-Auth-Token: AUTH_tkbf93f02e7e6842bb98374849cedcb6d1
 < Content-Length: 0
 < Date: Sat, 30 Mar 2013 09:38:43 GMT
 < 
 * Connection #0 to host localhost left intact
 * Closing connection #0
 ///

コンテナー名を列記:
# curl -v -X GET -H 'X-Auth-Token: AUTH_tkbf93f02e7e6842bb98374849cedcb6d1' https://localhost:443/v1/AUTH_test -k
///
 < HTTP/1.1 204 No Content
 < X-Account-Container-Count: 0
 < X-Account-Object-Count: 0
 < X-Bytes-Used: 0
 < X-Object-Count: 0
 < X-Account-Bytes-Used: 0
 < X-Type: Account
 < X-Container-Count: 0
 < Accept-Ranges: bytes
 < Content-Length: 0
 < Date: Sat, 30 Mar 2013 10:05:14 GMT
 < 
 * Connection #0 to host localhost left intact
 * Closing connection #0
///
※ "test"という名前のvolumeが無いと、ここで503エラーが発生。

ファイル作成:
# curl -T /tmp/mmm -X PUT -k -H 'X-Auth-Token: AUTH_tkbf93f02e7e6842bb98374849cedcb6d1' -H 'transfer-encoding: chunked' https://localhost:443/v1/AUTH_test/hello/aaa
※ ファイルが作成されているかの確認は、/mnt/gluster-objects かbrickの置き場所(/root/glusterfs/test)で実施する。 

まとめ

差し当たりGlusterのUFOを動かすことが出来た。実際に実施していることはHTTPでファイルGET/PUTを受けてプロキシ上にマウントされた glusterfsに読み書きしているだけのようなので、あまり新しいことはないが、、セグメントを越えたりリバースプロキシ経由でglusterに読み書き出来たりするので、オンプレミスの環境ではかなり使い勝手がよくなる気がしている。。(特にセグメント越えでCIFSが遅い場合や、、閲覧元がWindowsUnixでない場合)

※ 今のところ、ユーザー名が proxy-server.conf に直書きするしかなく、かつ、反映時に再起動が必要なのが運用上少々辛い気がする(ロードバランサーを使えば出来なくはないかもしれないが)

qpidでルーティングを作るときのメモ

qpidでルーティングを作るとき、QueueからQueueにルートを作るようにしないと、送り元で一度受け取って、送り先が起動したタイミングで再送、という動作が実施できない。
しかし、qpid-configでqueueルートを作る場合、指定できるのが送り元のqueueと送り先のexchangeとなっており、queueからqueueへのルートを作るには工夫が必要となる。

上手くいった構成としては、次の順で、Queue,Exchange,QueueをQueueルート、およびbindでつないだときだった。
※ メッセージの送信/受信は、サンプルのspout/drain で実施
hello2(queue, centos-virt12) -> (routing) -> helloexch(exchange, centos-virt11) -> (bind) -> hello(queue, centos-virt11)

事前準備

(centos-virt11)$ qpid-config add queue hello
(centos-virt12)$ qpid-config add queue hello2
(centos-virt11)$ qpid-config add exchange fanout helloexch
(centos-virt11)$ qpid-config bind helloexch hello
(centos-virt11)$ qpid-route queue add centos-virt11 centos-virt12 helloexch hello2
※ $ qpid-route route map で確認可能

確認

(centos-virt12)$ spout hello2
(centos-virt11)$ drain -f -r hello
※ centos-virt11上でメッセージが表示されることを確認する

なお、ルーティングのテストをする場合、同じブローカー内ではルートが作れないので注意。。

$ qpid-route queue add localhost localhost hello2 hello
Failed: Exception - Linking broker to itself is not permitted

追記:
※ bind があるかどうかを確認するには

$ qpid-tool
> list exchange
> list queue
から接続元/接続先 を調べて、
> list binding
> show (bindID)
exchangeRef
queueRef
を調べていくしかなさそう。。

PythonでExcelを操作する時のメモ

Windows版のPythonとwin32com モジュールを使うことで、VBAからしか使用出来ないような機能が Pythonからも使用できるようになる。
Git等と連携できる点や、普通のPythonモジュール(正規表現XML/JSON処理等)が使える点が圧倒的に便利で、、もはやVBAには戻れない。

インストール

本体とモジュールをインストールする(Windowsのみに対応)

http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi

  • win32comモジュール:

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/

役に立つリソース

  • 全般的:

http://mono-comp.com/programming/python-win-excel
https://sites.google.com/site/pythoncasestudy/home/pywin32kara-comwo-tsuka-tsu-te-excelwo-sousa-suru-houhou

  • セル数が多いときの必須テクニック:

http://d.hatena.ne.jp/Wacky/20091011/1255259575

https://github.com/aaabbb200909/test01/blob/master/win32excel.py

  • 追記: Oreilly本(特にmakepy.py の使い方)

http://oreilly.com/catalog/pythonwin32/chapter/ch12.html


※ ちなみにPerl/Ruby等でも類似のモジュールがあるようなので、お好みで

2013年04月06日のツイート

Apache qpid稼働確認時のメモ

※ CentOS6のqpidで確認
CentOS python-qpidパッケージにはいくつかサンプルのスクリプトが付いてきており、そちらを使って、qpidの動作確認をする場合のメモ。
ファイルの置き場所は /usr/share/doc/python-qpid-0.14/examples/api/ で使用するファイルは hello, drain, spoutとなる。
helloは指定されたキューにメッセージを書き込み、そのまま受信するので単体で使える。(Exchangeに対しても使用可能)
drain, spoutはそれぞれ受信/送信だけを行うので、組み合わせて使う。(Queueではなく、Exchangeに対して使う場合はは工夫が必要。。)

qpidのインストールを終えたら、まずhello で helloworldがかえってくるかを確認する。(単体qpidでの疎通確認)

./hello

その後、drain -r -f amq.fanout を実行しつつ, spout amq.fanout で、任意のexchange, queue 指定でメッセージ送信が出来るかを確認する(bind, routing のテストにも使える)

./drain -r -f amq.fanout
./spout amq.fanout

※ amq.fanoutはqueueではなく、exchangeのため、メッセージを受信するためには、drainの-fオプションが必要なことに注意。。

サイズの異なるメッセージを送りたい場合第2引数にテキストファイルを指定するとそちらをメッセージに含めることが出来る。

./spout amq.fanout $(cat aaa)

queueを作成したい場合はqpid-config (qpid-tools パッケージを使用)

qpid-config add queue キュー名

※ デフォルトで作成されているamq.fanout, amq.topic などはExchangeで、メッセージを貯めることが出来ないので注意。。

queueが作成されたかどうかはqpid-config で確認できる。

qpid-config
qpid-config queues

なお、キュー定義をdurableにしておかないと、qpidd再起動時にキューが消えてしまうので注意。(qpid-cpp-server-store パッケージが必要)

qpid-config add queue キュー名 --durable

GitでExcel2003のdiffを取る方法

やり方はまず、次のページからファイルのダウンロードを行い、 xls2txt を作成しておく。
Linux or Cygwin上で実施可能
http://wizard.ae.krakow.pl/~jb/xls2txt/

その後、次のページの形式に従って、.git 以下を編集しておく。
http://sixtease.livejournal.com/45387.html
.git/config に

[diff "excel"]
  textconv=/usr/local/bin/xls2txt.exe -A

.git/info/attributes に

 *.xls diff=excel

これで、git diff でExcelの記述がテキストのdiffで表示されるようになるはず。
※ Excel2003でしか試していないので、それ以外だと無理かも。。