分布式存储GlusterFS介绍与部

咋样治白癜风 http://pf.39.net/bdfyy/

点击上方“民工哥技术之路”,选择“设为星标”

回复“”获取独家整理的学习资料!

1.glusterfs概述

GlusterFS系统是一个可扩展的网络文件系统,相比其他分布式文件系统,GlusterFS具有高扩展性、高可用性、高性能、可横向扩展等特点,并且其没有元数据服务器的设计,让整个服务没有单点故障的隐患。当客户端访问GlusterFS存储时,首先程序通过访问挂载点的形式读写数据,对于用户和程序而言,集群文件系统是透明的,用户和程序根本感觉不到文件系统是本地还是在远程服务器上。读写操作将会被交给VFS(VirtualFileSystem)来处理,VFS会将请求交给FUSE内核模块,而FUSE又会通过设备/dev/fuse将数据交给GlusterFSClient。最后经过GlusterFSClient的计算,并最终经过网络将请求或数据发送到GlusterFSServer上。

2.glusterfs常用分布式简介

分布式卷也看成为哈希卷,多个文件以文件为单位在多个brick上,使用哈希算法随机存储。

应用场景:大量小文件优点:读/写性能好缺点:如果存储或服务器故障,该brick上的数据将丢失不指定卷类型,默认是分布式卷brick数量没有限制

创建分布式卷命令:

glustervolumecreatevolume_namenode1:/data/br1node2:/data/br1

复制卷是将多个文件在多个brick上复制多份,brick的数目要与需要复制的份数相等,建议brick分布在不同的服务器上。

应用场景:对可靠性高和读写性能要求高的场景优点:读写性能好缺点:写性能差replica=brick

创建复制卷:

glustervolumecreatevolume_namereplica2node1:/data/br1node2:/data/br1

replica:文件保存的份数

条带卷是将文件分成条带,存放在多个brick上,默认条带大小k

应用场景:大文件优点:适用于大文件存储缺点:可靠性低,brick故障会导致数据全部丢失stripe=birckstripe:条带个数创建条带卷:

glustervolumecreatevolume_namestripe2node1:/data/br1node2:/data/br1

分布式条带卷是将多个文件在多个节点哈希存储,每个文件再多分条带在多个brick上存储

应用场景:读/写性能高的大量大文件场景优点:高并发支持缺点:没有冗余,可靠性差brick数是stripe的倍数

创建分布式条带卷:

glustervolumecreatevolume_namestripe2node1:/data/br1node2:/data/br1node3:/data/br1node4:/data/br1

分布式复制卷是将多个文件在多个节点上哈希存储,在多个brick复制多份存储。

应用场景:大量文件读和可靠性要求高的场景优点:高可靠,读性能高缺点:牺牲存储空间,写性能差brick数量是replica的倍数

glustervolumecreatevolume_namereplica2node1:/data/br1node2:/data/br1node3:/data/br1node4:/data/br1

条带式复制卷是将一个大文件存储的时候划分条带,并且保存多份

应用场景:超大文件,并且对可靠性要求高优点:大文件存储,可靠性高缺点:牺牲空间写性能差brick数量是stripe、replica的乘积

glustervolumecreatevolume_namestripe2replica2node1:/data/br1node2:/data/br1node3:/data/br1node4:/data/br13.glusterfs环境日志存储集群采用的是分布式复制卷,将多个文件在多个节点上哈希存储,在多个brick复制多份存储。共有五台服务器,磁盘空间共有90T,那么采用这种分布式复制卷的方式,只有45T磁盘空间可用。并且需要采用分布式复制卷方式需要要有双数的brick,所以现采用一台服务器上创建两个brick,如上图所示,10..23.4:/data_01/node和10..23.44:/data_01/node是备份关系,其他节点均是如此,10..23.44作为日志存储集群的管理节点,nfs-ganesha服务只需要安装在控制节点,客户端则可以通过nfs方式挂载。

#sed-is#SELINUX=enforcing#SELINUX=disabled#/etc/sysconfig/selinux#关闭selinux#iptables-F#清除防火墙规则

安装glusterfs(01-05)

#yuminstalluserspace-rcu-*#yuminstallpython2-gluster-3.13.2-2.el7.x86_64.rpm#yuminstalltcmu-runner-*libtcmu-*#yuminstallgluster*#yuminstallnfs-ganesha-*#这个nfs只要需要对外挂载的哪台服务器需要安装(10..23.44)#systemctlstartglusterd.service#所有服务器启动glusterd#systemctlstartrpcbind#systemctlenableglusterd.service#systemctlenablerpcbind#ss-lnt#查询端口是否有为,如果有则服务正常运行

创建集群(在10..23.44节点上执行一下操作,向集群中添加节点):

[root

admin-node~]#glusterpeerprobe10..23.44peerprobe:success.[root

admin-node~]#glusterpeerprobe10..23.45peerprobe:success.[root

admin-node~]#glusterpeerprobe10..23.46peerprobe:success.[root

admin-node~]#glusterpeerprobe10..23.47peerprobe:success.[root

admin-node~]#glusterpeerprobe10..23.4peerprobe:success.

查看虚拟机信任状态添加结果

[root

admin-node~]#glusterpeerstatusNumberofPeers:4Hostname:10..23.46Uuid:31b5ecd4-c49c-4fa7--cffcc7eState:PeerinCluster(Connected)Hostname:10..23.47Uuid:38a7fda9-ad4a-a-b28f-abafState:PeerinCluster(Connected)Hostname:10..23.45Uuid:9e3cfb56-1ed4-4daf-9d20-ad4bf2cefb37State:PeerinCluster(Connected)Hostname:10..23.4Uuid:ae9a-eca5-f-bb9c-20fbcbState:PeerinCluster(Connected)

