南财贴吧:Gluster File System 安装及使用指南

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 18:24:16

实习成果—Gluster File System 安装及使用指南

smilettGluster, 实习 CTBRI, Gluster, 云, 实习 No Comments

1. 配置要求

硬件要求:GlusterFS支持大多数的符合商业标准的x86-64bit硬件平台。存储可以是直接附加的存储,RAID盘,以SATA/SAS/FC盘做后端的FC/Infiniband/iSCSI SAN盘。

1.1 网路要求

GlusterFS支持千兆网,百兆网和Infiniband(光纤)。

1.2 操作系统要求

GlusterFS可以支持很多POSIX兼容的系统,如GNU/Linux, FreeBSD, OpenSolaris, Solaris, 和Mac OS X。Gluster建议采用Ext3, Ext4或者ZFS作为子系统磁盘的格式。Gluster对GNU/Linux, Mac OS X, FreeBSD和OpenSolaris有内嵌的支持。

1.3 本文中的安装测试环境

Ubuntu Server 9.10

千兆网

服务器端IP: 124.127.117.28, 124.127.117.11, 124.127.117.9

客户端IP:124.127.117.12

2. 在服务器端,从源码安装GlusterFS,用作GlusterFS Server

下载最新版本(http://www.gluster.org/download)

官方FTP主页(http://ftp.gluster.com/pub/gluster/glusterfs/)

本文中安装测试所用的GlusterFS为version3.0.4

2.1 安装必要的支持软件包

sudo apt-get install flexsudo apt-get install bison

2.2 开始安装

tar -xzf glusterfs-version.tar.gzcd glusterfs-version./configure --prefix= > /dev/nullsudo makesudo make insatll

2.3 安装完毕,执行

sudo ldconfig

2.4 检验安装是否成功,输入

glusterfs --version

显示如下输出则说明安装成功

Glusterfs 3.0.4 built on Apr 21 2010 11:54:11Repository revision: v3.0.4Copyright (c) 2006-2009 Gluster Inc.GlusterFS comes with ABSOLUTELY NO WARRANTY.You may redistribute copies of GlusterFS under the terms of the GNU General Public License.

2.5 创建必要的文件

sudo mkdir /home/dir1sudo chmod 1777 /home/dir1

2.6 配置

此配置方法为手工配置,参数设置简单。此方法可以用于在一台服务器上同时启动多个Sever。另外一种配制方法将在最后介绍。

cd /etc/glusterfs

在此目录下有两个文件:glusterfsd.vol.sample,glusterfs.vol.sample 。glusterfsd.vol.sample,是服务器端配置文件的模板;glusterfs.vol.sample 是客户端配置文件的模板。

2.6.1 备份客户端配置文件模板

sudo cp glusterfsd.vol.sample glusterfsd.vol

2.6.2 编辑服务器端配置文件

sudo vim glusterfsd.vol

编辑glusterfsd.vol中内容如下:

volume bricktype storage/posix # POSIX FS translatoroption directory /home/dir1 # Export this directoryend-volumevolume servertype protocol/serveroption transport-type tcp/serveroption transport.socket.bind-address 124.127.117.28 # Default is to listen on all interfacessubvolumes brickoption auth.addr.brick.allow * # Allow access to "brick" volumeend-volume

2.7 启动Server

sudo glusterfsd -f /etc/glusterfs/glusterfsd.vol -l /var/log/glusterfs/glusterfsd.log

2.8 检验Server启动是否成功

2.8.1 检验glusterfsd进程是否存在

ps ax|grep -v grep |grep gluster

显示如下则说明Server进程启动

7535 ? Ssl 0:00 glusterfsd -f /etc/glusterfs/glusterfsd.vol -l /var/log/glusterfs/glusterfsd.log

2.8.2 检验端口6996是否启用监听

netstat -ln | grep 6996

显示如下则说明6996端口处在监听状态

tcp 0 0 124.127.117.28:6996 0.0.0.0:* LISTEN

2.8.3 查看log

vim /var/log/glusterfs/glusterfsd.log

log末尾显示如下则说明Server正常启动

+------------------------------------------------------------------------------+[2010-05-14 10:15:18] N [glusterfsd.c:1408:main] glusterfs: Successfully started

2.9 关闭Server

用sudo kill -9加进程号,结束server进程。如:

sudo kill -9 7535

3. 在客户端,从源码安装GlusterFS,用作GlusterFS Client

3.1 客户端必须要有FUSE的内核支持。FUSE可到http://fuse.sourceforge.net下载安装。

Ubuntu9.10的内核里应该是有FUSE的,但是也许是没有开启,我在机器上查,没有FUSE加载。用网上的命令试了,也开启不了。于是我去下了个来安。安起来比较麻烦,于是后来放弃了。但是Gluster却可以用,至今没搞懂。。。

3.2 从源码安装GlusterFS。方法步骤参看服务器端安装。

3.3 配置:

此配置方法为手工配置,参数设置简单。另外一种配制方法将在最后介绍。

cd /etc/glusterfs

在此目录下有两个文件:glusterfsd.vol.sample,glusterfs.vol.sample。glusterfsd.vol.sample,是服务器端配置文件的模板;glusterfs.vol.sample 是客户端配置文件的模板。

3.3.1 备份客户端配置文件模板

sudo cp glusterfs.vol.sample glusterfs.vol

3.3.2 编辑客户端配置文件

sudo vim glusterfs.vol

编辑glusterfs.vol中内容如下:

volume clienttype protocol/clientoption transport-type tcp/clientoption remote-host 124.127.117.28 # IP address of the remote brickoption remote-subvolume brick # name of the remote volumeend-volume

3.4 客户端挂载

sudo glusterfs -f /etc/glusterfs/glusterfs.vol -l /var/log/glusterfs/glusterfs.log /mnt/

3.5 检测客户端是否正常挂载

3.5.1 查看挂在盘符

df -h

显示如下则说明客户端正常挂载了服务器端的磁盘 (即 /home/dir1)

Filesystem    Size     Used       Avail      Use%   Mounted on/dev/sda1      21G      14G        5.7G       71%    /udev          502M     176K        501M        1%    /devnone          502M        0        502M        0%    /dev/shmnone          502M      56K        502M        1%    /var/runnone          502M        0        502M        0%    /var/locknone          502M        0        502M        0%    /lib/init/rw/dev/sda6     9.2G     150M        8.6G        2%    /image/dev/sda7     115G     188M        109G        1%     /data/etc/glusterfs/glusterfs.vol              913G      33G        834G        4%      /mnt

3.5.2 查看glusterfs进程是否存在

ps ax|grep -v grep |grep gluster

显示如下则说明glusterfs进程正常启动

23593 ? Ssl 0:00 glusterfs -f /etc/glusterfs/glusterfs.vol -l /var/log/glusterfs/glusterfs.log /mnt/

3.5.3 查看log

vim /var/log/glusterfs/glusterfs.log

log末尾显示如下则说明Client正常启动,并和Server交互正常

+------------------------------------------------------------------------------+[2010-05-14 10:09:38] N [glusterfsd.c:1408:main] glusterfs: Successfully started[2010-05-14 10:09:38] N [client-protocol.c:6246:client_setvolume_cbk] client: Connected to 124.127.117.28:6996, attached to remote volume 'brick'.[2010-05-14 10:09:38] N [client-protocol.c:6246:client_setvolume_cbk] client: Connected to 124.127.117.28:6996, attached to remote volume 'brick'.[2010-05-14 10:09:38] N [fuse-bridge.c:2950:fuse_init] glusterfs-fuse: FUSE inited with protocol versions: glusterfs 7.13 kernel 7.12

3.6 在客户端进行操作

cd /mnt

进入挂载目录后即可在客户端实现各种文件读写工作。

3.7 卸载时用命令

sudo umount /mnt

4. 利用GlusterFS内建的命令自动生成配置文件,并实现ClientServer的交互

glusterfs-volgenGlusterFS内建的命令,可以用来生成配置文件。

4.1 生成分布式系统的配置文件

glusterfs-volgen –name :

如本例中有3个Server,分别是28, 11, 9。可以输入以下命令来生成配置文件。

glusterfs-volgen --name test 124.127.117.28:/home/dir1 124.127.117.11:/home/dir1 124.127.117.9:/home/dir1

如此,系统会生成4个文件:

124.127.117.28-test-export.vol

124.127.117.11-test-export.vol

124.127.117.19-test-export.vol

test-tcp.vol

前三个分别为28,11,9这三个Server端的配置文件,最后一个为Client端的配置文件。

4.2 配置服务器端

把124.127.117.28-test-export.vol拷贝到28服务器上,并进行如下操作,以创建GlusterFS Server的配置文件。

sudo cp 124.127.117.28-test-export.vol /etc/glusterfs/glusterfsd.vol

在11和9服务器上,安对应的文件重复以上操作。

4.3 启动Server

sudo /etc/init.d/glusterfsd start

显示如下则说明启动成功

* Starting glusterfs server glusterfsd [ OK ]

也可以他通过查看log了解Server启动情况

vim /var/log/glusterfs/etc-glusterfs-glusterfsd.vol.log

在log的末尾显示如下则表明启动成功

+------------------------------------------------------------------------------+[2010-05-16 22:41:31] N [glusterfsd.c:1408:main] glusterfs: Successfully started

4.4 配置客户端

把test-tcp.vol拷贝到12服务器上,并进行如下操作,以创建GlusterFS Client的配置文件。

sudo cp test-tcp.vol /etc/glusterfs/glusterfs.vol

4.5 client挂载

4.5.1 创建挂载点

sudo mkdir /mnt/glusterfs

4.5.2 挂载

sudo mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs

4.5.3检测挂载是否成功

输入一下命令查看挂载情况

df -h

输出如下则说明正常挂载

Filesystem  Size  Used  Avail  Use%  Mounted on/dev/sda1    21G   14G   5.7G   71%  /udev        502M  176K   501M    1%  /devnone        502M     0   502M    0%  /dev/shmnone        502M   56K   502M    1%  /var/runnone        502M     0   502M    0%  /var/locknone        502M     0   502M    0%  /lib/init/rw/dev/sda6   9.2G  150M   8.6G    2%  /image/dev/sda7   115G  188M   109G    1%  /data/etc/glusterfs/glusterfs.vol            949G   79G   822G    9%  /mnt/glusterfs

也可查看log

vim /var/log/glusterfs/mnt-glusterfs.log

4.6 在客户端操作

cd /mnt/glusterfs

进入挂载目录后即可在客户端实现各种文件读写工作。

4.7 卸载

sudo umount /mnt/glusterfs

实习成果—Gluster Storage Platform 实习成果—Gluster虚拟机环境

  • Disqus