文件服务器fuse,分布式文件系统glusterfs安装步骤

我的系统是 RHEL5 , 可能环境不一样, 需要安装的第三方依赖不一样啊, 反正大家在安装的过程中缺少什么就去安装什么, 一般都会有提示的。

下载   glusterfs-3.2.0.tar.gz  源码包。 随便解压到一个目录。

glusterfs 需要 fuse 的支持, 在安装开始之前请先安装 fuse。

fuse可以到进行下载

安装fuse的步骤如下:

./configure

make

make install

glusterfs 需要 ctypes 的支持, 在安装开始之前请先安装 ctypes。

ctypes看的下载地址为

ctypes库安装时需要使用 python,安装步骤如下

python setup.py build

python setup.py test

python setup.py install

安装glusterfs, 步骤如下:

cd  /home/glusterfs-3.2.0

./configure   --enable-fusermount

make

make install

下来需要进行配置,我这里的环境为 :

server端3台----------- 192.168.2.85  和  192.168.2.222  和  192.168.2.98

client 端1台------------192.168.2.55

配置文件所在的目录为  /etc/glusterfs/

[root@redhat1 glusterfs]# more protocol-server.vol

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

volume brick

type storage/posix                   # POSIX FS translator

option directory /data/movies        # Export this directory

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp      # For TCP/IP transport

option transport.socket.listen-port 24016

# option transport-type ib-verbs # For Infiniband Verbs transport

# 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 transport.ib-verbs.listen-port 24016

#  option bind-address 192.168.1.10     # Default is to listen on all interfaces

# option client-volume-filename /etc/glusterfs/glusterfs-client.vol

subvolumes brick

option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume

end-volume

上面是  服务器端 的配置文件,每台服务器的配置都一样, 共享数据目录为 /data/movies

启动服务器端的命令为  :

glusterfsd  -l  /etc/glusterfs/g.log  -f  /etc/glusterfs/protocol-server.vol

下面的配置文件时客户端的配置文件:

volume client0

type protocol/client

option transport-type tcp     # for TCP/IP transport

# option transport-type ib-sdp  # for Infiniband transport

option remote-host 192.168.2.85     # IP address of the remote brick

option transport.socket.remote-port 24016

# 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 24016

option remote-subvolume brick        # name of the remote volume

# option transport-timeout 30          # default value is 120seconds

end-volume

volume client1

type protocol/client

option transport-type tcp     # for TCP/IP transport

# option transport-type ib-sdp  # for Infiniband transport

option remote-host 192.168.2.222     # IP address of the remote brick

option transport.socket.remote-port 24016

# 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 24016

option remote-subvolume brick        # name of the remote volume

# option transport-timeout 30          # default value is 120seconds

end-volume

volume client2

type protocol/client

option transport-type tcp     # for TCP/IP transport

# option transport-type ib-sdp  # for Infiniband transport

option remote-host 192.168.2.98     # IP address of the remote brick

option transport.socket.remote-port 24016

# 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 24016

option remote-subvolume brick        # name of the remote volume

# option transport-timeout 30          # default value is 120seconds

end-volume

volume unify

type cluster/distribute

subvolumes client0 client1 client2

end-volume

启动客户端的命令为:

glusterfs -l /etc/glusterfs/glusterfs.log -f /etc/glusterfs/protocol-client.vol /mnt

启动后可以检查  /etc/glusterfs/glusterfs.log 文件, 进行查看日志。

也可以用 df  -h 命令来查看,如下代表成功

glusterfs#/etc/glusterfs/protocol-client.vol

654G  133G  487G  22% /mnt

由于glusterfs 使用了 fuse, 所以就和使用本地的一个目录一样使用这个分布式的文件系统了。

不信你就执行一下   :

ls   /mnt

cp  /etc/glusterfs/protocol-client.vol   /mnt

ls  /mnt

祝大家工作愉快 !

在配置的过程中如果有什么问题, 大家还可以参考

http://hi.baidu.com/farmerluo/blog/category/Glusterfs

介绍的还是蛮详细的。

