glusterfs文件系统安装配置

yum -y install flex fuse bison openssl* python-ctypes
wget http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.1/glusterfs-3.3.1.tar.gz
tar -zxvf cd glusterfs-3.3.1.tar.gz && cd cd glusterfs-3.3.1
./configure -enable-dependency-tracking -enable-lib -enable-util -enable-kernel-module -prefix=/usr/local/glusterfs && make && make install
mkdir /home/glusterfs && chmod 777 /home/glusterfs
##################################################
cd /usr/src/ && tar -zxvf glusterfs-3.3.1.tar.gz && cd glusterfs-3.3.1 && ./configure -enable-dependency-tracking -enable-lib -enable-util -enable-kernel-module -prefix=/usr/local/glusterfs && make && make install && cd /usr/local/glusterfs/etc/glusterfs/ && mkdir /home/glusterfs && chmod 777 /home/glusterfs
##################################################
server: #服务器端配置文件
[root@os-1 glusterfs]# cat glusterd.vol
volume posix
    type storage/posix
    option directory /home/glusterfs    #共享目录
end-volume

volume locks
    type features/locks            #启用锁
    subvolumes posix
end-volume

volume brick                    #io线程
    type performance/io-threads
    option thread-count 8
    subvolumes locks
end-volume

volume server                    #服务器模式 允许所有IP访问
    type protocol/server
    option transport-type tcp
    subvolumes brick
    option auth.addr.brick.allow *
end-volume

启动server:
/usr/local/glusterfs/sbin/glusterd -l /var/log/glusterfs.log -p /var/run/glusterfs.pid -f /usr/local/glusterfs/etc/glusterfs/glusterd.vol

mount posrt:    #客户端配置
[root@test1 glusterfs]# cat glusterd.vol
volume brick0    #第一个server叫brick0 以此类推此处是10个点
type protocol/client
option transport-type tcp
option remote-host 192.168.10.151
option remote-subvolume brick
end-volume

volume brick1
type protocol/client
option transport-type tcp
option remote-host 192.168.10.152
option remote-subvolume brick
end-volume

volume brick2
type protocol/client
option transport-type tcp
option remote-host 192.168.10.153
option remote-subvolume brick
end-volume

volume brick3
type protocol/client
option transport-type tcp
option remote-host 192.168.10.154
option remote-subvolume brick
end-volume

volume brick4
type protocol/client
option transport-type tcp
option remote-host 192.168.10.155
option remote-subvolume brick
end-volume

volume brick5
type protocol/client
option transport-type tcp
option remote-host 192.168.10.156
option remote-subvolume brick
end-volume

volume brick6
type protocol/client
option transport-type tcp
option remote-host 192.168.10.157
option remote-subvolume brick
end-volume

volume brick7
type protocol/client
option transport-type tcp
option remote-host 192.168.10.158
option remote-subvolume brick
end-volume

volume brick8
type protocol/client
option transport-type tcp
option remote-host 192.168.10.159
option remote-subvolume brick
end-volume

volume brick9
type protocol/client
option transport-type tcp
option remote-host 192.168.10.160
option remote-subvolume brick
end-volume

volume afr1    #复制模式,brick0和1做镜像
type cluster/replicate
subvolumes brick0 brick1
end-volume

volume afr2
type cluster/replicate
subvolumes brick2 brick3
end-volume

volume afr3
type cluster/replicate
subvolumes brick4 brick5
end-volume

volume afr4
type cluster/replicate
subvolumes brick6 brick7
end-volume

volume afr5
type cluster/replicate
subvolumes brick8 brick9
end-volume

volume unify    #分配设置,将数据分散放置在1-5个复制模式的配置中
type cluster/distribute
subvolumes afr1 afr2 afr3 afr4 afr5
end-volume

挂载unify到/glufterfs目录
/usr/local/glusterfs/sbin/glusterfs -l /var/log/glusterfs.log -f /usr/local/glusterfs/etc/glusterfs/glusterd.vol /glusterfs/


###########################################################################################
7.    GlusterFS常用translators(中继)

7.1.1.    storage/posix

