0
|
1 # GFS2
|
|
2
|
|
3 ## GFS2とは
|
|
4
|
|
5 Global File System 2 の略。
|
|
6
|
|
7 サーバ同士で同一のディスクを共有し利用することができる。
|
|
8
|
|
9 環境は Fedora 20 。
|
|
10
|
|
11 linux kernel 3.17 あたりでは、現時点ではできない
|
|
12
|
|
13 ## GFS2 の設定
|
|
14
|
|
15 ### install
|
|
16
|
|
17 ```
|
|
18 yum install kernel-modules-extra
|
|
19 yum install gfs2-utils lvm2-cluster corosync dlm pacemaker
|
|
20 ```
|
|
21
|
|
22 ### module があるか確認
|
|
23
|
|
24 ```
|
|
25 $ lsmod | grep gfs2
|
|
26
|
|
27 $ lsmod | grep dlm
|
|
28 ```
|
|
29
|
|
30 ### disk format
|
|
31
|
|
32 接続されているディスクの一覧
|
|
33
|
|
34 ```
|
|
35 $ fdisk -l
|
|
36 ```
|
|
37
|
|
38 ディスクのフォーマット
|
|
39 sample
|
|
40
|
|
41 ```
|
|
42 $ fdisk /dev/sdb
|
|
43 ```
|
|
44
|
|
45 新しくパーティションを作成する
|
|
46
|
|
47 ```
|
|
48 n
|
|
49 ```
|
|
50
|
|
51 フォーマットタイプ の入力
|
|
52 16進数で入力する
|
|
53 lvm を使用するので 8e を指定
|
|
54
|
|
55 ```
|
|
56 t
|
|
57 ```
|
|
58
|
|
59 パーティションの確定と書き込み
|
|
60 w で enter をしてしまうとディスクの中身が消えてしまうので注意
|
|
61
|
|
62 ```
|
|
63 w
|
|
64 ```
|
|
65
|
|
66 ### LVM の設定
|
|
67
|
|
68 Logical Volume Manager の略
|
|
69
|
|
70 パーティションを切り分けたり合成できる
|
|
71
|
|
72 LVM の、physical volume を作成
|
|
73
|
|
74 ```
|
|
75 # pvcreate /dev/sdb1
|
|
76 Physical volume "/dev/sdb1" successfully created
|
|
77 ```
|
|
78
|
|
79 physical volume の確認
|
|
80
|
|
81 ```
|
|
82 # pvs
|
|
83 ```
|
|
84
|
|
85 Volume Group を作成する
|
|
86 fcs という名前の、 lvm2 cluster に対応した Volume Group を作成
|
|
87 - -c : クラスタ対応の許可
|
|
88 - fcs : Volume Group の名前(任意)
|
|
89
|
|
90 ```
|
|
91 # vgcreate -cy fcs /dev/sdb1
|
|
92 Volume group "fcs" successfully created
|
|
93 ```
|
|
94
|
|
95 ```
|
|
96 # vgs
|
|
97 VG #PV #LV #SN Attr VSize VFree
|
|
98 fcs 1 0 0 wz--n- 1.95t 1.95t
|
|
99 fedora_host 1 2 0 wz--n- 29.31g
|
|
100 ```
|
|
101
|
|
102 Logical Volume (LV) を作成する。全体の容量を指定
|
|
103 - -L : LVの容量
|
|
104 - -n : LV の名前
|
|
105 - fcs : 切り分ける VG の名前(今回はわけないで全体を使う)
|
|
106
|
|
107 ```
|
|
108 # lvcreate -L 1.95t -n fcslv fcs
|
|
109 Rounding up size to full physical extent 1.95 TiB
|
|
110 Logical volume "fcs_lv" created
|
|
111 # vgs
|
|
112 VG #PV #LV #SN Attr VSize VFree
|
|
113 fcs 1 1 0 wz--n- 1.95t 3.20g
|
|
114 fedora_host 1 2 0 wz--n- 29.31g 0
|
|
115 ```
|
|
116
|
|
117 「状態が ACTIVE か」「path はどこか」を調べる
|
|
118
|
|
119 ```
|
|
120 # lvscan
|
|
121 ACTIVE '/dev/fedora_host/swap' [2.98 GiB] inherit
|
|
122 ACTIVE '/dev/fedora_host/root' [26.33 GiB] inherit
|
|
123 ACTIVE '/dev/fcs/fcslv' [1.95 TiB] inherit
|
|
124 ```
|
|
125
|
|
126 /dev/fcslv を使用することができる
|
|
127
|
|
128 ### corosync の設定
|
|
129
|
|
130 corosync の設定ファイルの編集
|
|
131
|
|
132 ```
|
|
133 vim /etc/corosync/corosync.conf
|
|
134 ```
|
|
135
|
|
136 以下のように編集する
|
|
137
|
|
138 ```
|
|
139 totem {
|
|
140 version: 2
|
|
141 secauth: off
|
|
142 cluster_name: bldsvgfs2 // gfs2 のフォーマットに使用する
|
|
143 }
|
|
144
|
|
145 nodelist {
|
|
146 node {
|
|
147 ring0_addr: 10.0.0.9
|
|
148 nodeid: 1
|
|
149 }
|
|
150 node {
|
|
151 ring0_addr: 10.0.0.10
|
|
152 nodeid: 2
|
|
153 }
|
|
154 node {
|
|
155 ring0_addr: 10.0.0.11
|
|
156 nodeid: 3
|
|
157 }
|
|
158 }
|
|
159 quorum {
|
|
160 provider: corosync_votequorum
|
|
161 # two_node: 1
|
|
162 }
|
|
163 ```
|
|
164
|
|
165 ### lvm の設定
|
|
166
|
|
167 ```
|
|
168 $ vi /etc/lvm/lvm.conf
|
|
169 ```
|
|
170
|
|
171 ```
|
|
172 locking_type = 1
|
|
173 ```
|
|
174
|
|
175 を
|
|
176
|
|
177 ```
|
|
178 locking_type = 3
|
|
179 ```
|
|
180
|
|
181 にする
|
|
182
|
|
183
|
|
184 ### GFS2 でフォーマット
|
|
185
|
|
186 - -p lock_dlm : lock manager の指定。今回は dlm を使用する
|
|
187 - -t fileformat:clustername : フォーマットと corosync で設定したクラスタの名前を指定
|
|
188 - -j 3 : journaling 数の指定。GFS2 に接続し、ディスクを使用するホストの数を指定する
|
|
189
|
|
190 # mkfs.gfs2 -p lock_dlm -t gfs2:bldsvgfs2 -j 3 /dev/fcs/fcslv
|
|
191
|
|
192
|
|
193 ### GFS2 クラスタの起動
|
|
194
|
|
195 ```
|
|
196 service pcsd start
|
|
197 service corosync start
|
|
198 service dlm start
|
|
199 service clvmd start
|
|
200
|
|
201 mount /dev/fcs/fcslv /media/fcs
|
|
202 ```
|
|
203
|
|
204 ### 自動起動の設定
|
|
205
|
|
206 ```
|
|
207 systemctl enable pcsd start
|
|
208 ```
|
|
209
|
|
210 まだ corosync 以下は順番に実行する必要があると考えているため、
|
|
211 pcsd 以外のプロセスは自動起動に設定していない
|
|
212
|
|
213 自動起動の設定はこんな感じ
|
|
214
|
|
215 ```
|
|
216 $ systemctl enable corosync
|
|
217 $ systemctl enable dlm
|
|
218 $ chkconfig clvmd on
|
|
219 ```
|
|
220
|
|
221 /etc/fstab を書くのなら
|
|
222 ```
|
|
223
|
|
224 /dev/fcs/fcslv /media/fcs gfs2 _netdev,noatime,nodiratime 0 0
|
|
225 ```
|