有多种对Gluster配置的方式,此处介绍三种.

1.在一台服务器上建立Distributed Volume

假设服务器为:192.168.113.173(Server)

假设客户端为:192.168.113.179(Client)

首先配置Server,开启gluster服务

Server# modprobe fuse

Server# /etc/init/glusterd start

服务器只有一台,直接创建Volume即可,名为single-volume

Server#gluster volume create single-volume 192.168.113.173:/home/single1

启动volume

Server# gluster volume start single-volume

查看当前所有volume状态

Server# gluster volume info

若要使用Cache,则使用

Server# gluster volume set single-volume performance.cache-size 1GB

Gluster自动生成配置文件,在/etc/glusterd/vols/single-volume/文件夹中

在客户端挂载gluster镜像,客户端直接使用Server端的配置文件,不必创建自己的配置文件了

Client# modprobe fuse

Client# /etc/init/glusterd start

Client# mount.glusterfs 192.168.113.173:/single-volume /mnt/local-volume

2.在两台服务器上建立Distributed Volume

假设服务器A为:192.168.113.173(ServerA)

假设服务器B为:192.168.113.174(ServerB)

假设客户端为:192.168.113.179(Client)

首先配置Server,开启gluster服务

ServerA# modprobe fuse

ServerA# /etc/init/glusterd start

ServerB# modprobe fuse

ServerB# /etc/init/glusterd start

服务器有两台,要先绑定在一起(假设使用ServerA做主服务器)

ServerA# gluster peer probe 192.168.113.174

创建Volume,名为cluster-volume

ServerA# gluster volume create cluster-volume 192.168.113.173:/home/cluster1 192.168.113.174:/home/cluster2

启动volume

ServerA# gluster volume start cluster-volume

查看当前所有volume状态

ServerA# gluster volume info

若要使用Cache,则使用

ServerA# gluster volume set cluster-volume performance.cache-size 1GB

Gluster自动生成配置文件,在/etc/glusterd/vols/cluster-volume/文件夹中

在客户端挂载gluster镜像,客户端直接使用Server端的配置文件,不必创建自己的配置文件了

Client# modprobe fuse

Client# /etc/init/glusterd start

Client# mount.glusterfs 192.168.113.173:/cluster-volume /mnt/local-volume

3.在两台服务器上建立Striped Volume

假设服务器A为:192.168.113.173(ServerA)

假设服务器B为:192.168.113.174(ServerB)

假设客户端为:192.168.113.179(Client)

首先配置Server,开启gluster服务

ServerA# modprobe fuse

ServerA# /etc/init/glusterd start

ServerB# modprobe fuse

ServerB# /etc/init/glusterd start

服务器有两台,要先绑定在一起(假设使用ServerA做主服务器)

ServerA# gluster peer probe 192.168.113.174

创建Volume,名为stripe-volume

ServerA# gluster volume create stripe-volume stripe 2 transport tcp 192.168.113.173:/home/stripe1 192.168.113.174:/home/stripe2

启动volume

ServerA# gluster volume start stripe-volume

查看当前所有volume状态

ServerA# gluster volume info

若要使用Cache,则使用

ServerA# gluster volume set stripe-volume performance.cache-size 1GB

Gluster自动生成配置文件,在/etc/glusterd/vols/stripe-volume/文件夹中

在客户端挂载gluster镜像,客户端直接使用Server端的配置文件,不必创建自己的配置文件了

Client# modprobe fuse

Client# /etc/init/glusterd start

Client# mount.glusterfs 192.168.113.173:/stripe-volume /mnt/local-volume

摘要:GlusterFS是Scale-Out存储解决方案Gluster的核心,它是一个开源的分布式文件系统,具有强大的横向扩展能力,通过扩展能够支持数PB存储容量和处理数千客户端。GlusterFS借助TCP/IP或InfiniBand RDMA网络将物理分布的存储资源聚集在一起,使用单一全局命名空间来管理数据。GlusterFS基于可堆叠的用户空间设计,可为各种不同的数据负载提供优异的性能。

相关阅读:

Glusterfs集群文件系统研究

