gluster

GlusterFS 是集群分散式檔案系統,安裝簡單、設置容易、透過設定檔方式可以相當的靈活運用它。以下將實作 GlusterFS 架設類似於nfs,透過一台server分享檔案至各個client端。

準備

fuse
glusterfs

安裝

fuse

1
yum -y install fuse

glusterfs

1
2
3
4
5
tar -xvf glusterfs-3.0.4.tar.gz
cd glusterfs-3.0.4
./configure
make
make install

查看安裝後 glusterfs 資訊

1
glusterfs --versio
1
2
3
4
5
glusterfs 3.0.4 built on May  1 2010 11:35:36
Repository revision: v3.0.4
Copyright (c) 2006-2009 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.

設定 Server

可以從 /usr/local/etc/glusterfs/glusterfsd.vol.sample 範例修改

1
cp /usr/local/etc/glusterfs/glusterfsd.vol.sample /etc/glusterfsd-server.vol
1
vim /etc/glusterfsd-server.vol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
### file: server-volume.vol.sample
 
#####################################
###  GlusterFS Server Volume File  ##
#####################################
 
#### CONFIG FILE RULES:
### "#" is comment character.
### - Config file is case sensitive
### - Options within a volume block can be in any order.
### - Spaces or tabs are used as delimitter within a line. 
### - Multiple values to options will be : delimitted.
### - Each option should end within a line.
### - Missing or commented fields will assume default values.
### - Blank/commented lines are allowed.
### - Sub-volumes should already be defined above before referring.
 
### Export volume "brick" with the contents of "/home/export" directory.
volume brick
  type storage/posix                            # POSIX FS translator
  option directory /home/shian/public_html      # Export this directory
end-volume
 
### Add network serving capability to above brick.
volume server
  type protocol/server
  option transport-type tcp
# option transport-type unix
# option transport-type ib-sdp
option transport.socket.bind-address 192.168.1.200    # Default is to listen on all interfaces
option transport.socket.listen-port 6996              # Default is 6996
 
# option transport-type ib-verbs
# option transport.ib-verbs.bind-address 192.168.1.10     # Default is to listen on all interfaces
# option transport.ib-verbs.listen-port 6996              # Default is 6996
# option transport.ib-verbs.work-request-send-size  131072
# option transport.ib-verbs.work-request-send-count 64
# option transport.ib-verbs.work-request-recv-size  131072
# option transport.ib-verbs.work-request-recv-count 64
 
# option client-volume-filename /etc/glusterfs/glusterfs-client.vol
  subvolumes brick
# NOTE: Access to any volume through protocol/server is denied by
# default. You need to explicitly grant access through # "auth"
# option.
  option auth.addr.brick.allow * # Allow access to "brick" volume
end-volume

啟動Server

1
glusterfs -f /etc/glusterfsd-server.vol -l /var/log/glustfs.log

查看 server log

1
2
tail /vat/log/glusterfsd.log
[2010-05-01 11:48:50] N [glusterfsd.c:1408:main] glusterfs: Successfully started

開機啟動

1
vim /etc/rc.local
1
/usr/local/sbin/glusterfs -f /etc/glusterfsd-server.vol -l /var/log/glustfs.log

設定 client

可以從 /glusterfs/glusterfs-3.0.4/doc/examples/protocol-client.vol 範例修改

1
cp /glusterfs/glusterfs-3.0.4/doc/examples/protocol-client.vol /etc/glusterfsd-client.vol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
volume client
  type protocol/client
  option transport-type tcp     # for TCP/IP transport
# option transport-type ib-sdp  # for Infiniband transport
  option remote-host 192.168.1.11      # IP address of the remote brick
# option transport.socket.remote-port 6996              # default server port is 6996
 
# option transport-type ib-verbs # for Infiniband verbs transport
# option transport.ib-verbs.work-request-send-size  1048576
# option transport.ib-verbs.work-request-send-count 16
# option transport.ib-verbs.work-request-recv-size  1048576
# option transport.ib-verbs.work-request-recv-count 16
# option transport.ib-verbs.remote-port 6996              # default server port is 6996
 
  option remote-subvolume brick        # name of the remote volume
# option transport-timeout 30          # default value is 120seconds 
end-volume

載入 fuse

1
modprobe -i fuse

掛載於client

1
glusterfs -l /var/log/glustfs.log -f /etc/glusterfs-client.vol /home/shian/public_html

查看掛載

1
2
3
df -hP
檔案系統              容量  已用 可用 已用% 掛載點
glusterfs#/etc/glusterfsd-client.vol  125G  103G   16G  87% /home/shian/public_html

查看 client log

1
2
3
4
5
6
cat /var/log/glustfs.log
[2010-05-01 20:34:02] W [xlator.c:656:validate_xlator_volume_options] client: option 'transport.socket.remote-port' is deprecated, preferred is 'remote-port', continuing with correction
[2010-05-01 20:34:02] N [glusterfsd.c:1408:main] glusterfs: Successfully started
[2010-05-01 20:34:02] N [client-protocol.c:6246:client_setvolume_cbk] client: Connected to 192.168.1.200:6996, attached to remote volume 'brick'.
[2010-05-01 20:34:02] N [client-protocol.c:6246:client_setvolume_cbk] client: Connected to 192.168.1.200:6996, attached to remote volume 'brick'.
[2010-05-01 20:34:02] N [fuse-bridge.c:2950:fuse_init] glusterfs-fuse: FUSE inited with protocol versions: glusterfs 7.13 kernel 7.10

開機自動掛載

1
vi /etc/fstab
1
/etc/glusterfsd-client.vol  /home/shian/public_html  glusterfs  defaults  0  0

參考資料

Related Posts with Thumbnails

隨選文章

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>