本文环境:一台服务器,一台测试机均为CentOS-5.2操作系统,服务器端的ip为:192.168.10.252,测试机的ip为192.168.10.14 在服务端有一个独立的磁盘用来测试

一 服务器端的安装和配置

1.首先安装fuse扩展

[root@test-1 ~]# tar zvxf fuse-2.8.3.tar.gz

[root@test-1 ~]# cd fuse-2.8.3

[root@test-1 ~]# ./configure --enable-dependency-tracking --enable-lib --enable-util

[root@test-1 ~]# make

[root@test-1 ~]# make install

2. 检查fuse是否安装正确,如果不正确后面启动和挂载glusterfs时候都会报错

[root@test-1 ~]# ll /dev/fuse

crw-rw-rw- 1 root root 10, 229 Apr 23 14:08 /dev/fuse

3. 安装服务器端

[root@test-1 ~]# cd ..

[root@test-1 ~]# tar zvxf glusterfs-3.0.3.tar.gz

[root@test-1 ~]# cd glusterfs-3.0.3

[root@test-1 ~]# ./configure --enable-fusermount

clip_p_w_picpath002

[root@test-1 ~]# make

[root@test-1 ~]# make install

4. 创建本地的共享点同时挂载硬盘分区

[root@test-1 ~]# mkdir /home/gluster

[root@test-1 ~]# mount /dev/sdb1 /home/gluster/

[root@test-1 ~]# chmod 777 /home/gluster/

5. 查看挂载是否正常

[root@test-1 ~]# df -lh

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

7.0G 3.4G 3.2G 52% /

/dev/sda1 99M 12M 83M 13% /boot

tmpfs 125M 0 125M 0% /dev/shm

/dev/sdb1 4.0G 8.0M 3.8G 1% /home/gluster

6开始配置服务器端配置文件,首先先备份示例文件

[root@test-1 ~]#cd /usr/local/etc/glusterfs

[root@test-1 ~]# mkdir bak

[root@test-1 ~]# mv *.sample bak

[root@test-1 ~]# cp bak/glusterfsd.vol.sample glusterfsd.vol

[root@test-1 ~]# echo "" >glusterfsd.vol

[root@test-1 ~]# vi glusterfsd.vol(配置如下)

### Export volume "brick" with the contents of "/home/export" directory.

volume brick

type storage/posix # POSIX FS translator

option directory /home/gluster # Export this directory

end-volume

volume locker

type features/locks

subvolumes brick

end-volume

volume bricks

type performance/io-threads

option thread-count 50 #//开启50个线程

subvolumes locker

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp/server

option listen-port 6996 # Default is 6996

subvolumes locker

option auth.addr.bricks.allow *

option auth.addr.locker.allow *

end-volume

7. 启动服务器端

[root@test-1 glusterfs]# glusterfsd -l /var/log/glusterfs.log -f /usr/local/etc/glusterfs/glusterfsd.vol -p /var/run/glusterfs.pid

启动的过程中指定了pid文件位置和日志文件位置

8验证服务启动是否正常,端口监听

[root@test-1 glusterfs]# netstat -nltp |grep 6996 |grep -v grep

tcp 0 0 0.0.0.0:6996 0.0.0.0:* LISTEN 27698/glusterfsd

[root@test-1 glusterfs]#

二 客户端的安装和配置

1. 和服务器端同样的安装操作此处不多说了,接下来配置客户端配置文件

[root@localhost glusterfs]#cd /usr/local/etc/glusterfs

[root@localhost glusterfs]# mkdir bak

[root@localhost glusterfs]# mv *.sample bak

[root@localhost glusterfs]# cp bak/glusterfs.vol.sample glusterfs.vol

[root@localhost glusterfs]# echo "" >glusterfs.vol

[root@localhost glusterfs]# vi glusterfs.vol

volume client1

type protocol/client

option transport-type tcp/client

option remote-host 192.168.10.252 #//server ip

option remote-port 6996

option remote-subvolume locker

end-volume

volume bricks

type cluster/distribute

subvolumes client1

end-volume

2开始客户端的挂载,把服务器端对文件系统挂载到本地的/mnt目录

[root@localhost glusterfs]#glusterfs -l /var/log/glusterfs.log -f /usr/local/etc/glusterfs/glusterfsd.vol -p /var/run/glusterfs.pid

同样指定了pid文件和日志文件

3看看是否挂载成了本地文件系统

[root@localhost glusterfs]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/hda2 5.7G 2.0G 3.4G 38% /

/dev/hda1 99M 12M 83M 12% /boot

tmpfs 252M 0 252M 0% /dev/shm

glusterfs#/usr/local/etc/glusterfs/glusterfs.vol

7.0G 3.2G 3.4G 49% /mnt

[root@localhost glusterfs]# mount | tail -1

glusterfs#/usr/local/etc/glusterfs/glusterfs.vol on /data type fuse (rw,allow_other,default_permissions,max_read=131072)

[root@localhost glusterfs]#

三 测试部分

1. 在服务器的共享点上创建文件和目录

[root@test-1 gluster]# cd /home/gluster/

[root@test-1 gluster]# touch test

[root@test-1 gluster]# mkdir -p qubaoquan

[root@test-1 gluster]# ls

qubaoquan test

[root@test-1 gluster]#

2. 在客户记得挂载点上查看

[root@localhost glusterfs]# cd /mnt/

[root@localhost data]# ls

qubaoquan test