Glusterfs全局统一命名空间

创建Glusterfs分布式RAID10卷

Glusterfs 3.4 Beta 发布,集群文件系统

Glusterfs Rebalance简析

设计新Xlator扩展GlusterFS

过去一直以为GlusterFS和GFS为同一个东西,真是惭愧。昨天一同事用到才发现它是个好东西!

安装很简单,在所有存储服务器上执行:

yum -y install glusterfs glusterfs-server

chkconfig glusterd on

service glusterd start

将存储节点组合成一个集群,笔者以18节点为例。只需要在任一个节点执行:

gluster peer probe agent21.kisops.org

gluster peer probe agent22.kisops.org

gluster peer probe agent23.kisops.org

gluster peer probe agent24.kisops.org

gluster peer probe agent25.kisops.org

gluster peer probe agent26.kisops.org

gluster peer probe agent27.kisops.org

gluster peer probe agent28.kisops.org

gluster peer probe agent29.kisops.org

gluster peer probe agent30.kisops.org

gluster peer probe agent31.kisops.org

gluster peer probe agent32.kisops.org

gluster peer probe agent33.kisops.org

gluster peer probe agent34.kisops.org

gluster peer probe agent35.kisops.org

gluster peer probe agent36.kisops.org

gluster peer probe agent37.kisops.org

gluster peer probe agent38.kisops.org # 加入新节点

gluster peer status # 查看集群的节点信息

以/data/glusterfs为共享目录,创建一个名为gfs的存储卷,数据复制2份:

gluster volume create gfs replica 2 agent{21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38}.kisops.org:/data/glusterfs  # 创建卷

gluster volume start gfs # 启动卷

gluster volume info # 查看卷信息

gluster volume set gfs auth.allow 10.20.* # 授权访问

uid-22166872-id-4194504.html

OK,此时服务端已配置完毕,过程简单明了!客户端就更简单了:

yum -y install glusterfs glusterfs-fuse

mount -t glusterfs agent38.kisops.org:/gfs /mnt/gfs # 挂载任一节点即可(推荐)

mount.nfs agent38.kisops.org:/gfs /mnt/nfs -o nfsvers=3,proto=tcp # 使用NFS挂载,注意远端的rpcbind服务必须开启

mount -t nfs -o rw,nfsvers=3,proto=tcp,port=38465,nolock,noacl,nocto,noatime,nodiratime,rsize=131072,wsize=524288,async,soft,bg,acregmin=3,acregmax=10,acdirmin=1,acdirmax=5 agent21.kisops.org:/gfs /mnt/nfs # 标准挂法

# 若需要开机自动挂载,请更新/etc/fstab,追加:

agent38.kisops.org:/gfs /mnt/gfs glusterfs defaults,_netdev 0 1

uid-22166872-id-4194504.html

GlusterFS分布式存储

一、简介

Glusterfs是一个具有可以扩展到几个PB数量级的集群文件系统。它可以把多个不同类型的存储块通过Infiniband RDMA或者TCP/IP汇聚成一个大的并行网络文件系统。

注:InfiniBand架构是一种支持多并发链接的“转换线缆”技术。InfiniBand技术不是用于一般网络连接的,它的主要设计目的是针对服务器端的连接问题的。因此,InfiniBand技术将会被应用于服务 器与服务器(比如复制,分布式工作等),服务器和存储设备(比如SAN和直接存储附件)以及服务器和网络之间(比如LAN, WANs和the Internet)的通信。

Effective theoretical throughput in different configurations

Single ()

Double ()

Quad ()

1X

2 Gbit/s

4 Gbit/s

8 Gbit/s

4X

8 Gbit/s

16 Gbit/s

32 Gbit/s

12X

24 Gbit/s

48 Gbit/s

96 Gbit/s

二、测试环境介绍

uid-22166872-id-4194504.html

测试服务器共2台:GLUSTERFS1和GLUSTERFS2,安装CentOS5.3。其中GLUSTERFS1扮演CLIENT和SERVER双重角色,GLUSTERFS2只扮演SERVER角色。(注:在GlusterFS中,Server角色主要将服务器中文件夹声明成存储单元,而Client通过配置相应的Translator实现复制、分布式存储的功能。Client亦可是一台单独的服务器)