type storage/posix
storage/posix的作用是指定一个本地目录给GlusterFS内的一个卷使用。
配置例子:
volume posix-example
type storage/posix
option directory /sda4
end-volume

7.1.2.    protocol/server (服务器)

type protocol/server
服务器中继(protocol/server)表示本节点在GlusterFS中为服务器模式。
配置例子:
volume server-example
type protocol/server
option transport-type tcp
subvolumes brick                #定义好的卷
option auth.addr.brick.allow *  #指定可访问本卷的访问者,*为所有,可对访问者做限制,如192.168.1.*
end-volume

7.1.3.    protocol/client (客户端)

type protocol/client
客户端中继(protocol/server)用于客户端连接服务器时使用。
配置例子:
volume client-example
type protocol/client
option transport-type tcp
option remote-host 192.168.1.13    #连接的服务器
option remote-subvolume brick      #连接的服务器卷名
end-volume

7.1.4.    cluster/replicate(复制)

type cluster/replicate
复制中继(cluster/replicate,前身是AFR)为GlusterFS提供了类似RAID-1的功能。
Replicate会复制文件或者文件夹到各个subvolumes里。如一个卷(volume)内有两个子卷(subvolume),那就会有两份文件或文件夹的复本。
Replicate只时还有高可用的功能,如果两个子卷中有一个子卷挂了,卷依然可以正常工作。当这个子卷重新启用时,会自动更新丢失的文件或文件夹,不过更新是通过客户端进行的。
配置例子:
volume replicate-example
type cluster/replicate
subvolumes brick3 brick4
end-volume

7.1.5.    cluster/distribute (分布式)

type cluster/distribute
分布式中继(cluster/distribute,前身是unify)为GlusterFS提供了类似RAID-0的功能。
Distribute可把两个卷或子卷组成一个大卷,实现多存储空间的聚合
配置例子:
volume distribute-example
type cluster/distribute
subvolumes repl1 repl2
end-volume

7.1.6.    features/locks (锁)

type features/locks
锁中继(features/locks)只能用于服务器端的posix中继之上,表示给这个卷提供加锁(fcntl locking)的功能。
配置例子:
volume locks-example
type features/locks
subvolumes posix-example
end-volume

7.1.7.    performance/read-ahead (预读)

type performance/read-ahead
预读中继(performance/read-ahead)属于性能调整中继的一种,用预读的方式提高读取的性能。
读取操作前就预先抓取数据。这个有利于应用频繁持续性的访问文件,当应用完成当前数据块读取的时候,下一个数据块就已经准备好了。
额外的,预读中继也可以扮演读聚合器,许多小的读操作被绑定起来,当成一个大的读请求发送给服务器。
预读处理有page-size和page-count来定义,page-size定义了,一次预读取的数据块大小,page-count定义的是被预读取的块的数量
不过官方网站上说这个中继在以太网上没有必要,一般都能跑满带宽。主要是在IB-verbs或10G的以太网上用。
配置例子:
volume readahead-example
type performance/read-ahead
option page-size  256         # 每次预读取的数据块大小
option page-count 4           # 每次预读取数据块的数量
option force-atime-update off #是否强制在每次读操作时更新文件的访问时间,不设置这个,访问时间将有些不精确,这个将影响预读转换器读取数据时的那一时刻而不是应用真实读到数据的那一时刻。
subvolumes <x>
end-volume

7.1.8.    performance/write-behind (回写)

type performance/write-behind
回写中继(performance/read-ahead)属于性能调整中继的一种,作用是在写数据时,先写入缓存内,再写入硬盘。以提高写入的性能。
回写中继改善了了写操作的延时。它会先把写操作发送到后端存储,同时返回给应用写操作完毕,而实际上写的操作还正在执行。使用后写转换器就可以像流水线一样把写请求持续发送。这个后写操作模块更适合使用在client端,以期减少应用的写延迟。
回写中继同样可以聚合写请求。如果aggregate-size选项设置了的话,当连续的写入大小累积起来达到了设定的值,就通过一个写操作写入到存储上。这个操作模式适合应用在服务器端,以为这个可以在多个文件并行被写入磁盘时降低磁头动作。
配置例子:
volume write-behind-example
type performance/write-behind
option cache-size 3MB    # 缓存大小,当累积达到这个值才进行实际的写操作
option flush-behind on   # 这个参数调整close()/flush()太多的情况,适用于大量小文件的情况
subvolumes <x>
end-volume

