一、集群环境
- 集群中存储服务器是一些局域网内性能一般的Server,系统Linux RedHat
- IP范围:192.168.0.54~192.168.0.59,共六台服务器
- 局域网:千兆以太网
- FUSE版本:2.8.5
- GlusterFS版本:3.1.5
二、安装
1. 确认系统内核版本,因FUSE支持kernel2.4.X和2.6.X。FUSE虽说是支持2.4.X,不过该版本kernel里面没有fuse内核模块。kernel 2.6.14之后才开始有自带fuse。测试系统中已经自带fuse,否则,参见http://zhoubo.sinaapp.com/?p=140
2.安装Fuse,下载源码,执行如下命令安装(root权限):
$./configure --enable-dependency-tracking --enable-lib --enable-util $make $make install
3.安装bison(GlusterFS依赖包),下载源码,执行如下命令(root权限):
$./configure $make $make install
4.安装flex(GlusterFS依赖包),下载源码,执行如下命令(root权限):
$./configure $make $make install
5.安装Glusterfs,执行如下命令:
$./configure --enable-FEATURE=yes --enable-dependency-tracking --enable-fusermount --prefix=/usr/local $make $make install
6.验证安装
sudo ldconfig fuse测试并检查:lsmod | grep fuse 假如没有, 使用命令:modprobe fuse lsmod | grep fuse 使用 ls /dev/fuse,应该有 /dev/fuse 这个目录 glusterfs -V
在集群的每台服务器上安装上述软件。
三、Server端配置
server.vol文件内容:
volume posix type storage/posix # POSIX FS translator option directory /data/pkgs # Export this directory 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 option transport.socket.listen-port 24016 subvolumes brick option auth.addr.brick.allow * # Allow access to "brick" volume option auth.addr.locks.allow * # Allow access to "brick" volume end-volume
将上述server.vol文件拷贝到充当存储的各服务器上/usr/local/etc/glusterfs/。
四、Client配置
### Add client feature and attach to remote subvolume volume client1 type protocol/client option transport-type tcp option remote-host 192.168.0.54 # IP address of the remote brick option remote-port 24016 option remote-subvolume locks # name of the remote volume end-volume volume client2 type protocol/client option transport-type tcp option remote-host 192.168.0.55 # IP address of the remote brick option remote-port 24016 option remote-subvolume locks # name of the remote volume end-volume volume client3 type protocol/client option transport-type tcp option remote-host 192.168.0.56 # IP address of the remote brick option remote-port 24016 option remote-subvolume locks # name of the remote volume end-volume volume client4 type protocol/client option transport-type tcp option remote-host 192.168.0.57 # IP address of the remote brick option remote-port 24016 option remote-subvolume locks # name of the remote volume end-volume volume client5 type protocol/client option transport-type tcp option remote-host 192.168.0.58 option remote-port 24016 option remote-subvolume locks end-volume volume client6 type protocol/client option transport-type tcp option remote-host 192.168.0.59 option remote-port 24016 option remote-subvolume locks end-volume volume brick1 type cluster/replicate subvolumes client1 client2 end-volume volume brick2 type cluster/replicate subvolumes client3 client4 end-volume volume brick3 type cluster/replicate subvolumes client5 client6 end-volume volume bricks type cluster/distribute subvolumes brick1 brick2 brick3 end-volume
五、启动服务
1、启动Server端服务 在每台Server存储服务器上执行如下命令:
$glusterfsd -f /usr/local/etc/glusterfs/server.vol -l /tmp/glusterfsd.log
2、启动Client
$glusterfs -f /usr/local/etc/glusterfs/client.vol -l /tmp/glusterfs.log /mnt
3、验证服务是否已经启动
$ps -ef|grep glusterfs $netstat -nl|grep 24016 $df -h
六、小结:
- 如果打算做cluster/replicate的备份,server端必须支持features/posix-locks.否则会系统会报错.
- Cluster/distribute的结构支持动态添加nodes.添加以后,修改client.vol,然后umount/mount重新挂载一下就可以了.只要不改变namespace的设置,是不会影响以前存储的文件的.
- 在这个配置中namespace做了cluster/replicate的HA,单个namespace节点崩溃不会影响系统运行.
- 如果动态添加namespace节点个数,对系统没有影响.不过,新添加的namespace节点不会主动同步数据,要等有用户访问文件系统中的文件的时候,新的ns node才会更新.也就是说,如果某个文件根本没人访问,新添加的ns node就不会被更新这个文件.
- Replicate会复制文件或者文件夹到各个subvolumes里
- replicate同样提供了高可用,比如如果其中的一个subvolume down掉了(或者说一台存储服务器坏了,网络连接出现问题)replicate依然可以使用冗余的拷贝副本来提供服务。
- Replicate同样提供了自动修复功能,比如,如果一台crash掉的服务器恢复了,这台服务器上存储的过期的文件或者文件夹就会被更新成最新的版本。
- Replicate使用了后端文件系统的扩展功能来跟踪文件或者文件夹的版本来提供自动恢复的功能
- 性能测试见下期。