您的位置:首页 > 理论基础 > 计算机网络

Glusterfs由RDMA切换到TCP

2016-01-23 17:13 417 查看
Glusterfs作为分布式文件系统,具有简单、高效的特性。同时还支持RDMA协议挂载到客户端,大大降低延迟。但Infiniband网络使用成本毕竟高,所以当集群规模大了之后,可能就会考虑到进行网络转型,考虑使用传统的TCP 25Gb或40Gb来取代。由于Glusterfs不能做到像Lustre那样同时支持两套网络,所以当网络调整时需要我们手动去修改glusterfs的网络配置。目前经过验证的可靠方案是更改所有gluster-server节点中与创建的volume相关的配置文件。比较多,下面进行详细说明。

创建Volume时,通过使用transport rdma,tcp 参数可以使该卷同时支持rdma和tcp两种协议。一个volume创建完成后,在/var/lib/glusterfs下会生成一些配置文件:

[root@hpc-242-057 volume-tcp]# gluster volume create volume-test transport rdma,tcp 11.11.11.54:/brick1/vd_test 11.11.11.57:/brick1/vd_test
volume create: volume-test: success: please start the volume to access data
[root@hpc-242-057 volume-tcp]# cd /var/lib/glusterd/vols/volume-test/
[root@hpc-242-057 volume-test]# ll
total 48
drwxr-xr-x 2 root root 4096 Jan 21 11:34 bricks
-rw------- 1 root root   16 Jan 21 11:34 cksum
-rw------- 1 root root  502 Jan 21 11:34 info
-rw------- 1 root root   93 Jan 21 11:34 node_state.info
-rw------- 1 root root   13 Jan 21 11:34 snapd.info
-rw------- 1 root root 1744 Jan 21 11:34 trusted-volume-test.rdma-fuse.vol
-rw------- 1 root root 1742 Jan 21 11:34 trusted-volume-test.tcp-fuse.vol
-rw------- 1 root root 1516 Jan 21 11:34 volume-test-rebalance.vol
-rw------- 1 root root 3315 Jan 21 11:34 volume-test.11.11.11.54.brick1-vd_test.vol
-rw------- 1 root root 3315 Jan 21 11:34 volume-test.11.11.11.57.brick1-vd_test.vol
-rw------- 1 root root 1516 Jan 21 11:34 volume-test.rdma-fuse.vol
-rw------- 1 root root 1514 Jan 21 11:34 volume-test.tcp-fuse.vol


创建volume使用的是IB网络地址,当客户端挂载时会去找11.11.11.0段的地址,如果客户端没有IB网络,只配置了tcp的网络,就会出现连接超时,无法与server创建连接,下面是客户端挂载时的日志信息:

[2016-01-21 03:21:28.779796] E [socket.c:2332:socket_connect_finish] 0-volume-tcp-client-0: connection to 11.11.11.54:24007 failed (Connection timed out)
[2016-01-21 03:21:28.787792] E [socket.c:2332:socket_connect_finish] 0-volume-tcp-client-1: connection to 11.11.11.57:24007 failed (Connection timed out)
[2016-01-21 03:21:28.795853] I [fuse-bridge.c:5053:fuse_graph_setup] 0-fuse: switched to graph 0
[2016-01-21 03:21:28.796171] I [fuse-bridge.c:3979:fuse_init] 0-glusterfs-fuse: FUSE inited with protocol versions: glusterfs 7.22 kernel 7.13
[2016-01-21 03:21:28.796680] W [fuse-bridge.c:747:fuse_attr_cbk] 0-glusterfs-fuse: 2: LOOKUP() / => -1 (Transport endpoint is not connected)
[2016-01-21 03:21:28.815824] I [fuse-bridge.c:4900:fuse_thread_proc] 0-fuse: unmounting /mnt
[2016-01-21 03:21:28.816224] W [glusterfsd.c:1219:cleanup_and_exit] (-->/lib64/libpthread.so.0() [0x30e6a079d1] -->/usr/sbin/glusterfs(glusterfs_sigwaiter+0xcd) [0x405e4d] -->/usr/sbin/glusterfs(cleanup_and_exit+0x65) [0x4059b5] ) 0-: received signum (15), shutting down
[2016-01-21 03:21:28.816282] I [fuse-bridge.c:5595:fini] 0-fuse: Unmounting '/mnt'.
[2016-01-21 03:21:28.816282] I [fuse-bridge.c:5595:fini] 0-fuse: Unmounting '/mnt'.


下面开始配置文件修改。

创建一个volume后,在/var/lib/glusterd/vols/目录下会以volume_name创建一个文件夹,也就是这里的volume-test,在volume-test目录里会生成一些和该卷相关的配置文件。

1、先将volume stop

[root@hpc-242-057 volume-test]# gluster volume stop volume-tcp
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: volume-tcp: success


2、停止所有Glusterfs Server节点服务

[root@hpc-242-057 volume-test]# /etc/init.d/glusterd stop
[root@hpc-242-057 volume-test]#                            [  OK  ]


3、开始修改配置文件

首先修改bricks这个文件夹中文件

