Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1492369
  • 博文数量: 230
  • 博客积分: 474
  • 博客等级: 下士
  • 技术积分: 1955
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 18:40
文章分类

全部博文(230)

文章存档

2020年(3)

2019年(3)

2018年(12)

2017年(13)

2016年(11)

2015年(55)

2014年(74)

2013年(39)

2012年(2)

2011年(18)

我的朋友

分类: 云计算

2014-04-03 11:22:36

我的系统是 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/



[html] view plaincopy
  1. [root@redhat1 glusterfs]# more protocol-server.vol   
  2.   
  3. ### Export volume "brick" with the contents of "/home/export" directory.  
  4. volume brick  
  5.   type storage/posix                   # POSIX FS translator  
  6.   option directory /data/movies        # Export this directory  
  7. end-volume  
  8.   
  9. ### Add network serving capability to above brick.  
  10. volume server  
  11.   type protocol/server  
  12.   option transport-type tcp      # For TCP/IP transport  
  13.   option transport.socket.listen-port 24016                
  14.   
  15. # option transport-type ib-verbs # For Infiniband Verbs transport  
  16. # option transport.ib-verbs.work-request-send-size  131072  
  17. # option transport.ib-verbs.work-request-send-count 64  
  18. # option transport.ib-verbs.work-request-recv-size  131072  
  19. # option transport.ib-verbs.work-request-recv-count 64  
  20. # option transport.ib-verbs.listen-port 24016                
  21.   
  22. #  option bind-address 192.168.1.10     # Default is to listen on all interfaces  
  23. # option client-volume-filename /etc/glusterfs/glusterfs-client.vol  
  24.   subvolumes brick   
  25.   option auth.addr.brick.allow 192.168.* # Allow access to "brick" volume  
  26. end-volume  


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

启动服务器端的命令为  :

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


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


[html] view plaincopy
  1. volume client0  
  2.   type protocol/client  
  3.   option transport-type tcp     # for TCP/IP transport  
  4. # option transport-type ib-sdp  # for Infiniband transport  
  5.   option remote-host 192.168.2.85     # IP address of the remote brick  
  6.   option transport.socket.remote-port 24016                
  7.   
  8. # option transport-type ib-verbs # for Infiniband verbs transport  
  9. # option transport.ib-verbs.work-request-send-size  1048576  
  10. # option transport.ib-verbs.work-request-send-count 16  
  11. # option transport.ib-verbs.work-request-recv-size  1048576  
  12. # option transport.ib-verbs.work-request-recv-count 16  
  13. # option transport.ib-verbs.remote-port 24016                
  14.   
  15.   option remote-subvolume brick        # name of the remote volume  
  16. # option transport-timeout 30          # default value is 120seconds   
  17. end-volume  
  18.   
  19. volume client1  
  20.   type protocol/client  
  21.   option transport-type tcp     # for TCP/IP transport  
  22. # option transport-type ib-sdp  # for Infiniband transport  
  23.   option remote-host 192.168.2.222     # IP address of the remote brick  
  24.   option transport.socket.remote-port 24016  
  25.   
  26. # option transport-type ib-verbs # for Infiniband verbs transport  
  27. # option transport.ib-verbs.work-request-send-size  1048576  
  28. # option transport.ib-verbs.work-request-send-count 16  
  29. # option transport.ib-verbs.work-request-recv-size  1048576  
  30. # option transport.ib-verbs.work-request-recv-count 16  
  31. # option transport.ib-verbs.remote-port 24016  
  32.   
  33.   option remote-subvolume brick        # name of the remote volume  
  34. # option transport-timeout 30          # default value is 120seconds  
  35. end-volume  
  36.   
  37.   
  38. volume client2  
  39.   type protocol/client  
  40.   option transport-type tcp     # for TCP/IP transport  
  41. # option transport-type ib-sdp  # for Infiniband transport  
  42.   option remote-host 192.168.2.98     # IP address of the remote brick  
  43.   option transport.socket.remote-port 24016  
  44.   
  45. # option transport-type ib-verbs # for Infiniband verbs transport  
  46. # option transport.ib-verbs.work-request-send-size  1048576  
  47. # option transport.ib-verbs.work-request-send-count 16  
  48. # option transport.ib-verbs.work-request-recv-size  1048576  
  49. # option transport.ib-verbs.work-request-recv-count 16  
  50. # option transport.ib-verbs.remote-port 24016  
  51.   
  52.   option remote-subvolume brick        # name of the remote volume  
  53. # option transport-timeout 30          # default value is 120seconds  
  54. end-volume  
  55.   
  56.   
  57. volume unify  
  58. type cluster/distribute  
  59. subvolumes client0 client1 client2  
  60. 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.* # 授权访问

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




GlusterFS分布式存储  

2011-04-02 16:08:21|  分类: 分布式数据系统 |  标签:brick  subvolume  分布式  remote  glusterfs1  |举报|字号 订阅

一、简介


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


二、测试环境介绍



GlusterFS分布式存储 - zhuzhu - 五事九思


测试服务器共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进行可用性和恢复性测试。

本次测试的架构图,安装配置过程详见《GlusterFS分布式存储(一)功能简介及安装hi.baidu.com/imlidapeng/blog/item/8d2df0ced1c6e85a0eb34551.html

GlusterFS分布式存储 - zhuzhu - 五事九思

二、测试过程

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

clip_image002

[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

clip_image002

[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

clip_image002[1]

[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
clip_image002
[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
clip_image002[1]
[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(已经复制成功)

阅读(10626) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~