Glusterfs
glusterfs
是一个大尺度的文件系统,分布部署在多个服务器上,实现文件的复制,存在和备份功能
安装
101.35.241.220 VM-4-8-centos 150.158.153.179 VM-4-16-centos 42.194.147.234 VM-8-15-centos
安装glusterfs(每一个节点)
# 在每一个节点上安装GlusterFS yum install centos-release-gluster -y yum install glusterfs-server -y
启动Glusterfs(每一个节点)
systemctl start glusterd systemctl status glusterd
systemctl enabled glusterd
添加peer节点(在主节点)
gluster peer probe asp-middleware-2(主机名称) gluster peer probe asp-middleware-3(主机名称)
查看节点状态
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# 在master上 gluster peer status >>> Number of Peers: 2 Hostname: asp-middleware-2 Uuid: e733e173-6aae-4d78-9a17-2c9c61ba5d2e State: Peer in Cluster (Connected) Hostname: asp-middleware-3 Uuid: 670a289e-130a-4914-bd4b-19bcb47158b3 State: Peer in Cluster (Connected) # 在asp-middleware-2 gluster peer status >>> Number of Peers: 2 Hostname: asp-middleware-1 Uuid: db5bed73-f572-47d0-953f-591ecb2140e7 State: Peer in Cluster (Connected) Hostname: asp-middleware-3 Uuid: 670a289e-130a-4914-bd4b-19bcb47158b3 State: Peer in Cluster (Connected) # 在asp-middleware-3 gluster peer status >>> Number of Peers: 2 Hostname: asp-middleware-1 Uuid: db5bed73-f572-47d0-953f-591ecb2140e7 State: Peer in Cluster (Connected) Hostname: asp-middleware-2 Uuid: e733e173-6aae-4d78-9a17-2c9c61ba5d2e State: Peer in Cluster (Connected)
创建volume及其他操作
Distributed:分布式卷,文件通过hash算法随机的分不到bricks组成的卷上。
Replicated:复制卷,类似raid1,replica数必须等于volume中brick所包含的存储服务器数,可用性高。
striped:条带式卷,类似raid0,stripe数必须等于volume中brick所包含的存储服务器数,文件会被分成数据块,以Round Robin的方式存储在bricks中,并发粒度是数据块,大文件性能好。
Distributed striped:分布式条带卷,volume中brick所包含的存储服务器必须是stripe的倍数(>=2倍),兼顾分布式和条带式的功能。
Distributed Replicated:分布式的复制卷,volume中brick所包含的存储服务器数必须是replica的倍数(>=2倍),兼顾分布式和复制式的功能。
Stripe Replicated:条带复制卷,volume中brick所包含的存储服务器数必须是stripe和replica的倍数(>=2倍),兼顾条带式和复制式的功能。
Distributed Stripe Replicated:分布式条带复制卷,按需存储服务器数量必须是2*2*2=8共8台,兼顾分布式,条带式和复制式的功能,此处使用了3台服务器,8块硬盘,不尽完美!
创建各种卷语法格式:
volume create <NEW-VOLNAME> [stripe <COUNT>] [replica <COUNT> [arbiter <COUNT>]] [disperse [<COUNT>]] [disperse-data <COUNT>] [redundancy <COUNT>] [transport <tcp|rdma|tcp,rdma>] <NEW-BRICK>?<vg_name>... [force]
创建复制卷
gluster volume create asp replica 3 transport tcp asp-middleware-1:/apps/gluster_volume asp-middleware-2:/apps/gluster_volume asp-middleware-3:/apps/gluster_volume force
-
asp:卷名称
-
replica:指定副本数量
挂载
# 创建目录用于把卷挂载到这个目录 mkdir /apps/gluster_mount # 挂载 mount.glusterfs asp-middleware-1:asp /apps/gluster_mount mount.glusterfs asp-middleware-2:asp /apps/gluster_mount mount.glusterfs asp-middleware-3:asp /apps/gluster_mount
删除peer节点
gluster peer detach hostname
启动卷
gluster volume start asp
停止卷
gluster volume stop asp
删除卷
gluster volume delete asp
参看卷
gluster volume list gluster volume info [all] gluster volume status [all]
本文来自博客园,作者:暮歌行,转载请注明原文链接:https://www.cnblogs.com/xuejian123/p/17201801.html