ストレージ · 3 min read · Jan 12, 2026
Debian SqueezeでのGlusterFS 3.0.xを使用した高可用性ストレージ - 2つのストレージサーバー間の自動ファイル複製
このチュートリアルでは、GlusterFSを使用した2つのストレージサーバー(Debian Squeeze)で高可用性ストレージを設定する方法を示します。各ストレージサーバーは他のストレージサーバーのミラーとなり、ファイルは両方のストレージサーバー間で自動的に複製されます。クライアントシステム(Debian Squeezeも同様)は、ストレージをローカルファイルシステムのようにアクセスできるようになります。GlusterFSは、数ペタバイトまでスケーリング可能なクラスターファイルシステムです。Infiniband RDMAまたはTCP/IPインターコネクトを介して、さまざまなストレージブリックを1つの大規模な並列ネットワークファイルシステムに集約します。ストレージブリックは、SATA-II RAIDおよびInfiniband HBAを備えたx86_64サーバーなどの一般的なハードウェアで構成できます。
私はこれがあなたにとって機能するという保証は一切行いません!
1 予備ノート
このチュートリアルでは、3つのシステム、2つのサーバーと1つのクライアントを使用します:
- server1.example.com: IPアドレス 192.168.0.100 (サーバー)
- server2.example.com: IPアドレス 192.168.0.101 (サーバー)
- client1.example.com: IPアドレス 192.168.0.102 (クライアント)
3つのシステムすべてが他のシステムのホスト名を解決できる必要があります。これがDNSを通じて行えない場合は、/etc/hostsファイルを編集して、すべての3つのシステムで次のように見えるようにする必要があります:
vi /etc/hosts| 127.0.0.1 localhost.localdomain localhost 192.168.0.100 server1.example.com server1 192.168.0.101 server2.example.com server2 192.168.0.102 client1.example.com client1 # IPv6対応ホストにとって望ましい行 ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts |
(以下の設定でホスト名の代わりにIPアドレスを使用することも可能です。IPアドレスを使用することを好む場合は、ホスト名が解決できるかどうかを気にする必要はありません。)
2 GlusterFSサーバーの設定
server1.example.com/server2.example.com:
GlusterFSはDebian Squeeze用のパッケージとして利用可能であるため、次のようにインストールできます:
apt-get install glusterfs-serverコマンド
glusterfs --versionは、今インストールしたGlusterFSのバージョン(この場合は3.0.5)を表示するはずです:
root@server1:~# glusterfs --version
glusterfs 3.0.5 built on Jul 13 2010 16:44:21
Repository revision: v3.0.5
Copyright (c) 2006-2009 Gluster Inc.
GlusterFSは完全に無保証です。
GNU一般公衆ライセンスの条件の下でGlusterFSのコピーを再配布できます。
root@server1:~# 次に、いくつかのディレクトリを作成します:
mkdir /data/
mkdir /data/export
mkdir /data/export-ns次に、GlusterFSサーバー設定ファイル/etc/glusterfs/glusterfsd.volを作成します(最初に元の/etc/glusterfs/glusterfsd.volファイルのバックアップを作成します)。このファイルでは、どのディレクトリがエクスポートされるか(/data/export)と、どのクライアントが接続を許可されるか(192.168.0.102 = client1.example.com)を定義します:
cp /etc/glusterfs/glusterfsd.vol /etc/glusterfs/glusterfsd.vol_orig
cat /dev/null > /etc/glusterfs/glusterfsd.vol
vi /etc/glusterfs/glusterfsd.vol| volume posix type storage/posix option directory /data/export end-volume volume locks type features/locks subvolumes posix end-volume volume brick type performance/io-threads option thread-count 8 subvolumes locks end-volume volume server type protocol/server option transport-type tcp option auth.addr.brick.allow 192.168.0.102 subvolumes brick end-volume |
IPアドレスにワイルドカード(192.168.*のような)を使用することが可能であり、カンマで区切って複数のIPアドレスを指定することもできることに注意してください(例:192.168.0.102,192.168.0.103)。
その後、GlusterFSサーバーを起動します:
/etc/init.d/glusterfs-server start3 GlusterFSクライアントの設定
client1.example.com:
クライアントでは、次のようにGlusterFSクライアントをインストールできます:
apt-get install glusterfs-client次に、次のディレクトリを作成します:
mkdir /mnt/glusterfs次に、ファイル/etc/glusterfs/glusterfs.volを作成します(最初に元の/etc/glusterfs/glusterfs.volファイルのバックアップを作成します):
cp /etc/glusterfs/glusterfs.vol /etc/glusterfs/glusterfs.vol_orig
cat /dev/null > /etc/glusterfs/glusterfs.vol
vi /etc/glusterfs/glusterfs.vol| volume remote1 type protocol/client option transport-type tcp option remote-host server1.example.com option remote-subvolume brick end-volume volume remote2 type protocol/client option transport-type tcp option remote-host server2.example.com option remote-subvolume brick end-volume volume replicate type cluster/replicate subvolumes remote1 remote2 end-volume volume writebehind type performance/write-behind option window-size 1MB subvolumes replicate end-volume volume cache type performance/io-cache option cache-size 512MB subvolumes writebehind end-volume |
remote-host行のオプションに正しいサーバーホスト名またはIPアドレスを使用していることを確認してください!
これで完了です!次に、次の2つのコマンドのいずれかを使用してGlusterFSファイルシステムを/mnt/glusterfsにマウントできます:
glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfsまたは
mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfsこれで、次の出力で新しい共有が表示されるはずです…
mountroot@client1:~# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
/etc/glusterfs/glusterfs.vol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)
root@client1:~#…と…
df -hroot@client1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 29G 778M 27G 3% /
tmpfs 249M 0 249M 0% /lib/init/rw
udev 244M 100K 244M 1% /dev
tmpfs 249M 0 249M 0% /dev/shm
/etc/glusterfs/glusterfs.vol
18G 848M 16G 5% /mnt/glusterfs
root@client1:~#( server1.example.comとserver2.example.comはそれぞれGlusterFSファイルシステム用に18GBのスペースを持っていますが、データがミラーリングされているため、クライアントは36GB(2 x 18GB)ではなく、18GBしか表示されません。)
クライアントでGlusterFS共有を手動でマウントする代わりに、/etc/fstabを修正して、クライアントが起動する際に共有が自動的にマウントされるようにすることができます。
/etc/fstabを開いて、次の行を追加します:
vi /etc/fstab| [...] /etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs defaults,_netdev 0 0 |
修正した/etc/fstabが機能しているかどうかをテストするために、クライアントを再起動します:
reboot再起動後、次の出力で共有が見つかるはずです…
df -h…と…
mount/etc/fstabの修正が役立たない場合は、/etc/fstabの変更を元に戻し、代わりにこの行を/etc/rc.localに追加します(exit 0行の前):
vi /etc/rc.local| [...] /bin/mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs [...] |
これにより、ネットワークが起動した後に共有がマウントされることが保証されます。
4 テスト
では、GlusterFS共有にテストファイルを作成してみましょう:
client1.example.com:
touch /mnt/glusterfs/test1
touch /mnt/glusterfs/test2次に、server1.example.comおよびserver2.example.comの/data/exportディレクトリを確認します。test1およびtest2ファイルは各ノードに存在するはずです:
server1.example.com/server2.example.com:
ls -l /data/exportroot@server1:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test1
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test2
root@server1:~#次に、server1.example.comをシャットダウンし、client1.example.comのGlusterFS共有にいくつかのファイルを追加/削除します。
server1.example.com:
shutdown -h nowclient1.example.com:
touch /mnt/glusterfs/test3
touch /mnt/glusterfs/test4
rm -f /mnt/glusterfs/test2変更はserver2.example.comの/data/exportディレクトリに表示されるはずです:
server2.example.com:
ls -l /data/exportroot@server2:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test1
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test3
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test4
root@server2:~#server1.example.comを再起動し、/data/exportディレクトリを確認してみましょう:
server1.example.com:
ls -l /data/exportroot@server1:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test1
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test2
root@server1:~#ご覧のとおり、server1.example.comはダウンしている間に発生した変更を認識していません。これは簡単に修正できます。必要なのは、client1.example.comのGlusterFS共有で読み取りコマンドを呼び出すことだけです。例えば:
client1.example.com:
ls -l /mnt/glusterfs/root@client1:~# ls -l /mnt/glusterfs/
total 8
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test1
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test3
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test4
root@client1:~#再度、server1.example.comの/data/exportディレクトリを確認してみてください。変更がそのノードに複製されているはずです:
server1.example.com:
ls -l /data/exportroot@server1:~# ls -l /data/export
total 8
-rw-r--r-- 1 root root 0 2012-03-29 14:51 test1
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test3
-rw-r--r-- 1 root root 0 2012-03-29 14:52 test4
root@server1:~#5 リンク
- GlusterFS: http://www.gluster.org/
- Debian: http://www.debian.org/
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。