免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2033 | 回复: 0
打印 上一主题 下一主题

[GlusterFS] GlusterFS学习手记03-cluster/Replicate 的学习 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-23 17:23 |只看该作者 |倒序浏览

今天主要把我学习的
文件复制
功能写出来
Replicate
type cluster/replicate
Replicate(前身是AFR)为
glusterfs
提供了类似RAID-1的功能。Replicate会复制文件或者文件夹到各个subvolumes里。因此,如果replicate部分设置了4个subvolume,那就会4分的文件或者文件夹的拷贝副本。replicate同样提供了高可用,比如如果其中的一个subvolume down掉了(或者说一台存储服务器坏了,网络连接出现问题)replicate依然可以使用冗余的拷贝副本来提供服务。
Replicate同样提供了自动修复功能,比如,如果一台crash掉的服务器恢复了,这台服务器上存储的过期的文件或者文件夹就会被更新成最新的版本。Replicate使用了后端文件系统的扩展功能来跟踪文件或者文件夹的版本来提供自动恢复的功能
volume replicate-example
type cluster/replicate
subvolumes brick1 brick2 brick3
end-volume
上面的例子将会把所有文件都复制到brick1 brick2 brick3中
所有读的操作都会从第一台活着的sbuvolume进行。如果三个sub-volume都是启用的状态,就从brick1读;如果brick1 down了,就从brick2读。如果读的操作刚刚完成brick1就down了,复制就会传递给brick2.
概念讲完了,下面就来说下配置吧
模拟环境:
vmware6.0 两个
linux
server:192.168.211.128 client:192.168.211.129
两个存储node,一个client
先来看看server上的配置
cat /etc/glusterfs/glusterfs-server0.vol
### Export volume "brick" with the contents of "/home/export" directory.
volume brick
type storage/posix # POSIX FS translator
option directory /home/dir1 # Export this directory
end-volume
volume locker
type features/posix-locks
subvolumes brick
end-volume
### Add network serving capability to above brick.
volume server
type protocol/server
option transport-type tcp/server
option bind-address 192.168.211.128 # Default is to listen on all interfaces
option listen-port 6996 # Default is 6996
subvolumes locker
option auth.addr.brick.allow * # Allow access to "brick" volume
option auth.addr.locker.allow *
end-volume
cat /etc/glusterfs/glusterfs-server1.vol
### Export volume "brick" with the contents of "/home/export" directory.
volume brick
type storage/posix # POSIX FS translator
option directory /home/dir2 # Export this directory
end-volume
volume locker
type features/posix-locks
subvolumes brick
end-volume
### Add network serving capability to above brick.
volume server
type protocol/server
option transport-type tcp/server
option bind-address 192.168.211.128 # Default is to listen on all interfaces
option listen-port 6997 # Default is 6996
subvolumes locker
option auth.addr.brick.allow * # Allow access to "brick" volume
option auth.addr.locker.allow *
end-volume
然后是client端的配置
cat /etc/glusterfs/replicate-client.vol
### Add client feature and attach to remote subvolume
volume client0
type protocol/client
option transport-type tcp/client
option remote-host 192.168.211.128 # IP address of the remote brick
option remote-port 6996 # default server port is 6996
option remote-subvolume locker # name of the remote volume
end-volume
volume client1
type protocol/client
option transport-type tcp/client
option remote-host 192.168.211.128
option remote-port 6997
option remote-subvolume locker
end-volume
volume bricks
type cluster/replicate
subvolumes client0 client1
end-volume
到此,配置就都完成了
接下来启动服务
server端
glusterfsd -f /etc/glusterfs/glusterfs-server0.vol
glusterfsd -f /etc/glusterfs/glusterfs-server1.vol
当然启动的时候可以加上-l /dir/glusterfs.log参数,把日志加入
然后通过ps fax查看进程如下
2206 ? Ssl 0:00 glusterfsd -f /etc/glusterfs/glusterfs-server1.vol
2396 ? Ssl 0:00 glusterfsd -f /etc/glusterfs/glusterfs-server0.vol
说明,服务正常启动起来了
client端
modprobe fuse
glusterfs -l /tmp/glustfs.log -f /etc/glusterfs/replicate-client.vol /mnt
通过df -h查看是否服务正常启动,如下
[root@contos5-1-4 mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 7.1G 2.5G 4.3G 37% /
/dev/sda1 190M 11M 170M 7% /boot
tmpfs 125M 0 125M 0% /dev/shm
glusterfs 7.1G 2.9G 3.9G 43% /mnt
如果没有如上红色标记的,请查看日志然后进行排查
接下来就是测试阶段
首先在/mnt目录下touch 1空文件
然后在server端ls /home/*查看如下
[root@contos5-1-1 home]# ls *
dir1:
1
dir2:
1
可以看到dir2中已经同步了1这个文件
然后现在我么在server上把dir1这个进程kill掉
2206 ? Ssl 0:00 glusterfsd -f /etc/glusterfs/glusterfs-server1.vol
2396 ? Ssl 0:00 glusterfsd -f /etc/glusterfs/glusterfs-server0.vol
kill -9 2396
这时client端/mnt应该只会挂载dir2了
这是/mnt中的文件是0字节的
[root@contos5-1-4 mnt]# ll
total 0
-rw-r--r-- 1 root root 0 Feb 17 12:42 1
现在我们echo "123456789" >1中
cat 1返回如下
[root@contos5-1-4 mnt]# cat 1
123456789
再来看下server上dir1中的1
[root@contos5-1-1 home]# ll /home/dir1
total 8
-rw-r--r-- 1 root root 0 Feb 17 12:42 1
可以发现是0字节
dir2中的1
[root@contos5-1-1 home]# ll /home/dir2/
total 8
-rw-r--r-- 1 root root 10 Feb 17 12:42 1
可以看到是10字节
如此看来,dir1被我们模拟down机后,修改等请求都已经传送到dir2上了,现在让我们来恢复dir1,看下效果
glusterfsd -f /etc/glusterfs/glusterfs-server0.vol
在client上cat 1的内容
[root@contos5-1-4 mnt]# cat 1
123456789
然后看下server上dir1的情况
[root@contos5-1-1 home]# ll /home/dir1/
total 8
-rw-r--r-- 1 root root 10 Feb 17 12:42 1
dir1上已经同步成10字节了
由以上测试可以证明,复制操作是正常进行的,至于性能方面还需要进一步的测试,这个放到稍后进行
开头概念解释属于自己翻译的官方文档
具体请参看
http://www.gluster.org/docs/index.php/User_Guide
中的replicate部分
原文
http://www.wenzizone.cn/?p=10


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103318/showart_2101340.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP