ストレージ · 2 min read · Feb 06, 2026

Mandriva 2010.0 における GlusterFS を使用した高可用性ストレージ - 2 台のストレージサーバー間の自動ファイル複製

3 GlusterFS クライアントの設定

client1.example.com:

クライアントに GlusterFS クライアントを次のようにインストールできます:

urpmi glusterfs-client glusterfs-server

次に、次のディレクトリを作成します:

mkdir /mnt/glusterfs

次に、ファイル /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

これで、次の出力に新しい共有が表示されるはずです…

mount
[root@client1 administrator]# mount  
/dev/sda1 on / type ext4 (rw,relatime)  
none on /proc type proc (rw)  
/dev/sda6 on /home type ext4 (rw,relatime)  
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)  
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)  
nfsd on /proc/fs/nfsd type nfsd (rw)  
/etc/glusterfs/glusterfs.vol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)  
[root@client1 administrator]#

… と …

df -h
[root@client1 administrator]# df -h  
Filesystem            Size  Used Avail Use% Mounted on  
/dev/sda1              12G  1.5G  9.8G  13% /  
/dev/sda6              16G  172M   16G   2% /home  
/etc/glusterfs/glusterfs.vol  
                       29G  1.7G   26G   6% /mnt/glusterfs  
[root@client1 administrator]#

( server1.example.com と server2.example.com はそれぞれ GlusterFS ファイルシステム用に 29GB のスペースを持っていますが、データがミラーリングされているため、クライアントは 58GB (2 x 29GB) ではなく、29GB のみを認識します。)

クライアントで GlusterFS 共有を手動でマウントする代わりに、/etc/fstab を修正して、クライアントが起動するときに共有が自動的にマウントされるようにすることができます。

/etc/fstab を開いて、次の行を追加します:

vi /etc/fstab

| [...] /etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs defaults 0 0 |

修正した /etc/fstab が機能しているかどうかをテストするには、クライアントを再起動します:

reboot

再起動後、次の出力に共有が表示されるはずです…

df -h

… と …

mount

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/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test2  
[root@server1 administrator]#

次に、server1.example.com をシャットダウンし、client1.example.com の GlusterFS 共有にいくつかのファイルを追加/削除します。

server1.example.com:

shutdown -h now

client1.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/export
[root@server2 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@server2 administrator]#

server1.example.com を再起動し、/data/export ディレクトリを確認してみましょう:

server1.example.com:

ls -l /data/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test2  
[root@server1 administrator]#

ご覧のとおり、server1.example.com はダウンしている間に発生した変更に気づいていません。これを修正するのは簡単で、client1.example.com の GlusterFS 共有で読み取りコマンドを呼び出すだけで済みます。例えば:

client1.example.com:

ls -l /mnt/glusterfs/
[root@client1 administrator]# ls -l /mnt/glusterfs/  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@client1 administrator]#

再度、server1.example.com の /data/export ディレクトリを確認してみてください。変更がそのノードに複製されているはずです:

server1.example.com:

ls -l /data/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@server1 administrator]#

5 リンク

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。