免费注册 查看新帖 |

Chinaunix

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

[GlusterFS] GlusterFS学习手机06-基于glusterfs的web应用 [复制链接]

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


glusterfs
的东西也有段时间了,不过一直一来也是停留在对这个分布式系统的学习,当然对于一个软件的学习不能仅仅停留在对这个软件的熟悉,还要考虑它所适用的范围。最近就在思考,到底对于我们的什么应用合适,我这边接触的比较多的结构就是N台Web+单个NFS。我就再想,既然glusterfs是个聚合分布式文件系统,而且支持HA的功能,是不是可以使用glusterfs来替换NFS,既可以达到共享文件的用途,有可以解决了单点的问题。
先来看下我预计的拓扑结构

下面来解释一下这个拓扑,前端的web应用,每台web上的应用都放置在glusterfs共享出来的硬盘上,尽管我图上画的是一个diskpool,但实际的容量大小是几台web中glusterfs共享空间最小的那个大小。而且对于上面这个拓扑的应用,我并不需要独立的NAS来做共享,完全可以使用每台web服务器上未用的硬盘空间(注:当然你可以选择使用NAS来进行存储,在存储量很大的情况下)。
接下来就来看下实现的方式:
web01:192.168.220.128 共享出来的地址:/var/app
web02:192.168.220.129 共享出来的地址:/var/app
两台机器都事先安装好glusterfs和fuse(安装方法可以参考我前几篇文章)
首先来配置web01的server端
cat /etc/glusterfs/server.vol
volume brick
type storage/posix # POSIX FS translator
option directory /var/app # 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 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
web02上的server端配置相同
cat /etc/glusterfs/server.vol
volume brick
type storage/posix # POSIX FS translator
option directory /var/app # 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 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
服务器端配置完毕,接下来就是client端的配置,因为两台机器互为对方的sever又同时是自己的server所以两台上都需要配置client端。
首先看下web01上的配置
cat /etc/glusterfs/replicate.vol
volume client0
type protocol/client
option transport-type tcp/client
option remote-host 127.0.0.1 # 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.129
option remote-port 6996
option remote-subvolume locker
end-volume
volume bricks
type cluster/replicate
subvolumes client0 client1
option read-subvolume client0
end-volume
再来看下web02上的配置
cat /etc/glusterfs/replicate.vol
volume client0
type protocol/client
option transport-type tcp/client
option remote-host 127.0.0.1 # 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 6996
option remote-subvolume locker
end-volume
volume bricks
type cluster/replicate
subvolumes client0 client1
option read-subvolume client0
end-volume
到此,配置就已经完成了,接下来就可以测试咯,首先两台机器上需要加载fuse
modprobe fuse
如果没有报错,说明fuse模块加载完毕,然后在两台机器上启动server端和client端
web01上执行
启动服务端
glusterfsd -f /etc/glusterfs/server.vol
启动client端
glusterfs -f /etc/glusterfs/replicate.vol /usr/local/nginx/html/blog
web02上如法炮制
然后就可以在web01上的/mnt上放置web的内容了,web02上可以自动的看到相应的内容,并不需要人为的干预,没台机器上都会有一份web应用的拷贝,这样无论那台web宕机,web的提供的服务是不会中断,也不会受到影响的,从而避免了,单点NFS故障导致服务中断,同时避免了,双NFS数据同步的问题。同时每台web优先读取自己硬盘上的copy,所以可以减少网络负载。
但这个方案还不是最完美的,因为这种方案对于写频繁的应用来说是存在问题的,如果出现同时写一个文件的情况,就会造成数据的不一致,所以如果web应用是读频繁的话,还是很有优势的,而且如果后台人员需要对应用进行更新,只需要更新第一台server的就行,默认情况下replicate的应用,subvolumes client0 client1 中的一个就是主server,这里只要对于client0上的数据进行更新就可以做到同步了。
原文
http://www.wenzizone.cn/?p=37


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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP