GNU/Linux >> Linux の 問題 >  >> Debian

Debian8上のGlusterFSを使用した高可用性ストレージ-2つのストレージサーバー間でミラーリング

このチュートリアルでは、GlusterFSを使用する2つのストレージサーバー(Debian Jessie)を使用して高可用性ストレージを設定する方法を示します。各ストレージサーバーは他のストレージサーバーのミラーになり、ファイルは両方のストレージノードに自動的に複製されます。クライアントシステム(Debian 8も同様)は、ローカルファイルシステムであるかのようにストレージにアクセスできます。 GlusterFSは、数ペタバイトに拡張できるクラスター化されたファイルシステムです。 InfinibandRDMAまたはTCP/IP相互接続を介してさまざまなストレージブリックを1つの大規模な並列ネットワークファイルシステムに集約します。ストレージブリックは、SATA-IIRAIDおよびInfinibandHBAを備えた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(クライアント)

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

nano /etc/hosts
127.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


# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

(次の設定では、ホスト名の代わりにIPアドレスを使用することもできます。IPアドレスを使用する場合は、ホスト名を解決できるかどうかを気にする必要はありません。)

2GlusterFSサーバーのセットアップ

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

最新のGlusterFSバージョンは、gluster.orgからDebianパッケージとして入手できます。次のようにインストールできます:

両方のサーバーにgluster.orgDebianリポジトリの公開鍵を追加します。

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)が表示されます:

[email protected]:/# 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. <http://www.redhat.com/>
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.
[email protected]:/#

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

Glusterfsは、そのデータをサーバー上のディレクトリ/dataに格納する必要があります。インストールが小さい場合、または別のハードディスクパーティションを使用して/dataとしてマウントする場合は、この場所を通常のディレクトリにすることができます。

両方のサーバーで実行:

mkdir /data

データディレクトリを作成します。

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

server1.example.com:

server1.example.comで、

を実行します
gluster peer probe server2.example.com
[email protected]:/# gluster peer probe server2.example.com
peer probe: success.
[email protected]:/#

これで、信頼できるストレージプールのステータスは次のようになります。

gluster peer status
[email protected]:/# gluster peer status
Number of Peers: 1
Hostname: server2.example.com
Uuid: 0f7ee46c-6a71-4a31-91d9-6076707eff95
State: Peer in Cluster (Connected)
[email protected]:/#

次に、2つのレプリカを持つtestvolという名前の共有を作成します(この場合、ミラーリングを設定するため、レプリカの数はサーバーの数と同じであることに注意してください)。 / data / testvolディレクトリ(存在しない場合は作成されます):

gluster volume create testvol replica 2 transport tcp server1.example.com:/data/testvol server2.example.com:/data/testvol force
[email protected]:/# 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
[email protected]:/#

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

gluster volume start testvol
[email protected]:/# gluster volume start testvol
volume start: testvol: success
[email protected]:/#

テストボリュームは正常に開始されました。

上記のコマンドは、アクションが成功しなかったことを示している可能性があります:

[email protected]:~# gluster volume start testvol
Starting volume testvol has been unsuccessful
[email protected]:~#

この場合、次の出力を確認する必要があります...

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

netstat -tap | grep glusterfsd

両方のサーバーで。

このような出力が得られたら...

[email protected]:/# 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
[email protected]:/#

...すべて問題ありませんが、出力が得られない場合は...

[email protected]:~# netstat -tap | grep glusterfsd
[email protected]:~#

...対応するサーバー(この場合はserver1.example.com)でGlusterFSデーモンを再起動します:

server2.example.com:

service glusterfs-server restart

次に、...

の出力を確認します
netstat -tap | grep glusterfsd

...再びそのサーバー上で-これで次のようになります:

[email protected]:/# 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
[email protected]:/#

ここでserver1.example.comに戻ります:

server1.example.com:

コマンドでボリュームのステータスを確認できます

gluster volume info
[email protected]:/# 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:
performance.readdir-ahead: on
[email protected]:/#

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

gluster volume set testvol auth.allow 192.168.1.102
[email protected]:/# gluster volume set testvol auth.allow 192.168.1.102
volume set: success
[email protected]:/#

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

ボリューム情報に更新されたステータスが表示されます:

gluster volume info

[メール保護]:/#glusterボリューム情報

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
[email protected]:/#

3GlusterFSクライアントのセットアップ

client1.example.com:

クライアントシステムでは、最初にgluster.orgDebianリポジトリの公開鍵を追加します。

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を使用することもできます!)

これで、出力に新しいシェアが表示されるはずです...

mount
[email protected]:/# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev 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)
[email protected]:/#

...そして...

df -h
[email protected]:/# 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
[email protected]:/#

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

...そして...

mount

4GlusterFSレプリケーションのテスト

それでは、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/testvol
[email protected]:/# 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 now

client1.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/testvol
[email protected]:/# 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
[email protected]:/#

server1.example.comをもう一度起動して、/dataディレクトリを見てみましょう。

server1.example.com:

ls -l /data/testvol
[email protected]:/# 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
[email protected]:/#

ご覧のとおり、server1.example.comは変更内容を自動的に同期しました。変更がまだ同期されていない場合、これは簡単に修正できます。必要なのは、client1.example.comのGlusterFS共有で読み取りコマンドを呼び出すことだけです。例:

client1.example.com:

ls -l /mnt/glusterfs/
[email protected]:/# 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
[email protected]:/#

  • GlusterFS:http://www.gluster.org/
  • GlusterFSドキュメント:http://gluster.readthedocs.org/en/latest/
  • Debian:http://www.debian.org/

Debian
  1. CentOS7上のGlusterFSを使用した高可用性ストレージ-2つのストレージサーバー間でミラーリング

  2. Ubuntu12.10上のGlusterFS3.2.xを使用した4つのストレージノードにまたがる分散ストレージ

  3. Ubuntu12.10上のGlusterFS3.2.xを使用した4つのストレージノードに分散されたレプリケートされたストレージ

  1. Ubuntu12.10のGlusterFS3.2.xを使用した4つのストレージノード間のストライピング

  2. Ubuntu12.10上のGlusterFS3.2.xを使用した2つのストレージサーバー間での自動ファイルレプリケーション(ミラーリング)

  3. DebianLennyでのGlusterFSによる高可用性ストレージ-2つのストレージサーバー間での自動ファイルレプリケーション

  1. DebianLenny上のGlusterFSを使用した4つのストレージノードにまたがる分散ストレージ

  2. DebianLenny上のGlusterFSを使用した4つのストレージノードに分散されたレプリケートされたストレージ

  3. DebianLenny上のGlusterFSを使用した4つのストレージノード間のストライピング