存储单元:在GLUSTERFS1和GLUSTERFS2中分别声明出BRICK-A和BRICK-B两个存储单元

预期达成效果:希望能实现类似硬盘RAID1+0的效果,就是说先将两台服务器的BRICK-A做一个镜像,然后再此基础上做一个分散式存储,并mount到一个叫glusterfs的文件夹供用户使用。

三、安装部署

1.下载/安装源码

? FUSE(Filesystem in Userspace):

– fuse-2.7.4.tar.gz

? GlusterFS:

– glusterfs-2.0.8.tar.gz

解压后在相应数据夹下执行命令配置、编译及安装FUSE和GlusterFS:

./configure

make

make install

2.建立相关文件夹

在GLUSTER1建立export-a、export-b、glusterfs

#mkdir /data/export-a

#mkdir /data/export-b

#mkdir /mnt/glusterfs

在GLUSTER2建立export-a、export-b

#mkdir /data/export-a

#mkdir /data/export-b

3.分别在两台GLUSTERFS1和GLUSTERFS2完成GlusterFS Server端配置档编写

#vim /etc/glusterfs/glusterfsd.vol

volume posix-a

type storage/posix

option directory /data/export-a

end-volume

volume locks-a

type features/locks

subvolumes posix-a

end-volume

volume brick-a

type performance/io-threads

option thread-count 8

subvolumes locks-a

end-volume

volume posix-b

type storage/posix

option directory /data/export-b

end-volume

volume locks-b

type features/locks

subvolumes posix-b

end-volume

volume brick-b

type performance/io-threads

option thread-count 8

subvolumes locks-b

end-volume

volume server

type protocol/server

option transport-type tcp

option auth.addr.brick-a.allow *

option auth.addr.brick-b.allow *

subvolumes brick-a brick-b

end-volume

4.在GLUSTERFS1完成GlusterFS Client端配置档编写

#vim /etc/glusterfs/glusterfs.vol

volume brick-1a

type protocol/client

option transport-type tcp/client

option remote-host 10.167.10.118 # IP address of the remote brick

option remote-subvolume brick-a # name of the remote volume

end-volume

### Add client feature and attach to remote brick-a subvolume of server2

volume brick-2a

type protocol/client

option transport-type tcp/client

option remote-host 10.167.10.119 # IP address of the remote brick

option remote-subvolume brick-a # name of the remote volume

end-volume

### Add client feature and attach to remote brick-b subvolume of server1

volume brick-1b

type protocol/client

option transport-type tcp/client

option remote-host 10.167.10.118 # IP address of the remote brick

option remote-subvolume brick-b # name of the remote volume

end-volume

### Add client feature and attach to remote brick-b subvolume of server2

volume brick-2b

type protocol/client

option transport-type tcp/client

option remote-host 10.167.10.119 # IP address of the remote brick

option remote-subvolume brick-b # name of the remote volume

end-volume

#The replicated volume with brick-a

volume replication1

type cluster/replicate

subvolumes brick-1a brick-2a

end-volume

#The replicated volume with brick-b

volume replication2

type cluster/replicate

subvolumes brick-1b brick-2b

end-volume

#The distribution of all replication volumes (used for > 2 servers)

volume distribution

type cluster/distribute

option lookup-unhashed yes

subvolumes replication1 replication2

end-volume

5.分别在GLUSTERFS1和GLUSTERFS2中运行GlusterFS Server端

[root@glusterfs1]#glusterfs –f /etc/glusterfs/glusterfsd.vol –l /tmp/glusterfsd.log

[root@glusterfs1]#tail /tmp/glusterfsd.log

[2009-11-16 17:11:04] N [glusterfsd.c:1306:main] glusterfs: Successfully started

[root@glusterfs1]# #netstat –tl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State

tcp        0      0 *:ideafarm-catch            *:*                         LISTEN

tcp        0      0 *:netbios-ssn               *:*                         LISTEN

