GNU/Linux >> Linux の 問題 >  >> Ubuntu

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

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

このチュートリアルのすべてのステップをroot権限で実行するため、このチュートリアルのすべてのコマンドの前に文字列sudoを付けるか、「

」と入力して今すぐrootになります。
sudo su

3つのシステムすべてが、他のシステムのホスト名を解決できる必要があります。 DNSを介してこれを実行できない場合は、3つのシステムすべてで次のようになるように/ 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

# The following lines are desirable for IPv6 capable hosts
::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アドレスを使用する場合は、ホスト名を解決できるかどうかを気にする必要はありません。)

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

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

GlusterFSはUbuntu12.10のパッケージとして利用できるため、次のようにインストールできます。

apt-get install glusterfs-server

コマンド

glusterfsd --version

インストールしたばかりのGlusterFSバージョン(この場合は3.2.5)が表示されます:

[email protected]:~# glusterfsd --version
glusterfs 3.2.5 built on Jan 31 2012 07:39:58
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc. <http://www.gluster.com>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
[email protected]:~#

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

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

server1.example.com:

server1.example.comで、

を実行します
gluster peer probe server2.example.com
[email protected]:~# gluster peer probe server2.example.com
Probe successful
[email protected]:~#

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

gluster peer status
[email protected]:~# gluster peer status
Number of Peers: 1
Hostname: server2.example.com
Uuid: 7cd93007-fccb-4fcb-8063-133e6ba81cd9
State: Peer in Cluster (Connected)
[email protected]:~#

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

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

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

gluster volume start testvol

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

[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 *:24009                 *:*                     LISTEN      1548/glusterfsd
tcp        0      0 localhost.localdom:1019 localhost.localdo:24007 ESTABLISHED 1548/glusterfsd
[email protected]:~#

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

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

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

server2.example.com:

/etc/init.d/glusterfs-server restart

次に、...

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

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

[email protected]:~# netstat -tap | grep glusterfsd
tcp        0      0 *:24010                 *:*                     LISTEN      1458/glusterfsd
tcp        0      0 localhost.localdom:1021 localhost.localdo:24007 ESTABLISHED 1458/glusterfsd
[email protected]:~#

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

server1.example.com:

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

gluster volume info
[email protected]:~# 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
[email protected]:~#

デフォルトでは、すべてのクライアントがボリュームに接続できます。 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
[email protected]:~# 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
[email protected]:~#

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

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
[email protected]:~# mount
/dev/mapper/server3-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
server1.example.com:/testvol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)
[email protected]:~#

...そして...

df -h
[email protected]:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/server3-root
                       29G  1.1G   27G   4% /
udev                  238M  4.0K  238M   1% /dev
tmpfs                  99M  212K   99M   1% /run
none                  5.0M     0  5.0M   0% /run/lock
none                  247M     0  247M   0% /run/shm
/dev/sda1             228M   24M  193M  11% /boot
server1.example.com:/testvol
                       29G  1.1G   27G   4% /mnt/glusterfs
[email protected]:~#

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
[email protected]:~# ls -l /data
total 8
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test1
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test2
[email protected]:~#

ここで、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
[email protected]:~# ls -l /data
total 8
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test1
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test3
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test4
[email protected]:~#

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

server1.example.com:

ls -l /data
[email protected]:~# ls -l /data
total 8
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test1
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test2
[email protected]:~#

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

client1.example.com:

ls -l /mnt/glusterfs/
[email protected]:~# ls -l /mnt/glusterfs/
total 8
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test1
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test3
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test4
[email protected]:~#

ここで、server1.example.comの/ dataディレクトリをもう一度見てください。変更がそのノードに複製されていることがわかります:

server1.example.com:

ls -l /data
[email protected]:~# ls -l /data
total 4
-rw-r--r-- 1 root root 0 2012-12-17 11:17 test1
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test3
-rw-r--r-- 1 root root 0 2012-12-17 11:38 test4
[email protected]:~#

  • GlusterFS:http://www.gluster.org/
  • GlusterFS 3.2ドキュメント:http://download.gluster.com/pub/gluster/glusterfs/3.2/Documentation/AG/html/index.html
  • Ubuntu:http://www.ubuntu.com/

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

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

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

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

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

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

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

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

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