ストレージ · 4 min read · Jan 10, 2026

Debian Wheezy上のGlusterFS 3.2.xを使用した高可用性ストレージ - 2つのストレージサーバー間の自動ファイルレプリケーション(ミラー)

このチュートリアルでは、GlusterFSを使用した2つのストレージサーバー(Debian Wheezy)で高可用性ストレージを設定する方法を示します。各ストレージサーバーは他のストレージサーバーのミラーとなり、ファイルは両方のストレージサーバー間で自動的にレプリケートされます。クライアントシステム(Debian Wheezyも)は、ローカルファイルシステムのようにストレージにアクセスできます。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 (クライアント)

すべてのシステムは、他のシステムのホスト名を解決できる必要があります。これがDNSを介して行えない場合は、/etc/hostsファイルを編集して、すべてのシステムで次のように見えるようにしてください:

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 Wheezy用のパッケージとして利用可能であるため、次のようにインストールできます:

apt-get install glusterfs-server

コマンド

glusterfsd --version

は、今インストールしたGlusterFSのバージョン(この場合は3.2.7)を表示するはずです:

root@server1:~# glusterfsd --version  
glusterfs 3.2.7 built on Nov 12 2012 19:30:08  
Repository revision: git://git.gluster.com/glusterfs.git  
Copyright (c) 2006-2011 Gluster Inc.   
GlusterFS comes with ABSOLUTELY NO WARRANTY.  
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.  
root@server1:~#

ファイアウォールを使用している場合は、TCPポート111、24007、24008、24009-(すべてのボリュームにわたるブリックの数)がserver1.example.comおよびserver2.example.comで開いていることを確認してください。

次に、server2.example.comを信頼されたストレージプールに追加する必要があります(すべてのGlusterFS構成コマンドをserver1.example.comから実行していますが、server2.example.comからも実行できます。構成はGlusterFSノード間でレプリケートされるためです - 正しいホスト名またはIPアドレスを使用していることを確認してください):

server1.example.com:

server1.example.comで、次を実行します。

gluster peer probe server2.example.com
root@server1:~# gluster peer probe server2.example.com  
Probe successful  
root@server1:~#

信頼されたストレージプールの状態は、次のようになります:

gluster peer status
root@server1:~# gluster peer status  
Number of Peers: 1
Hostname: server2.example.com  
Uuid: d19cb707-7b23-4d11-8e9c-183cd0a18d96  
State: Peer in Cluster (Connected)  
root@server1:~#

次に、server1.example.comおよびserver2.example.comの/dataディレクトリに2つのレプリカを持つtestvolという名前の共有を作成します(この場合、ミラーリングを設定したいので、レプリカの数はサーバーの数と等しいことに注意してください):

gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data
root@server1:~# gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data  
Creation of volume testvol has been successful. Please start the volume to access data.  
root@server1:~#

ボリュームを開始します:

gluster volume start testvol

上記のコマンドが成功しなかったと表示される可能性があります:

root@server1:~# gluster volume start testvol  
Starting volume testvol has been unsuccessful  
root@server1:~#

この場合、次の出力を確認してください…

server1.example.com/server2.example.com:

netstat -tap | grep glusterfsd

両方のサーバーで出力が次のようであれば…

root@server1:~# netstat -tap | grep glusterfsd  
tcp        0      0 *:24009                 *:*                     LISTEN      1548/glusterfsd  
tcp        0      0 localhost.localdom:1019 localhost.localdo:24007 ESTABLISHED 1548/glusterfsd  
root@server1:~#

…すべてが正常ですが、出力が得られない場合…

root@server2:~# netstat -tap | grep glusterfsd  
root@server2:~#

…該当するサーバー(この場合はserver2.example.com)でGlusterFSデーモンを再起動します:

server2.example.com:

/etc/init.d/glusterfs-server restart

次に、そのサーバーで…

netstat -tap | grep glusterfsd

…の出力を再確認してください - これで次のようになるはずです:

root@server2:~# netstat -tap | grep glusterfsd  
tcp        0      0 *:24010                 *:*                     LISTEN      1458/glusterfsd  
tcp        0      0 localhost.localdom:1021 localhost.localdo:24007 ESTABLISHED 1458/glusterfsd  
root@server2:~#

