转自:http://blog.csdn.net/zzulp/article/details/39527441
0 术语简介
GlusterFS是一个开源的分布式文件系统。更多特性介绍附录的参考文档。
Brick:GFS中的存储单元,通过是一个受信存储池中的服务器的一个导出目录。可以通过主机名和目录名来标识,如'SERVER:EXPORT'
Client: 挂载了GFS卷的设备
Extended Attributes:xattr是一个文件系统的特性,其支持用户或程序关联文件/目录和元数据。
FUSE:Filesystem Userspace是一个可加载的内核模块,其支持非特权用户创建自己的文件系统而不需要修改内核代码。通过在用户空间运行文件系统的代码通过FUSE代码与内核进行桥接。
Geo-Replication
GFID:GFS卷中的每个文件或目录都有一个唯一的128位的数据相关联,其用于模拟inode
Namespace:每个Gluster卷都导出单个ns作为POSIX的挂载点
Node:一个拥有若干brick的设备
RDMA:远程直接内存访问,支持不通过双方的OS进行直接内存访问。
RRDNS:round robin DNS是一种通过DNS轮转返回不同的设备以进行负载均衡的方法
Self-heal:用于后台运行检测复本卷中文件和目录的不一致性并解决这些不一致。
Split-brain:脑裂
Translator:
Volfile:glusterfs进程的配置文件,通常位于/var/lib/glusterd/vols/volname
Volume:一组bricks的逻辑集合
1 Gluster安装
2 cluster管理
在创建volume之前需要先将一组存储设备组成一个存储池,通过存储设备提供的bricks来组成卷。
在设备上启动glusterd之后,可通过设备的主机名或IP地址,将设备加到存储池中。
gluster对于每个节点都会生成一个UUID来标识,因此如果节点的IP或主机名发生了变化,只需要重新执行peer probe即可。不过如果一个主机名曾经用过,想再改回去,则gluster会提示已经保存过。此时只能把节点detach掉,然后重新probe。
3 Volume管理
数据的传输协议支持tcp和infiniband rdma协议。
3.1 卷的类型
3.1.1 distributed volume
分布卷可以将某个文件随机的存储在卷内的一个brick内,通常用于扩展存储能力,不支持数据的冗余。除非底层的brick使用RAID等外部的冗余措施。
3.1.2 replicated volume
复本卷在创建时可指定复本的数量,复本在存储时会在卷的不同brick上,因此有几个复本就必须提供至少多个brick。
注意:在创建复本卷时,brick数量与复本个数必须相等;否则将会报错。
另外如果同一个节点提供了多个brick,也可以在同一个结点上创建复本卷,但这并不安全,因为一台设备挂掉,其上面的所有brick就无法访问了。
3.1.3 striped volume
分片卷将单个文件分成小块(块大小支持配置,默认为128K),然后将小块存储在不同的brick上,以提升文件的访问性能。
stripe后的参数指明切片的分布位置个数
注意:brick的个数必须等于分布位置的个数
3.1.4 distribute replication volume
此类型卷是基本复本卷的扩展,可以指定若干brick组成一个复本卷,另外若干brick组成另个复本卷。单个文件在复本卷内数据保持复制,不同文件在不同复本卷之间进行分布。
注意:
复本卷的组成依赖于指定brick的顺序
brick必须为复本数K的N倍,brick列表将以K个为一组,形成N个复本卷
3.1.5 distribute striped volume
类似于分布式复本卷,
若创建的卷的节点提供的bricks个数为stripe个数N倍时,将创建此类型的卷。
注意:
切片卷的组成依赖于指定brick的顺序
brick必须为复本数K的N倍,brick列表将以K个为一组,形成N个切片卷
3.1.6 striped replicated volume
数据将进行切片,切片在复本卷内进行复制,在不同卷间进行分布。
exp1和exp2组成复本卷,exp3和exp4组成复本卷,两个复本卷组成分片卷。
注意:brick数量必须和stripe个数N和repl参数M的积N*M相等。即对于brick列表,将以M为一组,形成N个切片卷。数据切片分布在N个切片卷上,在每个切片卷内部,切片数据复本M份。
3.1.7 distributed striped replicated vlume
注意:bricks数量为stripe个数N,和repl个数M的积N*M的整数倍
exp1 exp2 exp3 exp4组成一个分布卷,exp1和exp2组成一个stripe卷,exp3和exp4组成另一个stripe卷,1和2,3和4互为复本卷
exp4-exp8组成另一个分布卷,略。
3.2 启/停/删除卷
3.3 扩展收缩卷
扩展或收缩卷时,也要按照卷的类型,加入或减少的brick个数必须满足相应的要求。
3.4 迁移卷
主要完成数据在卷之间的在线迁移
3.5 均衡卷
当对卷进行了扩展或收缩后,需要对卷的数据进行重新均衡。
3.6 触发副本自愈
3.7 选项配置
详细的可设置选项:
4 排错
4.1 错误
gluster使用了若干端口,如果出现probe peer或数据无法同步,考虑iptables对应用的影响。
4.2 日志
$gluster volume log rotate mamm-vol #实现日志rotate
4.3 添加卷提示已经路径已在卷中的错误
执行下面的脚本,清除历史数据及属性信息
4.4 添加卷连接失败
每次向卷中添加brick后,远端的glusterd进程可能会连接关闭一段时间。此时现次执行操作会提示连接失败。等一会再执行即可。
5 客户端设置
客户端使用GFS有多种方式,性能最高的方式是使用gluster的native接口,此外还有NFS和CIFS方式。
5.1 native方式
1 安装gluserfs-fuse安装包,
2 挂载卷:mount -t glusterfs host/ip:path mnt-point
注意,这里提供的IP和主机只用来为客户提供volfile信息,后续客户便直接和需要的服务器通信了。
3 设置自动挂载
echo "localhost:/mamm-vol /mnt/glusterfs glusterfs defaults,_netdev 0 0" >>/etc/fstab
5.2 NFS方式
Gluster提供了内置的NFS服务,支持其他实现了NFSv3的客户端直接访问。
然后客户端挂载
window7客户端
程序和功能->打开或关闭windows功能,安装NFS客户端功能,即可使用mount/showmount功能。
5.3 CIFS方式
cifs可以提供给WIN及samba客户端访问,对于windows程序,可以使用//ip/path通过SMB协议来方便的使用远程资源
1 在服务器将glusterfs挂载到/mnt/gfs
2 服务器通过samba配置将/mnt/gfs导出服务,启动smb服务
3 在win客户端上挂载samber服务器导出共享mount -t cifs //ip/path /mnt-point
6 性能监控
6.1 性能profile
6.2 实时top
显示当前某个brick或NFS文件打开/读/写/打开目录/读目录的计数
显示当前某个brick或NFS路径读文件或写文件数据的性能
6.3 内部计数导出
设置导出路径
查看导出数据
6.4 卷状态查看
7 参考资料
Gluster集群文件系统研究:
http://blog.csdn.net/liuaigui/article/details/6284551
Gluster管理入门:
http://www.slashroot.in/gfs-gluster-file-system-complete-tutorial-guide-for-an-administrator
Gluster原理视频介绍:
http://edu.51cto.com/lesson/id-35359.html
Gluster运维视频介绍:
http://edu.51cto.com/course/course_id-1930-page-2.html
Infiniband介绍与配置:
http://www.ibm.com/developerworks/cn/linux/l-cn-infiniband/