ストレージ · 5 min read · Jan 10, 2026
Debian 8でのGlusterFSによる高可用性ストレージ - 2つのストレージサーバー間のミラー
このチュートリアルでは、GlusterFSを使用する2つのストレージサーバー(Debian Jessie)で高可用性ストレージを設定する方法を示します。各ストレージサーバーは他のストレージサーバーのミラーとなり、ファイルは自動的に両方のストレージノードに複製されます。クライアントシステム(Debian 8も同様)は、ローカルファイルシステムのようにストレージにアクセスできます。GlusterFSは、数ペタバイトにスケール可能なクラスタファイルシステムです。Infiniband RDMAまたはTCP/IPインターコネクトを介してさまざまなストレージブリックを1つの大規模な並列ネットワークファイルシステムに集約します。ストレージブリックは、SATA-II RAIDおよびInfiniband HBAを備えたx86_64サーバーなどの一般的なハードウェアで構成できます。
1 予備ノート
このチュートリアルでは、3つのシステム、2つのサーバーと1つのクライアントを使用します:
- server1.example.com: IPアドレス 192.168.1.100 (サーバー)
- server2.example.com: IPアドレス 192.168.1.101 (サーバー)
- client1.example.com: IPアドレス 192.168.1.102 (クライアント)
すべてのシステムは、他のシステムのホスト名を解決できる必要があります。これがDNSを介してできない場合は、/etc/hostsファイルを編集して、すべてのシステムで次のようにします:
nano /etc/hosts127.0.0.1 localhost
192.168.1.100 server1.example.com server1
192.168.1.101 server2.example.com server2
192.168.1.102 client1.example.com client1
# IPv6対応ホストに対しては以下の行が望ましい
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters(以下の設定ではホスト名の代わりにIPアドレスを使用することも可能です。IPアドレスを使用する場合は、ホスト名が解決できるかどうかを気にする必要はありません。)
2 GlusterFSサーバーの設定
server1.example.com/server2.example.com:
最新のGlusterFSバージョンは、gluster.orgからDebianパッケージとして入手できます。次のようにインストールできます:
両方のサーバーでgluster.org Debianリポジトリの公開鍵を追加します。
wget -O - http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.9/rsa.pub | apt-key add -次に、GlusterFSリポジトリを追加します(コマンドは1行です!)
echo deb http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.9/Debian/jessie/apt jessie main > /etc/apt/sources.list.d/gluster.listリポジトリリストを更新します。
apt-get updateこれで、aptを使用してGlusterFSサーバーソフトウェアをインストールできます。
apt-get -y install glusterfs-serverコマンド
glusterfsd --versionは、インストールしたばかりのGlusterFSバージョンを表示するはずです(この場合は3.7.9):
root@server1:/# glusterfsd --version
glusterfs 3.7.9 built on Mar 23 2016 05:24:49
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2013 Red Hat, Inc.
GlusterFS comes with ABSOLUTELY NO WARRANTY.
It is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3
or later), or the GNU General Public License, version 2 (GPLv2),
in all cases as published by the Free Software Foundation.
root@server1:/#ファイアウォールを使用している場合は、TCPポート111、24007、24008、24009-(24009 + ボリューム全体のブリック数)がserver1.example.comおよびserver2.example.comで開いていることを確認してください。
Glusterfsは、サーバーの/dataディレクトリにデータを保存します。この場所は、より小規模なインストールの場合は通常のディレクトリであるか、別のハードディスクパーティションを使用して/dataとしてマウントすることができます。
両方のサーバーで次を実行します:
mkdir /dataデータディレクトリを作成します。
次に、server2.example.comを信頼されたストレージプールに追加する必要があります(すべてのGlusterFS構成コマンドをserver1.example.comから実行していますが、server2.example.comからも実行できます。構成はGlusterFSノード間で複製されるため、正しいホスト名またはIPアドレスを使用することを確認してください):
server1.example.com:
server1.example.comで次を実行します。
gluster peer probe server2.example.comroot@server1:/# gluster peer probe server2.example.com
peer probe: success.
root@server1:/#信頼されたストレージプールのステータスは、次のようになります:
gluster peer statusroot@server1:/# gluster peer status
Number of Peers: 1Hostname: server2.example.com
Uuid: 0f7ee46c-6a71-4a31-91d9-6076707eff95
State: Peer in Cluster (Connected)
root@server1:/#次に、/data/testvolディレクトリに2つのレプリカを持つtestvolという名前の共有を作成します(この場合、レプリカの数はサーバーの数と等しいことに注意してください。ミラーリングを設定したいからです)。server1.example.comおよびserver2.example.comで次を実行します。
gluster volume create testvol replica 2 transport tcp server1.example.com:/data/testvol server2.example.com:/data/testvol forceroot@server1:/# gluster volume create testvol replica 2 transport tcp server1.example.com:/data/testvol server2.example.com:/data/testvol force
volume create: testvol: success: please start the volume to access data
root@server1:/#ボリュームを開始します:
gluster volume start testvolroot@server1:/# gluster volume start testvol
volume start: testvol: success
root@server1:/#テストボリュームは正常に開始されました。
上記のコマンドが成功しなかったと表示される場合があります:
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 *:49152 *:* LISTEN 8007/glusterfsd
tcp 0 0 server1.example.c:65533 server1.example.c:24007 ESTABLISHED 8007/glusterfsd
tcp 0 0 server1.example.c:49152 server2.example.c:65531 ESTABLISHED 8007/glusterfsd
tcp 0 0 server1.example.c:49152 server1.example.c:65532 ESTABLISHED 8007/glusterfsd
tcp 0 0 server1.example.c:49152 server1.example.c:65531 ESTABLISHED 8007/glusterfsd
tcp 0 0 server1.example.c:49152 server2.example.c:65526 ESTABLISHED 8007/glusterfsd
root@server1:/#…すべて正常ですが、出力が得られない場合…
root@server2:~# netstat -tap | grep glusterfsd
root@server2:~#…該当するサーバー(この場合はserver1.example.com)でGlusterFSデーモンを再起動します:
server2.example.com:
service glusterfs-server restart次に、そのサーバーで…
netstat -tap | grep glusterfsd…の出力を再確認します - 次のようになっているはずです:
root@server2:/# netstat -tap | grep glusterfsd
tcp 0 0 *:49152 *:* LISTEN 7852/glusterfsd
tcp 0 0 server2.example.c:49152 server2.example.c:65532 ESTABLISHED 7852/glusterfsd
tcp 0 0 server2.example.c:49152 server1.example.c:65526 ESTABLISHED 7852/glusterfsd
tcp 0 0 server2.example.c:49152 server2.example.c:65525 ESTABLISHED 7852/glusterfsd
tcp 0 0 server2.example.c:65533 server2.example.c:24007 ESTABLISHED 7852/glusterfsd
tcp 0 0 server2.example.c:49152 server1.example.c:65524 ESTABLISHED 7852/glusterfsd
root@server2:/#次にserver1.example.comに戻ります:
server1.example.com:
ボリュームのステータスを確認するには、次のコマンドを使用します。
gluster volume inforoot@server1:/# gluster volume infoVolume Name: testvol
Type: Replicate
Volume ID: 3fc9af57-ca56-4a72-ad54-3d2ea03e5883
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data/testvol
Brick2: server2.example.com:/data/testvol
Options Reconfigured:
performance.readdir-ahead: on
root@server1:/#デフォルトでは、すべてのクライアントがボリュームに接続できます。client1.example.com(= 192.168.1.102)のみへのアクセスを許可したい場合は、次を実行します:
gluster volume set testvol auth.allow 192.168.1.102root@server1:/# gluster volume set testvol auth.allow 192.168.1.102
volume set: success
root@server1:/#IPアドレスにワイルドカード(192.168.*のような)を使用することが可能であり、カンマで区切って複数のIPアドレスを指定することもできます(例:192.168.1.102,192.168.1.103)。
ボリューム情報は、更新されたステータスを表示するはずです:
gluster volume inforoot@server1:/# gluster volume info
Volume Name: testvol
Type: Replicate
Volume ID: 3fc9af57-ca56-4a72-ad54-3d2ea03e5883
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data/testvol
Brick2: server2.example.com:/data/testvol
Options Reconfigured:
auth.allow: 192.168.1.102
performance.readdir-ahead: on
root@server1:/#3 GlusterFSクライアントの設定
client1.example.com:
クライアントシステムでは、最初にgluster.org Debianリポジトリの公開鍵を追加します。
wget -O - http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.9/rsa.pub | apt-key add -次に、GlusterFSリポジトリを追加します(コマンドは1行です!)
echo deb http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.9/Debian/jessie/apt jessie main > /etc/apt/sources.list.d/gluster.listリポジトリリストを更新します。
apt-get update次に、次のようにGlusterFSクライアントをインストールできます。
apt-get -y install glusterfs-client次に、次のディレクトリを作成します:
mkdir /mnt/glusterfsこれで完了です!次のコマンドでGlusterFSファイルシステムを/mnt/glusterfsにマウントできます:
mount.glusterfs server1.example.com:/testvol /mnt/glusterfs(上記のコマンドではserver1.example.comの代わりにserver2.example.comを使用することもできます!)
次の出力で新しい共有が表示されるはずです:
mountroot@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=125556,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,relatime,size=204220k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (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)
root@client1:/#…および…
df -hroot@client1:/# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 57G 1.1G 53G 2% /
udev 10M 0 10M 0% /dev
tmpfs 200M 4.6M 195M 3% /run
tmpfs 499M 0 499M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 499M 0 499M 0% /sys/fs/cgroup
server1.example.com:/testvol 57G 21G 34G 39% /mnt/glusterfs
root@client1:/#クライアントでGlusterFS共有を手動でマウントする代わりに、/etc/fstabを変更して、クライアントの起動時に自動的にマウントされるようにすることができます。
/etc/fstabを開き、次の行を追加します:
nano /etc/fstab[...]
server1.example.com:/testvol /mnt/glusterfs glusterfs defaults,_netdev 0 0(再度、server1.example.comの代わりにserver2.example.comを使用することもできます!)
変更した/etc/fstabが機能するかテストするには、クライアントを再起動します:
reboot再起動後、次の出力で共有が見つかるはずです:
df -h…および…
mount4 GlusterFSレプリケーションのテスト
次に、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/testvolroot@server1:/# ls -l /data/testvol/
total 0
-rw-r--r-- 2 root root 0 Mar 23 2016 test1
-rw-r--r-- 2 root root 0 Mar 23 2016 test2次に、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/testvolディレクトリに表示されるはずです:
server2.example.com:
ls -l /data/testvolroot@server2:/# ls -l /data/testvol
total 8
-rw-r--r-- 2 root root 0 Mar 23 08:06 test1
-rw-r--r-- 2 root root 0 Mar 23 08:09 test3
-rw-r--r-- 2 root root 0 Mar 23 08:09 test4
root@server2:/#server1.example.comを再起動し、/dataディレクトリを確認します:
server1.example.com:
ls -l /data/testvolroot@server1:/# ls -l /data/testvol
total 0
-rw-r--r-- 2 root root 0 Mar 23 08:06 test1
-rw-r--r-- 2 root root 0 Mar 23 08:09 test3
-rw-r--r-- 2 root root 0 Mar 23 08:09 test4
root@server1:/#ご覧のとおり、server1.example.comは自動的に変更を同期しました。変更がまだ同期されていない場合は、クライアント1.example.comのGlusterFS共有で読み取りコマンドを実行するだけで簡単に修正できます。例えば:
client1.example.com:
ls -l /mnt/glusterfs/root@client1:/# ls -l /mnt/glusterfs/
total 0
-rw-r--r-- 1 root root 0 Mar 23 08:06 test1
-rw-r--r-- 1 root root 0 Mar 23 08:09 test3
-rw-r--r-- 1 root root 0 Mar 23 08:09 test4
root@client1:/#5 リンク
- GlusterFS: http://www.gluster.org/
- GlusterFSドキュメント: http://gluster.readthedocs.org/en/latest/
- Debian: http://www.debian.org/
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。