#author("2025-10-05T05:40:43+00:00;2016-05-30T16:26:39+00:00","default:sysosa","sysosa") #author("2025-10-06T01:29:33+00:00","default:sysosa","sysosa") 「呑めば呑むほど強くなる」な感じを率直に思えた「分散ファイルシステム」の一つ「&color(magenta){GlusterFS};」 本家様 [[http://www.gluster.org/>+http://www.gluster.org/]] github [[https://github.com/gluster/glusterfs>+https://github.com/gluster/glusterfs]] 複数のマシンで分散してデータを保持する。データ保持の方法は&color(red){''stripe''};や&color(blue){''replica''};などの方法である。 Lustreのような中央監視なマシンは不要。 &ref(2015y01m24d_215554084.png,nolink,noborder); ここでは4台(n1、n2、n3、n4)のノードを使って各種検証を行ってみた。使用OSは&color(lightseagreen){''CentOS 7''}; &color(red){*};&size(10){速度調査、パフォーマンステストはしません}; 単一マシンでGlusterFSを作ってみる [[GlusterFS/single]] ***&color(green){''Brick''};の作成 [#g5b1be08] 参照先 [[http://www.gluster.org/community/documentation/index.php/QuickStart>+http://www.gluster.org/community/documentation/index.php/QuickStart]] OS領域な部分と、&color(magenta){GlusterFS};構成員として拠出する&color(green){''Brick''};部分を作る。 拠出する&color(green){''Brick''};部分は&color(magenta){GlusterFS};をどのように構成するかに応じるが、冗長なしの単体HDDやHW-RAID構成でOK。 もちろん1台のノードに複数の&color(green){''Brick''};があっても構わない。 ここでは、 |BGCOLOR(YELLOW):デバイス|BGCOLOR(YELLOW):領域|BGCOLOR(YELLOW):サイズ|BGCOLOR(YELLOW):備考| |/dev/sda|OS領域|8GB|最小インストールでntp導入| |/dev/sdb|&color(magenta){GlusterFS};|16GB|&color(green){''Brick''};部分&br;パーティションを切らなくても可| と簡単に1ノードに1&color(green){''Brick''};の構成とした。 #code(nonumber){{ [root@n1 ~]# cat /proc/partitions major minor #blocks name 2 0 4 fd0 8 16 16777216 sdb 8 0 8388608 sda 8 1 524288 sda1 8 2 524288 sda2 8 3 2097152 sda3 8 4 5240832 sda4 11 0 470528 sr0 [root@n1 ~]# [root@n1 ~]# mkfs.xfs -i size=512 /dev/sdb *「-i size=512」はinodeサイズを512バイトに [root@n1 ~]# mkdir /brick [root@n1 ~]# echo "/dev/sdb /brick xfs defaults 1 2" >> /etc/fstab [root@n1 ~]# mount -a [root@n1 ~]# df -lTh /brick ファイルシス タイプ サイズ 使用 残り 使用% マウント位置 /dev/sdb xfs 16G 33M 16G 1% /brick [root@n1 ~]# }} n2、n3、n4でも同じように構築する ***&color(magenta){GlusterFS};のインストール [#b0784d2f] &color(lightseagreen){''CentOS 7''};の標準リポジトリで一応 &color(magenta){glusterfs};として提供されているだが、&color(magenta){glusterfs-server};は見当たらない。 なので、glusterのサイトでRed Hat/CentOS向けのパッケージを取得した。 [[http://www.gluster.org/community/documentation/index.php/Getting_started_install>+http://www.gluster.org/community/documentation/index.php/Getting_started_install]] 開発元がRed Hat/CentOS向けの最新版を提供している。すばらしい。 #code(nonumber){{ [root@n1 ~]# mkdir glusterfs && cd glusterfs [root@n1 glusterfs]# wget -l1 -nd -nc -r -A rpm \ http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/epel-7/x86_64/ [root@n1 glusterfs]# ls -l 合計 14324 -rw-r--r-- 1 root root 458032 4月 18 22:50 glusterfs-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 83380 4月 18 22:50 glusterfs-api-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 38336 4月 18 22:50 glusterfs-api-devel-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 181952 4月 18 22:50 glusterfs-cli-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 805172 4月 18 22:50 glusterfs-client-xlators-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 10625972 4月 18 22:50 glusterfs-debuginfo-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 168412 4月 18 22:50 glusterfs-devel-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 92620 4月 18 22:50 glusterfs-extra-xlators-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 131764 4月 18 22:50 glusterfs-fuse-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 42956 4月 18 22:50 glusterfs-ganesha-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 206952 4月 18 22:50 glusterfs-geo-replication-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 348936 4月 18 22:50 glusterfs-libs-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 60896 4月 18 22:50 glusterfs-rdma-3.7.11-1.el7.x86_64.rpm -rw-r--r-- 1 root root 1392340 4月 18 22:50 glusterfs-server-3.7.11-1.el7.x86_64.rpm [root@n1 glusterfs]# }} 取得したパッケージをn2、n3、n4にコピーします。 #code(nonumber){{ [root@n1 glusterfs]# ssh -l root n2 mkdir glusterfs && scp ./*.rpm root@n2:glusterfs/ [root@n1 glusterfs]# ssh -l root n3 mkdir glusterfs && scp ./*.rpm root@n3:glusterfs/ [root@n1 glusterfs]# ssh -l root n4 mkdir glusterfs && scp ./*.rpm root@n4:glusterfs/ }} インストールするパッケージは &color(magenta){glusterfs-server}; パッケージとその依存パッケージで、 #code(nonumber){{ [root@n1 glusterfs]# yum localinstall ./glusterfs-server-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-api-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-cli-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-client-xlators-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-fuse-3.7.11-1.el7.x86_64.rpm \ ./glusterfs-libs-3.7.11-1.el7.x86_64.rpm [root@n1 glusterfs]# }} とします。インストールが完了すると下記の様にサービスが定義され、glusterd.service を有効にします。 #code(nonumber){{ [root@n1 glusterfs]# systemctl list-unit-files |grep gluster glusterd.service disabled glusterfsd.service disabled [root@n1 glusterfs]# [root@n1 glusterfs]# systemctl enable glusterd }} &color(white,blue){留意}; glusterd と glusterfsd があるが、glusterdだけでいいみたい。 ***信頼されたストレージプールを作る [#k36569be] 本家では「Configure the trusted pool」と称されている。まあーお仲間作りって言ったところか。 ここではn1ノードでのみ操作を行います。 &color(white,blue){留意}; n1ノードで操作をしたからといって、n1ノードに特別な機能が与えられる訳ではない #code(nonumber){{ [root@n1 ~]# gluster peer status *状況確認 Number of Peers: 0 *仲間はおりません [root@n1 ~]# gluster pool list UUID Hostname State 3175c53c-aeff-49ae-bce9-af8a0314aedf localhost Connected *UUIDは/var/lib/glusterd/glusterd.infoと同じ [root@n1 ~]# [root@n1 ~]# gluster peer probe n2 *n2ノードを追加 peer probe: success. [root@n1 ~]# [root@n1 ~]# gluster peer status Number of Peers: 1 Hostname: n2 *n2ノード追加成功 Uuid: 80f808eb-8afc-424b-a40d-e0370c609cd8 State: Peer in Cluster (Connected) [root@n1 ~]# [root@n1 ~]# gluster pool list UUID Hostname State 80f808eb-8afc-424b-a40d-e0370c609cd8 n2 Connected 3175c53c-aeff-49ae-bce9-af8a0314aedf localhost Connected [root@n1 ~]# }} このn1ノードでの作業後、n2ノード側は何もしなくても #code(nonumber){{ [root@n2 ~]# gluster peer status Number of Peers: 1 Hostname: 192.168.0.52 Uuid: 3175c53c-aeff-49ae-bce9-af8a0314aedf State: Peer in Cluster (Connected) [root@n2 ~]# [root@n2 ~]# gluster pool list UUID Hostname State 3175c53c-aeff-49ae-bce9-af8a0314aedf 192.168.0.52 Connected 80f808eb-8afc-424b-a40d-e0370c609cd8 localhost Connected [root@n2 ~]# }} と自動的に連携される。 上記の様に操作して、n3ノードとn4ノードも追加します。 ちなみにノードを削除するには、下記のようにします。 #code(nonumber){{ [root@n1 ~]# gluster peer detach n2 peer detach: success [root@n1 ~]# gluster peer status Number of Peers: 0 [root@n1 ~]# gluster pool list UUID Hostname State 3175c53c-aeff-49ae-bce9-af8a0314aedf localhost Connected [root@n1 ~]# }} この時のn2ノードでも自動的に削除されます。 ***&color(magenta){GlusterFS};のボリュームを作成する [#ud9daccd] ここが胆なのかな。コマンド様式は #code(nonumber){{ [root@n1 ~]# gluster volume create ボリューム名 \ [stripe <COUNT>] \ [replica <COUNT>] \ [disperse [<COUNT>]] \ [redundancy <COUNT>] \ [transport <tcp|rdma|tcp,rdma>] \ n1:/brick/gv0 n2:/brick/gv0 n3:/brick/gv0 n4:/brick/gv0 \ [force] }} となる。 [[stripe(分割)>GlusterFS/stripe]] 複数のノードに分割したファイルの断片を分散させる [[replica(複製)>GlusterFS/replica]] 複数のノードに同じファイルの複製を作る [[disperse(分散)>GlusterFS/disperse]] RAID5っぽくファイルを分散する(version3.6から) ***mount操作 [#hbdbe2df] [[GlusterFS/client]] ***初期化 [#h5effb27] コマンドでなかったことにもできるが、簡単には #code(nonumber){{ [root@n1 ~]# /etc/init.d/glusterd stop [root@n1 ~]# rm -rf /var/lib/glusterd/* [root@n1 ~]# /etc/init.d/glusterd start }} でいいみたい。