---
title: "GlusterFS分布式文件部署"
author: "bwhzhl"
date: "2012-11-26T19:13:11Z"
tags: []
categories: ["企业架构"]
slug: "glusterfs"
draft: false
lastmod: "2012-11-26T19:15:58Z"
id: 1735553
url: "https://permiss.iteye.com/blog/1735553"
---

```
【FUSE安装】
yum install zlib-devel util-linux
 tar zxvf fuse-2.9.2.tar.gz 
 cd  fuse*
 ./configure
 make && make install  
export PKG_CONFIG_PATH=/usr/local/fuse/lib/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile
modprobe fuse 
lsmod | grep fuse

【GlusterFS安装】
yum install flex byacc bison openssl-devel  python-ctypes
tar zvxf glusterfs-3.3.1.tar.gz
cd glusterfs-3.3.1
./configure --enable-fusermount
make && make install

############服务端配置#######################
vim /usr/local/etc/glusterfs/glusterd.vol

volume brick
  type storage/posix
  option directory  /data/gluster
end-volume

volume locker
  type features/posix-locks
  subvolumes brick
end-volume

volume server
  type protocol/server
  option transport-type tcp/server
  option bind-address 192.168.1.202  # server1 201
  option listen-port 6997   #server1 6996
  subvolumes locker
  option auth.addr.brick.allow *
  option auth.addr.locker.allow *
end-volume
###################################
启动Server1和Server2，
glusterfsd -f /usr/local/etc/glusterfs/glusterd.vol  -l /tmp/glusterfsd-server.log
/etc/init.d/glusterd start




##############客户端配置#####################
vim /usr/local/etc/glusterfs/glusterd.vol

volume client1
  type    protocol/client
  option  transport-type  tcp/client
  option  remote-host  192.168.1.201
  option  transport.socket.remote-port 6996
  option  remote-subvolume locker
end-volume

volume client2
  type      protocol/client
  option    transport-type  tcp/client
  option    remote-host  192.168.1.202
  option    transport.socket.remote-port 6997
  option    remote-subvolume locker
end-volume

volume bricks
  type cluster/replicate
  subvolumes client1 client2
end-volume
###################################
mkdir -p  /data/gluster
glusterfs -f  /usr/local/etc/glusterfs/glusterd.vol  -l /tmp/glusterfs-client.log   /data/gluster    #debug



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