medamaの日記

技術的な事をメインにしてみる。

GlusterFSを検証してみる。 (1)

GlusterFSもVersion3.3がリリースされて希望していた機能がずいぶん実装されたのでそろそろ検証をしてみる事にした。

Version3.3の目玉は

 

Unified File and Object Storage

Scale-out storage for Apache Hadoop

Proactive self-healing

 

What's New3.3配下を参照の事。

http://www.gluster.org/community/documentation/index.php/WhatsNew3.3

 

Apache HadoopのHDFSは確かメタ管理サーバがsingle point of failure(SPOF)になるはずなのでそれが弱点だった気がする。

確かに自前でcluster化すれば良いのだろうけどGlusterFSが使えるのであればそれはそれで楽。

あとHDFSはPOSIX準拠のFilesystemではないのでファイル操作が面倒。

 

Proactive self-healingというのはこれから検証するので詳しくはまだわかっていないのだけれども障害発生、データ矛盾を自動的に解消する仕組みのはず。

(それ以前はデータにアクセスすると復旧が走り出す。)

 

検証環境は以下の通り。

仮想環境: Cirtix Xen Server 6(Free Edition)

VM OS:CentOS6.3(64bit)

VM OS Kernel Version:2.5.32-279.2.1.el6.x86_64

Xen Tools:version6 installed

VM 台数:3 (gluster-sv1, gluster-sv2, gluster-sv3)

サーバとクライアントはそれぞれ兼ねるもの、とした。

storageはCitrix Xen Serverの構築の関係上、全て同一storage(VM自体もこの中にある)を利用する事になるのでベンチマークはさほど期待しないでほしい。

OSはxvda(60G)にインストールし、GlusterFS領域はxvdb(50G)に割り当てるように設定し、それぞれ別領域とする。

 

サーバ間の名前解決ができるように/etc/hostsに以下の記述を行っておく。

 

172.17.1.40     gluster-sv1
172.17.1.41     gluster-sv2
172.17.1.42     gluster-sv3

 

GlusterFSのLATESTダウンロードは以下から行える。

http://download.gluster.org/pub/gluster/glusterfs/LATEST/

 

が、まずはRelease Notesを読んでみる。

http://www.gluster.org/community/documentation/index.php/Main_Page

 大したことは載っていない・・・。(汗)

なので、Admin Guideを読んでみる事にした。

http://www.gluster.org/wp-content/uploads/2012/05/Gluster_File_System-3.3.0-Administration_Guide-en-US.pdf

 こちらはある程度充実した内容が記載されている。

と書きつつ、さてRPMをインストールするか、と思ったが、何のRPMをインストールすればよいのか何の記載もない・・・。

今回はgeo replicationもしないし、rdmaも使わないので以下のパッケージをインストールすことから始めてみた。

足りなければ後で足せばよいし。

http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-3.3.0-1.el6.x86_64.rpm

http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-fuse-3.3.0-1.el6.x86_64.rpm

http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-server-3.3.0-1.el6.x86_64.rpm

 

rpm -hiv gluster-fs*

 

にてパッケージをインストールした。依存関係のエラーは出なかったのでとりあえずは問題なさそうだ。

Admin Guide

Chapter2 Managing the glusterd Service

によると。

 

#chkconfig glusterd on

 

しなさいと書いてあるので上記の通りサービス登録及びサービス起動を行う。

 

# /etc/init.d/glusterd start

 

次に4.1. Adding Servers to Trusted Storage Poolによると信頼したStorage Poolを作成し、そこへ信頼関係のあるサーバを追加しろ、とある。

 

まず、gluster-sv1にてgluster-sv2, gluster-sv3をマニュアル通り追加したみる。

 

[root@gluster-sv1 ~]# gluster peer probe gluster-sv2
Probe unsuccessful
Probe returned with unknown errno 107

 

早速こけた・・・。

