EC2インスタンスをGlusterFSを使用してEBS冗長化

この記事は公開されてから半年以上経過しています。情報が古い可能性がありますので、ご注意ください。

【実施したこと】

AWS環境のEC2インスタンスでGlusterFSを使用して、サーバの冗長化を行った時のメモになります

 

 

【前提条件】

・AmazonLinux

・追加でEBSをつけておく(これがGlusterFS化されるDiskです)
■手順
1.glusterfsインストール(www01/02)

curl -o /etc/yum.repos.d/glusterfs-epel.repo http://download.gluster.org/pub/gluster/glusterfs/3.3/LATEST/EPEL.repo/glusterfs-epel.repo

 

2.リポジトリファイル編集(www01/02)
vi /etc/yum.repos.d/glusterfs-epel.repo

[$releasever] → [6]に修正する

=========修正したファイル=========
#Place this file in your /etc/yum.repos.d/ directory

[glusterfs-epel] name=GlusterFS is a clustered file-system capable of scaling to several petabytes.
#baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-$releasever/$basearch/
baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-6/$basearch/
enabled=1
skip_if_unavailable=1
gpgcheck=0

[glusterfs-swift-epel] name=GlusterFS is a clustered file-system capable of scaling to several petabytes.
#baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-$releasever/noarch
baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-6/noarch
enabled=1
skip_if_unavailable=1
gpgcheck=0

[glusterfs-source-epel] name=GlusterFS is a clustered file-system capable of scaling to several petabytes. – Source
#baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-$releasever/SRPMS
baseurl=http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.2/EPEL.repo/epel-6/SRPMS
enabled=0
skip_if_unavailable=1
gpgcheck=0

 

 

3.glusterfsインストール及び起動(www01/02)

yum install glusterfs-server
chkconfig glusterd on
/etc/init.d/glusterd start

 

4.マウントデバイス作成(www01/02)
・アタッチしているEBSをフォーマットする

mkfs -t ext4 -I 512 /dev/[デバイス名]

・マウントディレクトリ作成
(www01の場合)
mkdir /brick/www01

(www02の場合)
mkdir /brick/www02

・マウントする
(www01の場合)
mount -t ext4 [デバイス名] /brick/www01

(www02の場合)
mount -t ext4 [デバイス名] /brick/www02
df -hで確認
・fstabへ追記
=========修正したファイル=========
#
LABEL=/ / ext4 defaults,noatime 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb1 /bricks/www01 ext4 defaults,noatime 1 1

 

5.ノード登録(www01※片側で実施)

[root@ ~]# gluster
gluster>
gluster> peer status
No peers present
gluster>
gluster> peer probe [IPアドレス] gluster>
gluster> peer status
Number of Peers: 1

Hostname: [IPアドレス] Uuid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
State: Peer in Cluster (Connected)
gluster>
6.ボリューム作成(www01※片側で実施)

gluster> volume info
No volumes present
gluster>
gluster> volume create vol01 replica 2 [www01のIPアドレス]:/bricks/www01 [IPアドレス]:/bricks/www02
Creation of volume vol01 has been successful. Please start the volume to access data.
gluster>
gluster> volume info

Volume Name: vol01
Type: Replicate
Volume ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Status: Created
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: [www01のIPアドレス]:/bricks/www01
Brick2: [www02のIPアドレス]:/bricks/www02
gluster>

 

7.ボリューム起動(www01※片側で実施)

gluster> volume status vol01
Volume vol01 is not started
gluster>
gluster> volume start vol01
Starting volume vol01 has been successful
gluster>
gluster> volume status vol01
Status of volume: vol01
Gluster process Port Online Pid


Brick 172.31.24.105:/bricks/www01 24010 Y 1900
Brick 172.31.2.117:/bricks/www02 24010 Y 1654
NFS Server on localhost 38467 Y 1906
Self-heal Daemon on localhost N/A Y 1912
NFS Server on 172.31.2.117 38467 Y 1660
Self-heal Daemon on 172.31.2.117 N/A Y 1662

gluster>
gluster> exit

8.ボリュームマウント(www01※片側で実施)

[root@~]#
[root@~]# mkdir /glusterfs/data
[root@~]# ls -ld /glusterfs/data
drwxr-xr-x 2 root root 4096 Aug 11 22:52 /glusterfs/data
[root@~]#
[root@~]#
[root@~]# mount -t glusterfs [www01のIPアドレス]:/vol01 /glusterfs/data
[root@~]#
[root@~]#
[root@~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 25G 2.9G 22G 12% /
devtmpfs 994M 64K 994M 1% /dev
tmpfs 1003M 0 1003M 0% /dev/shm
/dev/xvdb1 25G 44M 23G 1% /bricks/www01
[www01のIPアドレス]:/vol01 25G 44M 23G 1% /glusterfs/data
[root@ ~]#

 

9.ボリュームマウント(www02※片側で実施)

[root@~]#
[root@~]# mkdir /glusterfs/data
[root@~]# ls -ld /glusterfs/data
drwxr-xr-x 2 root root 4096 Aug 11 22:52 /glusterfs/data
[root@~]#
[root@~]#
[root@~]#
[root@~]# mount -t glusterfs [www02のIPアドレス]:/vol01 /glusterfs/data
[root@~]#
[root@~]#
[root@~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 25G 2.9G 22G 12% /
devtmpfs 994M 64K 994M 1% /dev
tmpfs 1003M 0 1003M 0% /dev/shm
/dev/xvdb1 25G 44M 23G 1% /bricks/www02
[www02のIPアドレス]:/vol01 25G 44M 23G 1% /glusterfs/data
[root@~]#

 

10.確認(www01/02)
(www01)
touch /glusterfs/data/test.txt
ls -l /glusterfs/data/test.txt
[確認]作成されたこと

(www02)
ls -l /glusterfs/data/test.txt
[確認]作成されていること

rm -i /glusterfs/data/test.txt
ls -l /glusterfs/data/test.txt
[確認]削除したこと
(www01)
ls -l /glusterfs/data/test.txt
[確認]削除されていること

 

11.自動マウント設定(www01/02)

・fstabへ追記(www01)
=========修正したファイル=========
#
LABEL=/ / ext4 defaults,noatime 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb1 /bricks/www01 ext4 defaults,noatime 1 1
[www01のIP]:/vol01 /glusterfs/data glusterfs defaults,_netdev 0 0

 

・fstabへ追記(www02)
=========修正したファイル=========
#
LABEL=/ / ext4 defaults,noatime 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb1 /bricks/www02 ext4 defaults,noatime 1 1
[www02のIPアドレス]:/vol01 /glusterfs/data glusterfs defaults,_netdev 0 0

 

 

・netfs有効(www01/www02)

chkconfig
chkconfig netfs on
chkconfig

・OS再起動してマウントされていること

 

これをしないとOS再起動してもマウントされない

※めっちゃはまった(泣)

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Time limit is exhausted. Please reload CAPTCHA.