7.1.9.    performance/io-threads (IO线程)

type performance/io-threads
IO线程中继(performance/io-threads)属于性能调整中继的一种,作用是增加IO的并发线程,以提高IO性能。
IO线程中继试图增加服务器后台进程对文件元数据读写I/O的处理能力。由于GlusterFS服务是单线程的,使用IO线程转换器可以较大的提高性能。这个转换器最好是被用于服务器端,而且是在服务器协议转换器后面被加载。
IO线程操作会将读和写操作分成不同的线程。同一时刻存在的总线程是恒定的并且是可以配置的。
配置例子:
volume iothreads
type performance/io-threads
option thread-count 32 # 线程使用的数量
subvolumes <x>
end-volume

7.1.10.    performance/io-cache (IO缓存)

type performance/io-cache
IO缓存中继(performance/io-threads)属于性能调整中继的一种,作用是缓存住已经被读过的数据,以提高IO性能。
IO缓存中继可以缓存住已经被读过的数据。这个对于多个应用对同一个数据多次访问,并且如果读的操作远远大于写的操作的话是很有用的(比如,IO缓存很适合用于提供web服务的环境,大量的客户端只会进行简单的读取文件的操作,只有很少一部分会去写文件)。
当IO缓存中继检测到有写操作的时候,它就会把相应的文件从缓存中删除。
IO缓存中继会定期的根据文件的修改时间来验证缓存中相应文件的一致性。验证超时时间是可以配置的。
配置例子:
volume iothreads
type performance/ io-cache
option cache-size 32MB  #可以缓存的最大数据量
option cache-timeout 1  #验证超时时间,单位秒
option priority   *:0   #文件匹配列表及其设置的优先级
subvolumes <x>
end-volume

7.1.11.    其它中继

其它中继还有
cluster/nufa(非均匀文件存取)
cluster/stripe(条带,用于大文件,分块存储在不用服务器)
cluster/ha(集群)
features/filter(过滤)
features/trash(回收站)
path-converter
quota
老的还有:
cluster/unify(和distribute,可定义不同的调度器,以不同方式写入数据)

8.    GlusterFS配置

8.1.    服务器端配置

服务器为6台,IP分别是192.168.1.11~192.168.1.16。配置为:
# vi /etc/glusterfs/glusterfsd.vol
volume posix
type storage/posix
option directory /sda4
end-volume

volume locks
type features/locks
subvolumes posix
end-volume

volume brick
type performance/io-threads
option thread-count 8
subvolumes locks
end-volume

volume server
type protocol/server
option transport-type tcp
subvolumes brick
option auth.addr.brick.allow *
end-volume
保存后启动GlusterFS:
# service glusterfsd start

8.2.    客户端配置

服务器为192.168.1.17和192.168.1.18:
# vi /etc/glusterfs/glusterfs.vol
volume brick1
type protocol/client
option transport-type tcp
end-volume

volume brick2
type protocol/client
option transport-type tcp
option remote-host 192.168.1.12
option remote-subvolume brick
end-volume

volume brick3
type protocol/client
option transport-type tcp
option remote-host 192.168.1.13
option remote-subvolume brick
end-volume

volume brick4
type protocol/client
option transport-type tcp
option remote-host 192.168.1.14
option remote-subvolume brick
end-volume

volume brick5
type protocol/client
option transport-type tcp
option remote-host 192.168.1.15
option remote-subvolume brick
end-volume

volume brick6
type protocol/client
option transport-type tcp
option remote-host 192.168.1.16
option remote-subvolume brick
end-volume

volume afr1
type cluster/replicate
subvolumes brick1 brick2
end-volume

volume afr2
type cluster/replicate
subvolumes brick3 brick4
end-volume

volume afr3
type cluster/replicate
subvolumes brick5 brick6
end-volume

volume unify
type cluster/distribute
subvolumes afr1 afr2 afr3
end-volume

