环境CentOS 6.3 x64

两个服务端,一个客户端

 

 

 官方安装源

  1. http://download.gluster.org/pub/gluster/glusterfs/3.3/3.3.1/CentOS/epel-6/x86_64/ 

 

 

安装glusterfs

  1. yum install glusterfs-server 

这样会安装两个服务,其中glusterd 用于服务端,glusterfsd用于客户端

 

配置服务端,/etc/glusterfs/glusterd.vol

  1. #指定一个卷,路径为/data/gluster,作为服务器文件 
  2. volume brick 
  3.   type storage/posix 
  4.   option directory  /data/gluster 
  5. end-volume 
  6.  
  7. #设置卷brick为锁中继(关于中继在附录中介绍) 
  8. volume locker 
  9.   type features/posix-locks 
  10.   subvolumes brick 
  11. end-volume 
  12.  
  13. #设置卷brick为服务器模式,并指定IP和检测端口,同时设置卷的使用权限为*(全部授权),也可以设置成部分授权,如:192.168.1.* 
  14. volume server 
  15.   type protocol/server 
  16.   option transport-type tcp/server 
  17.   option bind-address 192.168.1.101 #Server2时IP配置为: 192.168.1.102 
  18.   option listen-port 6996 
  19.   subvolumes locker 
  20.   option auth.addr.brick.allow * 
  21.   option auth.addr.locker.allow * 
  22. end-volume 

启动服务端,(服务端监听端口24007、24009、38465, 38466, and 38467)

 

  1. service glusterd start 

 

 

配置客户端,/etc/glusterfs/glusterfs.vol

  1. #指向Server1:192.168.1.101服务器的客户端访问配置 
  2. volume client1 
  3.   type    protocol/client 
  4.   option  transport-type  tcp/client 
  5.   option  remote-host  192.168.1.101 
  6.   option  transport.socket.remote-port 6996 
  7.   option  remote-subvolume locker 
  8. end-volume 
  9.  
  10. #指向Server2:192.168.1.102服务器的客户端访问配置 
  11. volume client2 
  12.   type      protocol/client 
  13.   option    transport-type  tcp/client 
  14.   option    remote-host  192.168.1.102 
  15.   option    transport.socket.remote-port 6996 
  16.   option    remote-subvolume locker 
  17. end-volume 
  18.  
  19. #将client1和client2设置成复制模式 
  20. volume bricks 
  21.   type cluster/replicate 
  22.   subvolumes client1 client2 
  23. end-volume 

启动客户端

  1. service glusterfsd start 

 

GlusterFS常用的中继介绍

  1. 1. storage/posix   #指定一个本地目录给GlusterFS内的一个卷使用; 
  2. 2. protocol/server   #服务器中继,表示此节点在GlusterFS中为服务器模式,可以说明其IP、守护端口、访问权限; 
  3. 3. protocol/client   #客户端中继,用于客户端连接服务器时使用,需要指明服务器IP和定义好的卷; 
  4. 4. cluster/replicate   #复制中继,备份文件时使用,若某子卷掉了,系统仍能正常工作,子卷起来后自动更新(通过客户端); 
  5. 5. cluster/distribute   #分布式中继,可以把两个卷或子卷组成一个大卷,实现多存储空间的聚合; 
  6. 6. features/locks    #锁中继,只能用于服务器端的posix中继之上,表示给这个卷提供加锁(fcntl locking)的功能; 
  7. 7. performance/read-ahead     #预读中继,属于性能调整中继的一种,用预读的方式提高读取的性能,有利于应用频繁持续性的访问文件,当应用完成当前数据块读取的时候,下一个数据块就已经准备好了,主要是在IB-verbs或10G的以太网上使用; 
  8. 8. performance/write-behind   #回写中继,属于性能调整中继的一种,作用是在写数据时,先写入缓存内,再写入硬盘,以提高写入的性能,适合用于服务器端; 
  9. 9. performance/io-threads   #IO线程中继,属于性能调整中继的一种,由于glusterfs 服务是单线程的,使用IO 线程转换器可以较大的提高性能,这个转换器最好是被用于服务器端; 
  10. 10. performance/io-cache   #IO缓存中继,属于性能调整中继的一种,作用是缓存住已经被读过的数据,以提高IO 性能,当IO 缓存中继检测到有写操作的时候,它就会把相应的文件从缓存中删除,需要设置文件匹配列表及其设置的优先级等内容; 
  11. 11. cluster/stripe   #条带中继,将单个大文件分成多个小文件存于各个服务器中,实现大文件的分块存储。 

 

本文严重参考了海力博客 和蚊子世界 。