次にserver1.example.comに戻ります:

server1.example.com:

ボリュームの状態を確認するには、次のコマンドを使用します。

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol  
Type: Replicate  
Status: Started  
Number of Bricks: 2  
Transport-type: tcp  
Bricks:  
Brick1: server1.example.com:/data  
Brick2: server2.example.com:/data  
root@server1:~#

デフォルトでは、すべてのクライアントがボリュームに接続できます。client1.example.com(= 192.168.0.102)にのみアクセスを許可したい場合は、次を実行します:

gluster volume set testvol auth.allow 192.168.0.102

IPアドレスにワイルドカード(192.168.*のような)を使用することが可能であり、カンマで区切って複数のIPアドレスを指定することもできることに注意してください(例:192.168.0.102,192.168.0.103)。

ボリューム情報は、更新された状態を表示するはずです:

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol  
Type: Replicate  
Status: Started  
Number of Bricks: 2  
Transport-type: tcp  
Bricks:  
Brick1: server1.example.com:/data  
Brick2: server2.example.com:/data  
Options Reconfigured:  
auth.allow: 192.168.0.102  
root@server1:~#

3 GlusterFSクライアントの設定

client1.example.com:

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

apt-get install glusterfs-client

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

mkdir /mnt/glusterfs

それでおしまい!次のコマンドでGlusterFSファイルシステムを/mnt/glusterfsにマウントできます:

mount.glusterfs server1.example.com:/testvol /mnt/glusterfs

(server1.example.comの代わりにserver2.example.comを使用することもできます!)

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

mount
root@client1:~# mount  
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)  
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)  
odev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=126813,mode=755)  
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)  
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=102704k,mode=755)  
/dev/mapper/server1-root on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)  
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)  
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=205400k)  
/dev/sda1 on /boot type ext2 (rw,relatime,errors=continue)  
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)  
server1.example.com:/testvol on /mnt/glusterfs type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)  
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)  
root@client1:~#

…と…

df -h
root@client1:~# df -h  
Filesystem                Size  Used Avail Use% Mounted on  
rootfs                     29G  1.2G   26G   5% /  
udev                      10M     0   10M   0% /dev  
tmpfs                     101M  240K  101M   1% /run  
/dev/mapper/server1-root     29G  1.2G   26G   5% /  
tmpfs                     5.0M     0  5.0M   0% /run/lock  
tmpfs                     201M     0  201M   0% /run/shm  
/dev/sda1                 228M   18M  199M   9% /boot  
server1.example.com:/testvol   29G  1.2G   26G   5% /mnt/glusterfs  
root@client1:~#

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

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

vi /etc/fstab

| [...] server1.example.com:/testvol /mnt/glusterfs glusterfs defaults,_netdev 0 0 |

(再度、server1.example.comの代わりにserver2.example.comを使用することもできます!)

修正した/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ディレクトリを確認しましょう。test1およびtest2ファイルは各ノードに存在するはずです:

server1.example.com/server2.example.com:

ls -l /data
root@server1:~# ls -l /data  
total 0  
-rw-r--r-- 1 root root 0 Sep 30 17:53 test1  
-rw-r--r-- 1 root root 0 Sep 30 17:53 test2  
root@server1:~#

次に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ディレクトリに表示されるはずです:

server2.example.com:

ls -l /data
root@server2:~# ls -l /data  
total 8  
-rw-r--r-- 1 root root 0 Sep 30 17:53 test1  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test3  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test4  
root@server2:~#

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

server1.example.com:

ls -l /data
root@server1:~# ls -l /data  
total 0  
-rw-r--r-- 1 root root 0 Sep 30 17:53 test1  
-rw-r--r-- 1 root root 0 Sep 30 17:53 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 Sep 30 17:53 test1  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test3  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test4  
root@client1:~#

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

server1.example.com:

ls -l /data
root@server1:~# ls -l /data  
total 0  
-rw-r--r-- 1 root root 0 Sep 30 17:53 test1  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test3  
-rw-r--r-- 1 root root 0 Sep 30 17:54 test4  
root@server1:~#

5 リンク

Share: X/Twitter LinkedIn

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

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