こういう時のお約束はiptablesが邪魔をしているので全サーバにて

 

# chkconfig iptables off

# /etc/init.d/iptables stop

 

[root@gluster-sv1 ~]# gluster peer probe gluster-sv2
Probe successful
[root@gluster-sv1 ~]# gluster peer probe gluster-sv3
Probe successful

 

はい。gluster-sv1にてStorage Poolへのサーバ追加が完了しました。

確認してみます。

(gluster-sv1にて)

[root@gluster-sv1 ~]# gluster peer status
Number of Peers: 2

Hostname: gluster-sv2
Uuid: 2e76d962-e3cb-4ab2-8b92-f23a738f0e9d
State: Peer in Cluster (Connected)

Hostname: gluster-sv3
Uuid: 6eb7a405-d7ba-47dc-84c6-4f30531a9c3a
State: Peer in Cluster (Connected)

 

(gluster-sv2にて)

[root@gluster-sv2 ~]# gluster peer status
Number of Peers: 2

Hostname: gluster-sv1
Uuid: 0525a794-013c-4382-87a6-260291a931ea
State: Peer in Cluster (Connected)

Hostname: gluster-sv3
Uuid: 6eb7a405-d7ba-47dc-84c6-4f30531a9c3a
State: Peer in Cluster (Connected)

 

(gluster-sv3にて)

[root@gluster-sv3 ~]# gluster peer status
Number of Peers: 2

Hostname: gluster-sv1
Uuid: 0525a794-013c-4382-87a6-260291a931ea
State: Peer in Cluster (Connected)

Hostname: gluster-sv2
Uuid: 2e76d962-e3cb-4ab2-8b92-f23a738f0e9d
State: Peer in Cluster (Connected)

 

3台とも問題なく認識しているようだ。

当然Storage Poolからサーバを削除することもできるようなのだが、このテストは実際に容量を割り当て可能な状態から離脱させるテストの時に実施してみる事とする。

本番環境時にはメンテナンス等で必要な措置となるため。

 

それでは次に

Chapter 5. Setting up GlusterFS Server Volumes

に従ってVolumeのセットアップをしてみよう。

Volumeのタイプには以下のものがあるらしい。

 

Distributed

Replicated

Striped

Distributed Striped

Distributed Replicated

Distributed Striped Replicated

Striped Replicated

 

さて。なんとなく書いていることは分かるが、なんだ、この組み合わせは・・・。

と思ったがマニュアルには丁寧に図解入りで説明があるので詳しくはそちらを読んでもらうとして。

Distributedは冗長性もないのでパス。単に容量をどんどんスケールアウトさせる時に使うらしい。が、スケールさせるほどデータロスの危険性は増えるのでまず使わないでしょう。

HDFS同様、Replicationは必須と思うので、Replication絡みの資料を読んでみる事にする。

ReplicatedというのはHDFSのReplicationと同様の様だ。

従って、利用できる容量はreplicationの数と反比例していく。(当たり前)

HDFSではreplication数を3以上を強く推奨していたはず、あと、当環境もそれを意識して検証機の数を3にしているので、まず、

Replicated

を選択してreplicationの数を3としてみる事にする。

まず、各サーバのxvdbをfdisk、ext4 formatして、gluster-sv1は/exp1, gluster-sv2は/exp2, gluster-sv3は/exp3としてmountさせておく。

 

Storage Pool device

gluster-sv1  /exp1

gluster-sv2  /exp2

gluster-sv3  /exp3

 

その他パラメータは以下の通りとする。

 

volume name=test-volume

replica COUNT=3

transport protocol=tcp

 

以下のコマンドを何れかのサーバで実行する。

 

gluster volume create test-volume replica 3 transport tcp gluster-sv1:/exp1 gluster-sv2:/exp2 gluster-sv3:/exp3

 

コマンド結果

Creation of volume test-volume has been successful. Please start the volume to access data.

 

成功したようだ。