GlusterFS的主要配置都在客户端上,上面配置文件的意思是把6台服务器分成3个replicate卷,再用这3个replicate卷做成一个distribute,提供应用程序使用。

8.3.    GlusterFS挂载

GlusterFS挂载为在客户端上执行:
# glusterfs -f /etc/glusterfs/glusterfs.vol /gmnt/ -l /var/log/glusterfs/glusterfs.log
-f /etc/glusterfs/glusterfs.vol为指定GlusterFS的配置文件
/gmnt是挂载点
-l /var/log/glusterfs/glusterfs.log为日志
另外,GlusterFS也可以结果fstab或autofs方式开机挂载。挂载后就可以在/gmnt内读写文件了,用法与读写本地硬盘一样。


9.    GlusterFS性能测试

9.1.    单客户端测试

测试1:复制大约2.5G容量 /usr目录至GlusterFS(大部分都是小文件)
测试结果:
glusterfs    1361KB/s
本地硬盘   2533KB/s

测试2: 复制一个3.8G的文件至GlusterFS
测试结果:
glusterfs     2270KB/s
本地硬盘    10198KB/s

测试3:读取测试2复制的大文件(cat xxx.iso > /dev/null)
测试结果:
glusterfs     11.2MB/s(基本跑满100M带宽)
本地硬盘    45.6MB/s

9.2.    双客户端测试

测试1:在两个客户端上同时复制大约2.5G容量 /usr目录至GlusterFS(大部分都是小文件)
测试结果:
192.168.1.17:glusterfs   1438KB/s
192.168.1.18:glusterfs   1296KB/s

测试2: 在两个客户端上同时复制一个3.8G的文件至GlusterFS
测试结果:
192.168.1.17:glusterfs    2269KB/s
192.168.1.18:glusterfs    2320KB/s


9.3.    配置回写功能后的测试

9.3.1.    服务器配置

volume posix
type storage/posix
option directory /sda4
end-volume

volume locks
type features/locks
subvolumes posix
end-volume

volume writebehind
type performance/write-behind
option cache-size   16MB
option flush-behind on
subvolumes locks
end-volume

volume brick
type performance/io-threads
option thread-count 64
subvolumes writebehind
end-volume

volume server
type protocol/server
option transport-type tcp
option auth.addr.brick.allow * # Allow access to "brick" volume
end-volume

9.3.2.    客户端配置

volume brick1
type protocol/client
option transport-type tcp
option remote-host 192.168.1.11      # IP address of the remote brick
option remote-subvolume brick        # name of the remote volume
end-volume

volume brick2
type protocol/client
option transport-type tcp
option remote-host 192.168.1.12
option remote-subvolume brick
end-volume

volume brick3
type protocol/client
option transport-type tcp
option remote-host 192.168.1.13
option remote-subvolume brick
end-volume

volume brick4
type protocol/client
option transport-type tcp
option remote-host 192.168.1.14
option remote-subvolume brick
end-volume

volume brick5
type protocol/client
option transport-type tcp
option remote-host 192.168.1.15
option remote-subvolume brick
end-volume

volume brick6
type protocol/client
option transport-type tcp
option remote-host 192.168.1.16
option remote-subvolume brick
end-volume

volume afr1
type cluster/replicate
subvolumes brick1 brick2
end-volume

volume afr2
type cluster/replicate
subvolumes brick3 brick4
end-volume

volume afr3
type cluster/replicate
subvolumes brick5 brick6
end-volume

volume wb1
type performance/write-behind
option cache-size 2MB
option flush-behind on
subvolumes afr1
end-volume

volume wb2
type performance/write-behind
option cache-size 2MB
option flush-behind on
subvolumes afr2
end-volume

volume wb3
type performance/write-behind
option cache-size 2MB
option flush-behind on
subvolumes afr3
end-volume

volume unify
type cluster/distribute
subvolumes wb1 wb2 wb3
end-volume

9.3.3.    测试

测试:在两个客户端上同时复制大约2.5G容量 /usr目录至GlusterFS(大部分都是小文件)
测试结果:
192.168.1.17:glusterfs   979KB/s

192.168.1.18:glusterfs   1056KB/s


###############################

本文由笔者原创

作者:john

转载请注明出处


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值