tcp        0      0 *:sunrpc                    *:*                         LISTEN

tcp        0      0 *:6996                      *:*                         LISTEN

tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN

tcp        0      0 localhost.localdomain:smtp *:*                         LISTEN

tcp        0      0 *:microsoft-ds              *:*                         LISTEN

tcp        0      0 *:http                      *:*                         LISTEN

tcp        0      0 *:ssh                       *:*                         LISTEN

tcp        0      0 *:https                     *:*                         LISTEN

成功启动后,系统中出现6996监听端口。

6.在GLUSTERFS1中运行GlusterFS Client端

#glusterfs –f /etc/glusterfs/glusterfs.vol –l /tmp/glusterfs.log /mnt/glusterfs

#df –h

Filesystem            Size Used Avail Use% Mounted on

/dev/sda2             9.5G 3.8G 5.3G 42% /

/dev/sda5              20G 522M   18G   3% /home

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

tmpfs                 506M     0 506M   0% /dev/shm

glusterfs#/etc/glusterfs/glusterfs.vol

19G 7.5G   11G 42% /mnt/glusterfs

成功运行后, 就可以通过/mnt/glusterfs来访问了。

下期预告:针对GlusterFS进行简单的功能测试。

GlusterFS分布式存储(二)Replicate功能测试

一、前言

此次主要针对GlusterFS中的Replicate进行可用性和恢复性测试。

uid-22166872-id-4194504.html

二、测试过程

1.模拟系统故障,关闭GLUSTERFS1上的Glusterfs Server和Glusterfs Client,删除GLUSTERFS1中BRICK-A和BRICK-B中文件。

2.在GLUSTERFS2上启动Glusterfs Client

3.检查文件服务可用性:文件读取及存储操作正常。

4.重新启动GLUSTERFS1并启动Glusterfs Server,检查系统可用性:无法查看目录中文件列表;但可以通过文件完整路径,访问文件。

5.变更replicate中的主副关系,在GLUSTERFS2中修改/etc/glusterfs/glusterfs.vol

#The replicated volume with brick-a

volume replication-a

type cluster/replicate

subvolumes brick-2a brick-1a

end-volume

#The replicated volume with brick-b

volume replication-b

type cluster/replicate

subvolumes brick-2b brick-1b

end-volume

6.重建GLUSTERFS1中数据:启动GLUSTERFS1的Glusterfs Server,系统完成自我修复(ls -lR)。

7.检查系统恢复情况,确认数据完整性:文件恢复成功

三、测试结论

1.可用性测试结论

? 作为访问入口的Glusterfs Client不存在单点失败问题,可在不同服务器中启动。

? 文件存取不存在单点失败的问题:任何一台subvolume失败,都不影响文件的读取和写入。

2.恢复性测试结论

? 用新的subvolume替换损坏的subvolume时

– 当浏览目录的时候,自我修复机制启动,会将当前目录下文件复制到新的subvolume中。

– 如想强制所有目录全部自我修复,需遍历所有目录,例如使用命令 ls –lR

? 当损坏的subvolume为主subvolume:

– 如果某个文件不在主subvolume,但存在于其它的subvolume,通过入口是无法看到此文件的。此时自我修复无法通过浏览目录启动。

– 但是如果已知道此文件名称,还是可以访问此文件并自我修复的。换句话说,在自我修复过程中,系统的读取和写入不受影响。

– 可以架设一台Glusterfs Client专门负责自我修复工作,此台Glusterfs Client会调换subvolume的主从关系

本文环境:一台服务器,一台测试机均为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

uid-22166872-id-4194504.html