次に、volumeを動かしてみる。

その前に今作成したvolumeの状態を確認してみる。

 

[root@gluster-sv1 ~]# gluster volume info all

Volume Name: test-volume
Type: Replicate
Volume ID: 76d2f5aa-b713-4d55-880e-2965d6b24398
Status: Created
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: gluster-sv1:/exp1
Brick2: gluster-sv2:/exp2
Brick3: gluster-sv3:/exp3

 

問題なさそうだ。

さ、volumeを有効化してみる。

 

[root@gluster-sv1 ~]# gluster volume start test-volume
Starting volume test-volume has been successful

 

それでは早速volumeアクセスしてみよう。

その為にはFUSE(Filesystem in Userspace)という仕組みを通じてクライアントはFilesystemにアクセスしなければならない。

User LANDなFUSEを使う分、当然オーバーヘッドは大きいが。

カーネルへの実装が不要な分だけ開発スピードを上げることが出来る。

将来的にはKernel module化されることを期待して、と。

 

それではFUSE moduleを呼び出してみよう。

 

[root@gluster-sv1 ~]# modprobe fuse

[root@gluster-sv1 ~]# lsmod | grep fuse
fuse                   66891  0

 

lsmodしてfuseが表示されればOK。

問題があるようであれば、fuseをyumでインストールしておこう。

とつらつら読んでいくと、ここでGlusterFSクライアントに必要なRPMの説明が出てきた。

 

6.1.1.1. Installing on RPM Based Distributions

 

によると

$ sudo rpm -i glusterfs-3.3.0-1.x86_64.rpm
$ sudo rpm -i glusterfs-fuse-3.3.0-1.x86_64.rpm
$ sudo rpm -i glusterfs-rdma-3.3.0-1.x86_64.rpm

と書いてある。が、予定通りrdmaは使わないので今回はそのままスルーする。

 

ではFUSE mountに進んでみよう。

 

6.1.2. Mounting Volumes

 

方法としてはmanually mountとautomatically mountがあるらしいが、当然、automatically mountを採用することにする。

automaticallu mountを使うには単にfstabに以下の記述をすればよいらしい。

ちなみに_netdevというmountオプションはnetworkが有効になった後にmountすることを保証するオプション。

GlusterFSは当然network必須なのでこのオプションを採用しているのだろう。

 

For example:

server1:/test-volume /mnt/glusterfs glusterfs defaults,_netdev 0 0

 

さて、ここで困ったことが。

上記、sampleにはNFSサーバのように

 

server1:/test-volume

 

とサーバ名を指定しなさい、とある。

当環境のglusterサーバは3台ある。

一体、どのサーバを指定すればよいのか・・・。

あと、そのサーバが落ちたらどうなるのか・・・。

と悩んでいたら、以下の補足があった。

 

Note

The server specified in the mount command is only used to fetch the gluster configuration volfile describing the volume name.

Subsequently, the client will communicate directly with the servers mentioned in the volfile (which might not even include the one used for mount).

 

サーバ名はgluster volfile設定を取り込むためだけに使いますよ。

その後はvolfileに書かれているサーバと直接お話ししますよ。

 

とある。

なので、ひとまずglusterdが生きている事が確実なサーバを書いておけばよさそうだ。

今回の場合、サーバとクライアントを兼ねるので、自分自身(localhost)を指定してみる。

まずは手動でmountしてみる。

 

[root@gluster-sv1 ~]# mkdir /mnt/gluster-test
[root@gluster-sv1 ~]# mount -t glusterfs gluster-sv1:/test-volume /mnt/gluster-test

 

mountできたようだ。

さて、読み書きしてみよう。

 

[root@gluster-sv1 gluster-test]# time tar czf lib.tar.gz /lib
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets

