uyfrjk 发表于 2019-2-1 09:44:42

glusterfs实践(二)cluster/unify的学习

个人感觉:
glusterfs感觉和moosefs有点类似,就是在备份的方面moosefs用的是创建副本的形式,而glusterfs用的是单独的一个空间来做交换,在下面的实验中就会得到体验

一.实验环境
目的:将两台server的剩余空间合并,让client挂载,所需3台服务器,两台server,一台client,IP分别为:
192.168.4.189----------------glusterfs_server01
192.168.4.190----------------glusterfs_server02
192.168.4.188----------------glusterfs_client
系统使用centos5.1,有个奇怪的问题是系统使用centos4.4的时候编译glusterfs的时候总报错,用centos5.1就没事,这问题还以待研究

二.安装
1.首先安装fuse
tar -zxvf fuse-2.7.4.tar.gz
cd fuse-2.7.4
./configure -enable-dependency-tracking -enable-kernel-module -enable-lib -enable-util
make && make isntall
2.安装glusterfs
tar -zxvf glusterfs-2.0.0rc1.tar.gz
cd glusterfs-2.0.0rc1
./configure
make && make install
两台glusterfs_server和glusterfs_client端操作一样

三. 配置
gluster_server端的操作
1.gluster_server端服务器有一个单独的硬盘/dev/hdb,对/dev/hdb分区并mount到/disk上,执行chmod 777 /disk
两台server一样的操作
2.配置文件的修改
glusterfs_server01上:
mv glusterfs-server.vol.sample glusterfs-server.vol
vi /usr/local/etc/glusterfs/glusterfs-server.vol
修改后内容如下:
volume brick
type storage/posix
option directory /disk/export # Note: Once exported, DO NOT WRITE DIRECTLY TO THIS DIRECTORY
end-volume
volume brick-ns
type storage/posix
option directory /disk/export_ns
end-volume
volume server
type protocol/server
subvolumes brick brick-ns
option transport-type tcp/server   # For TCP/IP transport
option auth.ip.brick.allow *
option auth.ip.brick-ns.allow *
end-volume
glusterfs_server02上:
mv glusterfs-server.vol.sample glusterfs-server.vol
vi /usr/local/etc/glusterfs/glusterfs-server.vol
修改后内容如下:
volume brick
type storage/posix
option directory /disk/export # Note: Once exported, DO NOT WRITE DIRECTLY TO THIS DIRECTORY
end-volume
volume brick-ns
type storage/posix
option directory /disk/export_ns
end-volume
volume server
type protocol/server
subvolumes brick brick-ns
option transport-type tcp/server   # For TCP/IP transport
option auth.ip.brick.allow *
option auth.ip.brick-ns.allow *
end-volume
3.mkdir -p /disk/export
mkdir -p /disk/export_ns
两台server操作一样

gluster_cliengt端的操作:
cd /usr/local/etc/glusterfs/
mv glusterfs-client.vol.sampleglusterfs-client.vol
修改后的内容如下:
volume client1-ns
type protocol/client
option transport-type tcp/client
option remote-host 192.168.4.189
option remote-subvolume brick-ns
end-volume
volume client1
type protocol/client
option transport-type tcp/client
option remote-host 192.168.4.189
option remote-subvolume brick
end-volume
volume client2
type protocol/client
option transport-type tcp/client
option remote-host 192.168.4.190
option remote-subvolume brick
end-volume
volume unify
type cluster/unify
subvolumes client1 client2
option namespace client1-ns
option scheduler rr
end-volume

四. 操作
glusterfs_server端的操作
1.glusterfsd -f /usr/local/etc/glusterfs/glusterfs-server.vol启动server端
2.ps -ef | grep glusterfs                                    查看进程存在不存在
3.netstat -ln | grep 6996                                    查看端口是否监听
两台server一样
glusterfs_client端的操作
1.modprobe -i fuse                加载fuse模块
2.glusterfs -l /tmp/glusterfs.log -f /usr/local/etc/glusterfs/glusterfs-client.vol /mnt      挂载到/mnt上,同时可以查看 /tmp下的glusterfs.log日志
3.# df -h
文件系统            容量已用 可用 已用% 挂载点
/dev/hda1             8.5G5.0G3.2G62% /
tmpfs               125M   0125M   0% /dev/shm
glusterfs             6.0G147M5.5G   3% /mnt
看看/mnt的容量是不是两个server磁盘的总和,是的话就证明OK!!!

五. 测试
1.glusterfs_client端的/mnt目录下:
touch {1,2,3,4,5,6,7,8,9,10}
2.到glusterfs_server的/disk/export目录下ls
server01:
   # ls
    13579
server02:
# ls
    246810
3.再到server01上的/disk/export_ns目录下ls
# ls
11023456789
由上面看到,10个新的文件是依次创建到了两个server的/disk/export中,server01中的/disk/export_ns就是我们配置的namespace,用于交换空间
到此,我的试验就算完成了,而且试验目的也达成了
4.在server端进行一个破坏性的实验,把server02的gluster进程杀掉,到client端看,发现/mnt的空间把server02的去掉了变成了3G,但是到/mnt里touch文件是没问题
但是把server01端的gluster进程杀掉后:
# ls
ls: .: 没有那个文件或目录
当把server01端的glusterfs进程启动后恢复正常
5.到此有几个问题比较疑惑
(1).交换空间也就是namespace需要设置多大,是应该每个存储空间之和还是和一个空间大小一样就行,个人感觉应该是每个存储空间之和
(2).感觉只要namespace的服务器的进程不down,client就可以正常访问,namespace可以和其他的server在一台服务器上也可以单独一台服务器,单独出来出问题的危险小点
    还可以把namespace的服务器做成HA为了更保险的话,这样就感觉namespace太浪费磁盘了
对于以上2个问题,我会再之后的学习中进行研究,并实现glusterfs的其他功能,对于其中的参数下次一并讨论吧

                                 
                                                   







页: [1]
查看完整版本: glusterfs实践(二)cluster/unify的学习