[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

Unify模式简介:

多台server目前空余的硬盘空间利用起来。这就是glusterfsUnify模式的功能,多存储空间的聚合。

本文环境:二台服务器,一台测试机均为CentOS-5.2操作系统,

服务器1的ip为:192.168.10.252,共享目录/home/gluterfs和/data3

服务器2的Ip为:192.168.10.253 , 共享目录是/data和/data2

测试机的ip为192.168.10.14 , 挂载点为/mnt

一 服务器1的安装和配置

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-2.0.0rc1.tar.gz

[root@test-1 ~]# cd glusterfs-2.0.0rc1

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

uid-22166872-id-4194504.html

[root@test-1 ~]# make

[root@test-1 ~]# make install

4.创建本地的共享点1

[root@test-1 ~]# mkdir /data

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

5.创建本地输出目录2

[root@test-1 ~]#touch /data2

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

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

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

[root@test-1 ~]# mkdir bak

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

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

volume brick

type storage/posix # POSIX FS translator

option directory /home/gluster # Export this directory

end-volume

volume brick-ns

type storage/posix

option directory /data3

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp/server

subvolumes brick brick-ns

option auth.addr.brick.allow *

option auth.addr.brick-ns.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]#

二 服务器端2的安装和配置

1.首先安装fuse扩展

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

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

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

[root@test-2~]# make

[root@test-2~]# make install

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

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

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

3.安装服务器端

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

[root@test-2~]# tar zvxf glusterfs-2.0.0rc1.tar.gz

[root@test-2~]# cd glusterfs-2.0.0rc1

[root@test-2~]# ./configure

uid-22166872-id-4194504.html

[root@test-2~]# make

[root@test-2~]# make install

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

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

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

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

5.创建本地输出目录2

[root@test-2~]#touch /data3

[root@test-2~]# chmod 777 /data3

6.查看挂载是否正常

[root@test-2~]# 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

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

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

[root@test-2~]# mkdir bak

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

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

volume brick

type storage/posix # POSIX FS translator

option directory /data # Export this directory

end-volume

volume brick-ns

type storage/posix

option directory /data2

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp/server

subvolumes brick brick-ns

option auth.addr.brick.allow *

option auth.addr.brick-ns.allow *

end-volume

8. 启动服务器端

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

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

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

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

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

[root@test-2glusterfs]#

三 客户端的安装和配置

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

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

[root@localhost glusterfs]# mkdir bak

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