在所有节点进行以下磁盘操作:

[root

admin-node~]#fdisk/dev/sdb

创建卷组:

[root

admin-node~]#vgcreatevg_data01/dev/sdb1/dev/sdc1/dev/sdd1/dev/sde1/dev/sdf1[root

admin-node~]#vgcreatevg_data02/dev/sdg1/dev/sdh1/dev/sdi1/dev/sdj1/dev/sdk1

查看卷组:

[root

admin-node~]#vgdisplay

创建逻辑卷:

[root

admin-node~]#lvcreate-nlv_data01-L9TBvg_data01[root

admin-node~]#lvcreate-nlv_data02-L9TBvg_data02

查看逻辑卷:

[root

admin-node~]#lvdisplay

格式化逻辑卷:

[root

admin-node~]#mkfs.xfs/dev/vg_data01/lv_data01[root

admin-node~]#mkfs.xfs/dev/vg_data02/lv_data02

挂载逻辑卷:

[root

admin-node~]#mkdir-p/data_01/node/data_02/node[root

admin-node~]#vim/etc/fstab/dev/vg_data01/lv_data01/data_01xfsdefaults00/dev/vg_data02/lv_data02/data_02xfsdefaults00[root

admin-node~]#mount/data_01[root

admin-node~]#mount/data_02

分布式复制模式(组合型),最少需要4台服务器才能创建。

创建卷:

[root

admin-node~]#glustervolumecreatedata-volumereplica..23.4:/data_01/node10..23.44:/data_01/node10..23.44:/data_02/node10..23.45:/data_02/node10..23.45:/data_01/node10..23.4:/data_02/node10..23.46:/data_01/node10..23.47:/data_01/node10..23.46:/data_02/node10..23.47:/data_02/nodeforce

启动创建的卷:

[root

admin-node~]#glustervolumestartdata-volumevolumestart:data-volume:success所有机器都可以查看:[root

admin-node~]#glustervolumeinfo

查看分布式卷的状态:

[root

admin-node~]#glustervolumestatus

基于以上glusterfs部署,glusterfs分布式复制卷已经完成

4.nfs-ganesha环境搭建

glusterfs服务本身也是支持nfs挂载,由于现有生产环境存在多个网段,并且有些网段与glusterfs存储服务器网段是不通,所以需要通过nginx代理nfs来实现nfs挂载。Glusterfs服务只是支持nfs3版本的挂载,在通过nginx代理方面也不是那么方便,端口繁多,所以glusterfs与NFSs-Ganesha是完美组合。NFSs-Ganesha通过FSAL(文件系统抽象层)将一个后端存储抽象成一个统一的API,提供给Ganesha服务端,然后通过NFS协议将其挂载到客户端。在客户端上对挂出来的空间进行操作。并且NFSs-Ganesha可以指定nfs的版本。

在管理节点10..23.44上安装nfs-ganesha,在一开始部署glusterfs已在管理节点上安装,这里就不重复说明了,直接简要说明配置文件

[root

admin-node~]#vim/etc/ganesha/ganesha.conf.....................................EXPORT{##ExportId(mandatory,eachEXPORTmusthaveauniqueExport_Id)#Export_Id=;Export_Id=10;##Exportedpath(mandatory)#Path=/nonexistant;Path=/data01;##PseudoPath(requiredforNFSv4orifmount_path_pseudo=true)#Pseudo=/nonexistant;Pseudo=/data01;#客户端通过nfs挂载的根目录##Restricttheprotocolsthatmayusethisexport.Thiscannotallow##accessthatisdeniedinNFS_CORE_PARAM.#Protocols=3,4;Protocols=4;#客户端nfs挂载的版本##Accesstypeforclients.DefaultisNone,sosomeaccessmustbe##given.Itcanbehere,intheEXPORT_DEFAULTS,orinaCLIENTblock#Access_Type=RW;Access_Type=RW;#权限问题##Whethertosquashvarioususers.#Squash=root_squash;Squash=No_root_squash;#root降级##Allowedsecuritytypesforthisexport#Sectype=sys,krb5,krb5i,krb5p;Sectype=sys;#类型##ExportingFSAL#FSAL{#Name=VFS;#}FSAL{Name=GLUSTER;hostname="10..23.44";#glusterfs管理节点IPvolume="data-volume";#glusterfs卷名}}...................

[root

admin-node~]#systemctlrestartnfs-ganesha[root

admin-node~]#systemctlenablenfs-ganesha[root

admin-node~]#showmount-e10..23.44Exportlistfor10..23.44:#nfs-ganesha搭建成功5.客户端挂载

以glusterfs方式挂载:

[root

admin-node~]#mkdir/logs[root

admin-node~]#mount-tglusterfs10..23.44:data-volume/logs/

以NFS方式进行挂载:

在客户端(10.1.99段):

[root

moban-00~]#yum-yinstallnfs-utilsrpcbind[root

moban-00~]#systemctlstartrpcbind[root

moban-00~]#systemctlenablerpcbind[root

moban-00~]#mkdir/home/dwweiyinwen/logs/[root

moban-00~]#mount-tnfs-overs=4,proto=tcp,port=..23.44:/data01/home/dwweiyinwen/logs/

原文:



转载请注明地址:http://www.xqopn.com//zcmbzl/91412.html
  • 上一篇文章:
  • 下一篇文章: 没有了