このチュートリアルでは、4つの単一ストレージサーバー(CentOS 6.3を実行)をGlusterFSを使用して分散レプリケートストレージに結合する方法を示します。ノード1と2(replication1)および3と4(replication2)は相互にミラーリングし、replication1とreplication2は1つの大きなストレージサーバー(ディストリビューション)に結合されます。基本的に、これはネットワーク上のRAID10です。replication1から1台、replication2から1台のサーバーを失っても、分散ボリュームは引き続き機能します。クライアントシステム(CentOS 6.3も)は、ローカルファイルシステムであるかのようにストレージにアクセスできます。GlusterFSは、数ペタバイトに拡張できるクラスター化されたファイルシステムです。 InfinibandRDMAまたはTCP/IP相互接続を介してさまざまなストレージブリックを1つの大規模な並列ネットワークファイルシステムに集約します。ストレージブリックは、SATA-IIRAIDおよびInfinibandHBAを備えたx86_64サーバーなどの任意のコモディティハードウェアで作成できます。
これがあなたのために働くという保証はありません!
1予備メモ
このチュートリアルでは、5つのシステム、4つのサーバー、およびクライアントを使用します。
- server1.example.com:IPアドレス192.168.0.100(サーバー)
- server2.example.com:IPアドレス192.168.0.101(サーバー)
- server3.example.com:IPアドレス192.168.0.102(サーバー)
- server4.example.com:IPアドレス192.168.0.103(サーバー)
- client1.example.com:IPアドレス192.168.0.104(クライアント)
5つのシステムすべてが、他のシステムのホスト名を解決できる必要があります。 DNSを介してこれを実行できない場合は、5つのシステムすべてで次のようになるように/ etc/hostsファイルを編集する必要があります。
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 192.168.0.100 server1.example.com server1 192.168.0.101 server2.example.com server2 192.168.0.102 server3.example.com server3 192.168.0.103 server4.example.com server4 192.168.0.104 client1.example.com client1 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 |
(次の設定では、ホスト名の代わりにIPアドレスを使用することもできます。IPアドレスを使用する場合は、ホスト名を解決できるかどうかを気にする必要はありません。)
2追加のリポジトリを有効にする
server1.example.com/server2.example.com/server3.example.com/server4.example.com/client1.example.com:
まず、ソフトウェアパッケージのGPGキーをインポートします:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
次に、CentOSシステムでEPEL6リポジトリを有効にします。
rpm --import https://fedoraproject.org/static/0608B895.txt
cd / tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
rpm -ivh epel-release-6- 7.noarch.rpm
yum install yum-priorities
/etc/yum.repos.d/epel.repoを編集します...
vi /etc/yum.repos.d/epel.repo
...そして[epel]セクションにpriority=10という行を追加します:
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 priority=10 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [...] |
3GlusterFSサーバーのセットアップ
server1.example.com/server2.example.com/server3.example.com/server4.example.com:
GlusterFSはEPELのパッケージとして利用できるため、次のようにインストールできます。
yum install glusterfs-server
Glusterデーモンのシステム起動リンクを作成して起動します:
chkconfig --levels 235 glusterd on
/etc/init.d/glusterd start
コマンド
glusterfsd --version
インストールしたばかりのGlusterFSバージョン(この場合は3.2.7)が表示されます:
[[メール保護]〜]#glusterfsd --version
glusterfs3.2.7ビルド日2012年6月11日13:22:28
リポジトリリビジョン:git://git.gluster.com/glusterfs.git
Copyright(c)2006-2011 Gluster Inc.
GlusterFSには、まったく保証がありません。
GlusterFSのコピーは、次の条件で再配布できます。 GNU General PublicLicense。
[[メール保護]〜]#
ファイアウォールを使用する場合は、TCPポート111、24007、24008、24009-(24009 +すべてのボリュームにわたるブリックの数)がserver1.example.com、server2.example.com、server3.example.com、およびserver4.example.com。
次に、server2.example.com、server3.example.com、server4.example.comを信頼できるストレージプールに追加する必要があります(server1.example.comからすべてのGlusterFS構成コマンドを実行していることに注意してください。ただし、次のようにすることもできます。構成はGlusterFSノード間で複製されるため、server2.example.com、server3.example.com、またはserver4.example.comから実行してください。正しいホスト名またはIPアドレスを使用していることを確認してください):
server1.example.com:
server1.example.comで、
を実行します
glusterピアプローブserver2.example.com
glusterピアプローブserver3.example.com
glusterピアプローブserver4.example.com
出力は次のようになります。
[[メール保護]〜]#glusterピアプローブserver2.example.com
プローブが成功しました
[[メール保護]〜]#
これで、信頼できるストレージプールのステータスは次のようになります。
gluster peer status
[[メール保護]〜]#glusterピアステータス
ピア数:3
ホスト名:server2.example.com
Uuid:600ff607-f7fd-43f6-af8d-419df703376d
状態:クラスター内のピア(接続済み)
ホスト名:server3.example.com
Uuid:1d6a5f3f-c2dd-4727-a050-0431772cc381
状態:クラスター内のピア(接続済み)
ホスト名:server4.example.com
Uuid:0bd9d445-0b5b-4a91-be6f-02b13c41d5d6
状態:クラスター内のピア(接続済み)
[[メール保護]〜]#
次に、server1.example.com、server2.example.comに、2つのレプリカを持つtestvolという名前の分散複製共有を作成します(この場合、分散複製を設定するため、レプリカの数はサーバーの数の半分であることに注意してください)。 / dataディレクトリ内の、server3.example.com、およびserver4.example.com(これは、存在しない場合に作成されます):
gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data server3.example.com:/data server4.example.com:/data
[[メール保護]〜]#gluster volume create testvol Replica 2 transport tcp server1.example.com:/data server2.example.com:/data server3.example.com:/data server4.example.com:/data
ボリュームtestvolの作成に成功しました。ボリュームを起動してデータにアクセスしてください。
[[メール保護]〜]#
ボリュームを開始します:
gluster volume start testvol
上記のコマンドは、アクションが成功しなかったことを示している可能性があります:
[[メール保護]〜]#gluster volume start testvol
ボリュームtestvolの開始に失敗しました
[[メール保護]〜]#
この場合、次の出力を確認する必要があります...
server1.example.com/server2.example.com/server3.example.com/server4.example.com:
netstat -tap | grep glusterfsd
両方のサーバーで。
このような出力が得られたら...
[[メール保護]〜]#netstat -tap | grepのglusterfsd
TCP 0 0 *:24009 *:* LISTEN 1365 / glusterfsd
TCP 0 0はlocalhost:1023 localhostを:24007 ESTABLISHED 1365 / glusterfsd
TCP 0 0 server1.example.com:24009 server1.example.com:1023 ESTABLISHED 1365 / glusterfsd
[[email protected]〜]#
...すべて問題ありませんが、出力が得られない場合は...
[[メール保護]〜]#netstat -tap | grep glusterfsd
[[メール保護]〜]#
[[メール保護]〜]#netstat -tap | grep glusterfsd
[[メール保護]〜]#
[[メール保護]〜]#netstat -tap | grep glusterfsd
[[メール保護]〜]#
...対応するサーバー(この場合はserver2.example.com、server3.example.com、server4.example.com)でGlusterFSデーモンを再起動します。
server2.example.com/server3.example.com/server4.example.com:
/etc/init.d/glusterfsd restart
次に、...
の出力を確認しますnetstat -tap | grep glusterfsd
...これらのサーバーでも-次のようになります:
[[メール保護]〜]#netstat -tap | grepのglusterfsd
TCP 0 0 *:24009 *:* LISTEN 1152 / glusterfsd
TCP 0 0 localhost.localdom:1018 localhost.localdo:24007 ESTABLISHED 1152 / glusterfsd
[[電子メール〜]保護]#
[[メール保護]〜]#netstat -tap | grepのglusterfsd
TCP 0 0 *:24009 *:* LISTEN 1311 / glusterfsd
TCP 0 0 localhost.localdom:1018 localhost.localdo:24007 ESTABLISHED 1311 / glusterfsd
[[電子メール〜]保護]#
[[メール保護]〜]#netstat -tap | grepのglusterfsd
TCP 0 0 *:24009 *:* LISTEN 1297 / glusterfsd
TCP 0 0 localhost.localdom:1019 localhost.localdo:24007 ESTABLISHED 1297 / glusterfsd
[[電子メール〜]保護]#
ここでserver1.example.comに戻ります:
server1.example.com:
コマンド
を使用して、ボリュームのステータスを確認できます。gluster volume info
[[email protected] ~]# gluster volume info
ボリューム名:testvol
タイプ:分散-複製
ステータス:開始
レンガの数:2 x 2 =4
トランスポートタイプ:tcp
レンガ:
Brick1:server1.example.com:/ data
Brick2:server2.example.com:/ data
Brick3:server3.example.com:/data
Brick4:server4.example。 com:/ data
[[email protected]〜]#
デフォルトでは、すべてのクライアントがボリュームに接続できます。 client1.example.com(=192.168.0.104)のみへのアクセスを許可する場合は、次を実行します。
gluster volume set testvol auth.allow 192.168.0.104
IPアドレスにワイルドカードを使用することが可能であり(192.168. *など)、コンマで区切って複数のIPアドレスを指定できることに注意してください(例:192.168.0.104,192.168.0.105)。
ボリューム情報に更新されたステータスが表示されます:
gluster volume info
[[email protected] ~]# gluster volume info
ボリューム名:testvol
タイプ:分散-複製
ステータス:開始
レンガの数:2 x 2 =4
トランスポートタイプ:tcp
レンガ:
Brick1:server1.example.com:/ data
Brick2:server2.example.com:/ data
Brick3:server3.example.com:/data
Brick4:server4.example。 com:/ data
再構成されたオプション:
auth.allow:192.168.0.104
[[email protected]〜]#
4GlusterFSクライアントのセットアップ
client1.example.com:
クライアントでは、次のようにGlusterFSクライアントをインストールできます。
yum install glusterfs-client
次に、次のディレクトリを作成します。
mkdir /mnt/glusterfs
それでおしまい!これで、次のコマンドを使用してGlusterFSファイルシステムを/ mnt/glusterfsにマウントできます。
mount.glusterfs server1.example.com:/testvol /mnt/glusterfs
(server1.example.comの代わりに、上記のコマンドでserver2.example.com、server3.example.com、server4.example.comを使用することもできます!)
これで、出力に新しいシェアが表示されるはずです...
mount
[[メール保護]〜]#mount
/ dev / mapper / vg_client1-LogVol00 on / type ext4(rw)
proc on / proc type proc(rw)
sysfs on / sys type sysfs(rw)
devpts on / dev / pts type devpts(rw、gid =5、mode =620)
tmpfs on / dev / shm type tmpfs(rw)
/ dev / sda1 on / boot type ext4(rw)
none on / proc / sys / fs / binfmt_misc type binfmt_misc(rw)
sunrpc on / var / lib / nfs / rpc_pipefs type rpc_pipefs(rw)
server1.example.com:/testvol on / mnt / glusterfsタイプfuse.glusterfs(rw、allow_other、default_permissions、max_read =131072)
[[email protected]〜]#
...そして...
df -h
[[メール保護]〜]#df -h
ファイルシステム使用済み使用率使用率
/ dev / mapper / vg_client1-LogVol00
br /> G 9.7 G 9.7 G /> tmpfs 499M 0 499M 0%/ dev / shm
/ dev / sda1 504M 39M 440M 440M 9%/ boot
server1.example.com 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、server3.example.com、server4.example.comを使用することもできます!)
変更した/etc/ fstabが機能しているかどうかをテストするには、クライアントを再起動します。
reboot
再起動後、出力に共有が表示されます...
df -h
...そして...
mount
5テスト
それでは、GlusterFS共有にいくつかのテストファイルを作成しましょう:
client1.example.com:
touch / mnt / glusterfs / test1
touch / mnt / glusterfs / test2
touch / mnt / glusterfs / test3
touch / mnt / glusterfs / test4
touch / mnt / glusterfs / test5
touch / mnt / glusterfs / test6
次に、server1.example.com、server2.example.com、server3.example.com、およびserver4.example.comの/dataディレクトリを確認しましょう。 Replication1とreplication2は、クライアント上のGlusterFS共有を構成するファイル/ディレクトリの一部のみを保持しますが、replication1(server1とserver2)またはreplication2(server3とserver4)を構成するノードには同じものが含まれていることに気付くでしょう。ファイル(ミラーリング):
server1.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
- rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test4
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test5
[[email protected]〜]#
server2.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
- rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test4
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test5
[[email protected]〜]#
server3.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test3
- rw-r--r-- 1 root root 0 2012-12-17 15:49 test6
[[email protected]〜]#
server4.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test3
- rw-r--r-- 1 root root 0 2012-12-17 15:49 test6
[[email protected]〜]#
ここで、server1.example.comとserver4.example.comをシャットダウンし、client1.example.comのGlusterFS共有でいくつかのファイルを追加/削除します。
server1.example.com/server4.example.com:
shutdown -h now
client1.example.com:
rm -f / mnt / glusterfs / test5
rm -f / mnt / glusterfs / test6
変更は、server2.example.comおよびserver3.example.comの/dataディレクトリに表示されます。
server2.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
- rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test4
[[メール保護]〜]#
server3.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test3
[ [メールで保護]〜]#
server1.example.comとserver4.example.comを再度起動して、/dataディレクトリを確認してみましょう。
server1.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
- rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test4
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test5
[[email protected]〜]#
server4.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test3
- rw-r--r-- 1 root root 0 2012-12-17 15:49 test6
[[email protected]〜]#
ご覧のとおり、server1.example.comとserver4.example.comは、ダウン中に発生した変更に気づいていません。これは簡単に修正できます。必要なのは、client1.example.comのGlusterFS共有で読み取りコマンドを呼び出すことだけです。例:
client1.example.com:
ls -l /mnt/glusterfs/
[[メール保護]〜]#ls -l / mnt / glusterfs /
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
-rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test3
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test4
[[email protected]〜]#
ここで、server1.example.comとserver4.example.comの/ dataディレクトリをもう一度見てください。変更が、これらのノードに複製されていることがわかります。
server1.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test1
- rw-r--r--1ルートルート02012-12-1715:49 test2
-rw-r--r--1ルートルート02012-12-1715:49 test4
[[メール保護]〜]#
server4.example.com:
ls -l /data
[[メール保護]〜]#ls -l / data
total 0
-rw-r--r-- 1 root root 0 2012-12-17 15:49 test3
[ [メールで保護]〜]#
6つのリンク
- GlusterFS:http://www.gluster.org/
- GlusterFS 3.2ドキュメント:http://download.gluster.com/pub/gluster/glusterfs/3.2/Documentation/AG/html/index.html
- CentOS:http://www.centos.org/