[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 brick

end-volume

volume client2

type protocol/client

option transport-type tcp/client

option remote-host 192.168.10.253 #//server ip

option remote-port 6996

option remote-subvolume brick

end-volume

volume client1-ns

type protocol/client

option transport-type tcp/client

option remote-host 192.168.10.252

option remote-subvolume brick-ns

end-volume

volume unify

type cluster/unify

subvolumes client1 client2

option namespace client1-ns

option scheduler rr

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.1G 3.4G 39% /

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

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

glusterfs 11G 3.2G 7.2G 31% /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.在服务器1的共享点上创建文件

[root@test-1 ~]# cd /data3

[root@test-1 data3]# touch data3

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

[root@test-1 gluster]# touch gluster

[root@test-1 gluster]#

2.在服务器2的共享点上创建文件

[root@test-2 data]# cd /data

[root@test-2 data]# touch data

[root@test-2 data]# cd /data2

[root@test-2 data2]# touch data2

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

[root@localhost mnt]# ls

data data3 gluster data2

[root@localhost mnt]#

Replacte模式简介:

为提供了类似RAID-1的功能。Replicate会复制文件或者文件夹到各个subvolumes里。因此,如果replicate部分设置了4个subvolume,那就会4分的文件或者文件夹的拷贝副本。replicate同样提供了高可用,比如如果其中的一个subvolume down掉了(或者说一台存储服务器坏了,网络连接出现问题)replicate依然可以使用冗余的拷贝副本来提供服务。

Replicate同样提供了自动修复功能,比如,如果一台crash掉的服务器恢复了,这台服务器上存储的过期的文件或者文件夹就会被更新成最新的版本。Replicate使用了后端文件系统的扩展功能来跟踪文件或者文件夹的版本来提供自动恢复的功能

本文环境:二台服务器,一台测试机均为CentOS-5.2操作系统,

服务器1的ip为:192.168.10.252,共享目录/home/gluterfs

服务器2的Ip为:192.168.10.253 , 共享目录是/data

测试机的ip为192.168.10.14 , 挂载点为/mnt

一 服务器1的安装和配置

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-2.0.0rc1.tar.gz

[root@test-1 ~]# cd glusterfs-2.0.0rc1

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

uid-22166872-id-4194504.html

[root@test-1 ~]# make

[root@test-1 ~]# make install

4.创建本地的共享点1

[root@test-1 ~]# mkdir /data

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

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

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

[root@test-1 ~]# mkdir bak

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

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

volume brick

type storage/posix # POSIX FS translator

option directory /data

end-volume

volume locker

type features/posix-locks

subvolumes brick

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp/server

subvolumes locker

option auth.addr.brick.allow * # Allow access to "brick" volume

option auth.addr.locker.allow *

end-volume

6. 启动服务器端

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

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

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

[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]#

二 服务器端2的安装和配置

1.首先安装fuse扩展

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

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

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

[root@test-2~]# make

[root@test-2~]# make install

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

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

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

3.安装服务器端

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

[root@test-2~]# tar zvxf glusterfs-2.0.0rc1.tar.gz

[root@test-2~]# cd glusterfs-2.0.0rc1

[root@test-2~]# ./configure

uid-22166872-id-4194504.html

[root@test-2~]# make

[root@test-2~]# make install

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

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

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

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

5.查看挂载是否正常

[root@test-2~]# 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-2~]#cd /usr/local/etc/glusterfs

[root@test-2~]# mkdir bak

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

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

volume brick

type storage/posix # POSIX FS translator

option directory /home/gluster

end-volume

volume locker

type features/posix-locks

subvolumes brick

end-volume

### Add network serving capability to above brick.

volume server

type protocol/server

option transport-type tcp/server

subvolumes locker

option auth.addr.brick.allow * # Allow access to "brick" volume

option auth.addr.locker.allow *

end-volume

7. 启动服务器端

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

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

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

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

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

[root@test-2glusterfs]#

三 客户端的安装和配置

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

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

[root@localhost glusterfs]# mkdir bak

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

[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 client2

type protocol/client

option transport-type tcp/client

option remote-host 192.168.10.253 #//server ip

option remote-port 6996

option remote-subvolume locker

end-volume

volume bricks

type cluster/replicate

subvolumes client1 client2

end-volume

2.首先挂载fuse模块

[root@localhost glusterfs]#modprobe fuse

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

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

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

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

[root@localhost glusterfs]# df –h

Filesystem Size Used Avail Use% Mounted on

/dev/hda2 5.7G 2.1G 3.4G 39% /

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

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

glusterfs 11G 3.2G 7.2G 31% /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@localhost mnt]# cd /mnt

[root@localhost mnt]# touch test

2.然后再两个服务器端查看,可以看到2个服务器同时产生了副本

[root@test-1 gluster]# cd /home/gluster/(服务器-1)

[root@test-1 gluster]# ls

test

[root@test-2 data]# cd /data(服务器-2)

[root@test-2 data]# ls

test

3.挂掉服务器端1,然手再续在客户端创建新文件

[root@test-1 gluster]# kill -9 `cat /var/run/glusterfs.pid`(服务器-1)

[root@localhost mnt]# touch test2

[root@localhost mnt]# ls

test test2

[root@localhost mnt]#

4.然后分别查看两个服务器端的数据变换

[root@test-1 gluster]# cd /home/gluster/(服务器-1)

[root@test-1 gluster]# ls

test

[root@test-2 data]# cd /data(服务器-2)

[root@test-2 data]# ls

test test2

5.现在启动服务器-1,然后查看数据是否同步过来

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

[root@test-1 gluster]# cd /home/gluster/(服务器-1)

[root@test-1 gluster]# ls

test(暂时无变化)

6.现在在客户端重新查询一下数据,以把请求复制到服务器-1上,这样两个服务器的内容就一致了

[root@localhost mnt]# cd /mnt

[root@localhost mnt]# ls

test test2

7.到服务器-1上看test2文件是否已经复制过来了

[root@test-1 gluster]# cd /home/gluster/(服务器-1)

[root@test-1 gluster]# ls

test test2(已经复制成功)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值