real    0m27.379s
user    0m15.472s
sys     0m1.760s
[root@gluster-sv1 gluster-test]# ls -al
total 64508
drwxr-xr-x. 4 root root     4096 Jul 27 15:59 .
drwxr-xr-x. 3 root root     4096 Jul 27 15:58 ..
-rw-r--r--. 1 root root 66024914 Jul 27 16:00 lib.tar.gz
drwx------. 2 root root    16384 Jul 27 12:46 lost+found

 

問題なく書き込みは出来た。

次にデータがreplicationされているかどうか各サーバのStorage Pool deviceを確認してみる。

 

[root@gluster-sv1 gluster-test]# ls -al /exp1/
total 64512
drwxr-xr-x.  4 root root     4096 Jul 27 15:59 .
dr-xr-xr-x. 24 root root     4096 Jul 27 12:48 ..
drw-------.  6 root root     4096 Jul 27 15:59 .glusterfs
-rw-r--r--.  2 root root 66024914 Jul 27 16:00 lib.tar.gz
drwx------.  2 root root    16384 Jul 27 12:45 lost+found

 

[root@gluster-sv2 ~]# ls -al /exp2/
total 64512
drwxr-xr-x.  4 root root     4096 Jul 27 15:59 .
dr-xr-xr-x. 24 root root     4096 Jul 27 12:47 ..
drw-------.  6 root root     4096 Jul 27 15:59 .glusterfs
-rw-r--r--.  2 root root 66024914 Jul 27 16:00 lib.tar.gz
drwx------.  2 root root    16384 Jul 27 12:46 lost+found

 

[root@gluster-sv3 exp3]# ls -al /exp3/
total 64512
drwxr-xr-x.  4 root root     4096 Jul 27 15:59 .
dr-xr-xr-x. 24 root root     4096 Jul 27 12:48 ..
drw-------.  6 root root     4096 Jul 27 15:59 .glusterfs
-rw-r--r--.  2 root root 66024914 Jul 27 16:00 lib.tar.gz
drwx------.  2 root root    16384 Jul 27 12:46 lost+found

 

と、綺麗にreplicationされていることが分かった。

次にマニュアルに従いfstabに記述を行い、自動的にmountさせるようにしてみよう。

サーバ名はgluster-sv1で行い、その他サーバに関してはoptionのサーバ名を変更して自分自身にアクセスさせるようにすればOK。

 

# vi /etc/fstab

gluster-sv1:/test-volume /mnt/gluster-test glusterfs defaults,_netdev 0 0

 

_netdevというオプションはGFSなどでも見られるが、networkが有効になってからmountしてね、というもの。

 

さきほどmountしたglusterfsをumountしてからfstab経由でmountし直してみる。

 

[root@gluster-sv1 mnt]# umount /mnt/gluster-test/
[root@gluster-sv1 mnt]# mount -a
unknown option _netdev (ignored)

 

dfコマンドの結果からもmountは出来たが、マニュアルに記述されている_netdevオプションを認識してくれないようだ。

man mountによると_netdevは確かに存在するoptionなのでFUSEの問題なのかもしれない。

ただ、これはすでに既知の問題の様だ。

 

gluster-users ML

Re: [Gluster-users] Issue recreating volumes

http://www.mail-archive.com/gluster-users@gluster.org/msg09005.html

> (2) Minor point: the FUSE client no longer seems to understand or need the
> "_netdev" option, however it still invokes it if you use "defaults" in
> /etc/fstab, and so you get a warning about an unknown option:
>
>      root@dev-storage1:~# grep gluster /etc/fstab
>      storage1:/safe /gluster/safe glusterfs defaults,nobootwait 0 0
>      storage1:/fast /gluster/fast glusterfs defaults,nobootwait 0 0
>
>      root@dev-storage1:~# mount /gluster/safe
>      unknown option _netdev (ignored)
>

Will look into this.

 

覗いてみるよ、とあるが、未だ具体的な回答はなされていないようだった。(2012/07/27時点)

 

次はauto self-healingがどのようなものか検証してみよう。