[root@hpc-242-057 bricks]# ls
11.11.11.54:-brick1-vd_test  11.11.11.57:-brick1-vd_test
[root@hpc-242-057 bricks]# sed -i 's/11.11.11/192.168.242/g' 11.11.11.54:-brick1-vd_test
[root@hpc-242-057 bricks]# sed -i 's/11.11.11/192.168.242/g' 11.11.11.57:-brick1-vd_test


再修改info这个文件

[root@hpc-242-057 volume-test]# cat info
type=0
count=2
status=0
sub_count=0
stripe_count=1
replica_count=1
disperse_count=0
redundancy_count=0
version=1
transport-type=2
volume-id=316c4455-d571-4590-bd86-ccc0f40b5d40
username=ea0faa9a-833e-4848-867f-398ae96cb32f
password=34da1a52-4cef-418c-82c3-11c24a0709b1
op-version=3
client-op-version=3
parent_volname=N/A
restored_from_snap=00000000-0000-0000-0000-000000000000
snap-max-hard-limit=256
performance.readdir-ahead=on
brick-0=11.11.11.54:-brick1-vd_test
brick-1=11.11.11.57:-brick1-vd_test
[root@hpc-242-057 volume-test]# sed -i 's/11.11.11/192.168.242/g' info


trusted-volume-test.rdma-fuse.vol

[root@hpc-242-057 volume-test]# sed -i 's/11.11.11/192.168.242/g' trusted-volume-test.rdma-fuse.vol


trusted-volume-test.tcp-fuse.vol

[root@hpc-242-057 volume-test]# sed -i 's/11.11.11/192.168.242/g' trusted-volume-test.tcp-fuse.vol


volume-test-rebalance.vol

sed -i 's/11.11.11/192.168.242/g' volume-test-rebalance.vol


volume-test.11.11.11.54.brick1-vd_test.vol

sed -i 's/11.11.11/192.168.242/g' volume-test.11.11.11.54.brick1-vd_test.vol


volume-test.11.11.11.57.brick1-vd_test.vol

sed -i 's/11.11.11/192.168.242/g' volume-test.11.11.11.57.brick1-vd_test.vol


volume-test.rdma-fuse.vol

sed -i 's/11.11.11/192.168.242/g' volume-test.rdma-fuse.vol


volume-test.tcp-fuse.vol

sed -i 's/11.11.11/192.168.242/g' volume-test.tcp-fuse.vol


到此,volume-test目录下的配置文件修改改成,其实这里主要就是修改配置文件中的IP地址,另外还有几个配置文件的名称需要修改:

[root@hpc-242-054 volume-test]# mv volume-test.11.11.11.54.brick1-vd_test.vol volume-test.192.168.242.54.brick1-vd_test.vol
[root@hpc-242-054 volume-test]# mv volume-test.11.11.11.57.brick1-vd_test.vol volume-test.192.168.242.57.brick1-vd_test.vol
[root@hpc-242-054 volume-test]# cd bricks/
[root@hpc-242-054 bricks]# ls
11.11.11.54:-brick1-vd_test  11.11.11.57:-brick1-vd_test
[root@hpc-242-054 bricks]# mv 11.11.11.54:-brick1-vd_test 192.168.242.54:-brick1-vd_test
[root@hpc-242-054 bricks]# mv 11.11.11.57:-brick1-vd_test 192.168.242.57:-brick1-vd_test
[root@hpc-242-054 bricks]# ll
total 8
-rw------- 1 root root 163 Jan 23 16:30 192.168.242.54:-brick1-vd_test
-rw------- 1 root root 155 Jan 23 16:30 192.168.242.57:-brick1-vd_test


完成上面操作后,再切换到/var/lib/glusterd/peers/目录下查看server节点配置信息

[root@hpc-242-057 peers]# ll
total 44
-rw------- 1 root root  94 Jan 21 11:09 1bc35ed5-d4ef-41b5-863a-a3abc5e9cfdc
-rw------- 1 root root  94 Jan 21 11:09 1db89bbd-ac68-4ed1-bffb-f95cdaa17299

[root@hpc-242-057 peers]# cat 1bc35ed5-d4ef-41b5-863a-a3abc5e9cfdc
uuid=1bc35ed5-d4ef-41b5-863a-a3abc5e9cfdc
state=3
hostname1=hpc-242-054
hostname2=11.11.11.54


注意最下面两行hostname值,如果已经有了tcp网段对应ip解析的主机名或tcp段的ip地址,则不需再修改,如果只有一个11段的ip地址或主机名,这里还需修改成192段的地址。实际上,这里从IB网络切换到TCP后,hostname2就可以删除了。

确认peers下配置文件没问题后,将修改过的配置文件同步到其他Server节点上,直接scp过去即可。然后重新启动glusterd服务后再将volume启动。

4、 客户端挂载测试

找一台没有IB网络的节点进行测试:

[root@cobbler ~]#mount -t glusterfs 192.168.242.54:volume-test /mnt
[root@cobbler ~]#df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             772G  377G  357G  52% /
tmpfs                 7.8G   80K  7.8G   1% /dev/shm
/dev/sda1             194M   32M  152M  18% /boot
/dev/sdb1             862G  736G   83G  90% /disk1
192.168.242.54:volume-test
73T   61T   13T  84% /mnt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: