阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

分布式存储-GlusterFS

298次阅读
没有评论

共计 16831 个字符,预计需要花费 43 分钟才能阅读完成。

一、分布式存储介绍

我们知道 NAS 是远程通过网络共享目录, SAN 是远程通过网络共享块设备。那么分布式存储你可以看作拥有多台存储服务器连接起来的存储输出端。把这多台存储服务器的存储合起来做成一个整体再通过网络进行远程共享, 共享的方式有目录(文件存储), 块设备(块存储), 对象网关或者说一个程序接口(对象存储)。

常见的分布式存储开源软件有:GlusterFS,Ceph,HDFS,MooseFS,FastDFS 等。

分布式存储一般都有以下几个优点:

  1. 扩容方便,轻松达到 PB 级别或以上
  2. 提升读写性能或数据高可用
  3. 避免单个节点故障导致整个架构问题
  4. 价格相对便宜,大量的廉价设备就可以组成,比光纤 SAN 这种便宜很多

二、GlusterFS 介绍

glusterfs 是一个免费, 开源的分布式文件系统(它属于 文件存储类型)。主要由 Z RESEARCH 公司负责开发。GlusterFS 具有强大的横向扩展能力,通过扩展能够支持数 PB 存储容量和处理数千客户端。GlusterFS 可以将物理分布的存储资源聚集在一起,使用单一全局命名空间来管理数据,可为各种不同的数据负载提供优异的性能。

GlusterFS 主要由存储服务器(Brick Server)、客户端以及 NFS/Samba 存储网关组成。在 GlusterFS 架构中没有元数据服务器组件,这是其最大的设计这点,对于提升整个系统的性能、可靠性和稳定性都有着决定性的意义。

GlusterFS 支持 TCP/IP 和 高速网络互联。客户端可通过原生 GlusterFS 协议访问数据,其他没有运行 GlusterFS 客户端的终端可通过 NFS/CIFS 标准协议通过存储网关访问数据。存储服务器主要提供基本的数据存储功能,客户端弥补了没有元数据服务器的问题,承担了更多的功能,包括数据卷管理、I/O 调度、文件定位、数据缓存等功能,利用 FUSE(File system in User Space)模块将 GlusterFS 挂载到本地文件系统之上,来访问系统数据。

三、raid 级别回顾

raid 级别有很多种,下面主要介绍常用的几种:

raid0 读写性能佳,坏了其中一块,数据挂掉,可靠性低(stripe 条带化),磁盘利用率 100%

分布式存储 -GlusterFS

raid1 镜像备份(mirror),同一份数据完整的保存在多个磁盘上,写的性能不佳,可靠性高,读的性能还行,磁盘利用率 50%

分布式存储 -GlusterFS

raid10 先做 raid 1 再做 raid 0

分布式存储 -GlusterFS

raid5 由多块磁盘做 raid 5,磁盘利用率为 n -1/n, 其中一块放校验数据,允许坏一块盘,数据可以利用校验值来恢复

分布式存储 -GlusterFS

raid6 在 raid5 的基础上再加一块校验盘,进一步提高数据可靠性

分布式存储 -GlusterFS

注意:生产环境中最常用的为 raid5 和 raid10

GlusterFS 名词解释

  • Brick: 最基本的存储单元,表示为 trusted storage pool 中输出的目录,供客户端挂载用,一般表示方式为“主机名: 目录名”
  • Volume: 一个卷。在逻辑上由 N 个 bricks 组成.
  • FUSE: Unix-like OS 上的可动态加载的模块,允许用户不用修改内核即可创建自己的文件系统。

四、GlusterFS 卷类型

基本卷

distribute volume 分布式卷 默认:

分布式存储 -GlusterFS

说明:根据 hash 算法,将文件随机存储在一个的 brick 上,文件不能拆分。此时 volume 的容量是所有 brick 的和;方便扩展空间,但无冗余保护;由于使用本地文件系统进行存储(brick server 的本地文件系统),存取效率不高;受限于本地文件系统对单文件容量的限制,支持超大型文件系统有问题。

stripe volume 条带卷:

分布式存储 -GlusterFS

说明:每个文件被分片数据块,然后以 round robin 的方式将每个 chunk 存储到 1 个 brick,相当于 raid0;比如,对于一个文件,奇数行存储在第一个 brick 上,偶数行存储在第二个 brick。单一超大容量文件可被分片,不受 brick server 本地文件系统的限制;分布式读写性能较高,但分片随机读写可能会导致硬盘 iops 较高;无冗余,1 个 server 节点故障会导致所有数据丢失。

replica volume 复制卷(类似 Raid 1):

分布式存储 -GlusterFS

说明:每个文件同步复制镜像到多个 brick,相当于文件级 raid1,一个是存储一个是备份;读性能提升,写性能下降;提升数据可靠性,但磁盘利用率低;如果两台存储服务器不同,就会出现木桶效应

复合卷

distribute replica volume 分布式复制卷:

分布式存储 -GlusterFS

说明:是分布式卷与复制卷的组合,兼具两者的功能,若干 brick 组成 1 个复制卷,另外若干 brick 组成其他复制卷;单个文件在复制卷内数据保持副本,不同文件在不同复制卷之间进行哈希分布

distribute stripe volume 分布式条带卷:

分布式存储 -GlusterFS

说明:分布式卷与条带卷的组合,兼具两者的功能,若干 brick 组成 1 个条带卷,另外若干 brick 组成其他条带卷;单个文件在条带卷内数据以条带的形式存储,不同文件在不同条带卷之间进行哈希分布;

striped replicated volume 条带镜像卷:

分布式存储 -GlusterFS

说明:条带与复制卷的组合,兼具两者的功能,若干 brick 组成 1 个复制卷,另外若干 brick 组成其他复制卷;单个文件以条带的形式存储在 2 个或多个复制集(replicated sets),复制集内文件分片以副本的形式保存;

distribute stripe replica volume 混合卷: 三种基本卷的复合卷,分布式卷,条带与复制卷的组合,兼具三者的功能

dispersed volume: 分散式(冗余式),例如,数据保存在 10 个 brick 中,每个 brick 有 1T,10 个 brick 中有 3 个是作为冗余 brick,作为数据校验,不做存储。此时 volume 只有 7T,volume 中允许有 3 个 brick 损坏

五、glusterfs 集群

目前为止 stripe(条带)类型已经用的越来越少,我们以一个案例说明 distribute(分布式),replica(复制),distribute replica(分布式复制),dispersed(冗余)四种常用的类型如何使用

学习案例

案例需求: 部署一个 glusterfs 存储集群

集群部署: 案例步骤

  1. 部署集群
  2. 创建卷并启动
  3. 客户端连接挂载

实验拓扑图

分布式存储 -GlusterFS

计算机名称 IP 地址 角色
manage01 192.168.98.200 client
node1 192.168.98.201 storage_node
node2 192.168.98.202 storage_node
node3 192.168.98.203 storage_node
node4 192.168.98.204 storage_node
node5 192.168.98.205 storage_node

实验环境

  • CentOS8 系统

  • 关闭防火墙

  • 关闭 selinux

  • 网络连通

  • 时间同步

实验步骤

时间同步

[root@manage01 ~]# vim /etc/chrony.conf server 192.168.98.200 iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync allow 192.168.98.0/24 local stratum 10 leapsectz right/UTC logdir /var/log/chrony bindaddress 192.168.98.200 [root@manage01 ~]# systemctl restart chrony server 192.168.98.200 iburst [root@node1 ~]# systemctl restart chronyd.service

gluster 集群部署

1、安装软件[安装软件、启动服务]

2、部署集群

存储端设置

a、所有存储机器, 设置 Yum 源,安装 gluster

# 官方源地址 https://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-rhel8.repo [root@node2 ~]#vim /etc/yum.repos.d/glusterfs.repo # Place this file in your /etc/yum.repos.d/ directory [glusterfs-rhel8] name=GlusterFS is a clustered file-system capable of scaling to several petabytes. baseurl=https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/RHEL/el-$releasever/$basearch/ enabled=1 skip_if_unavailable=1 gpgcheck=1 gpgkey=https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub [glusterfs-noarch-rhel8] name=GlusterFS is a clustered file-system capable of scaling to several petabytes. baseurl=https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/RHEL/el-$releasever/noarch enabled=1 skip_if_unavailable=1 gpgcheck=1 gpgkey=https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub [glusterfs-source-rhel8] name=GlusterFS is a clustered file-system capable of scaling to several petabytes. - Source baseurl=https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/RHEL/el-$releasever/SRPMS enabled=0 skip_if_unavailable=1 gpgcheck=1 gpgkey=https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub [root@node1 yum.repos.d]# vim /etc/yum.repos.d/CentOS-PowerTools.repo [PowerTools] name=CentOS-$releasever - PowerTools mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra #baseurl=http://mirror.centos.org/$contentdir/$releasever/PowerTools/$basearch/os/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

b、安装 glusterfs 软件包,并启动服务

[root@node2 ~]# dnf install glusterfs-server [root@node2 ~]# systemctl enable glusterd [root@node2 ~]# systemctl start glusterd

glusterfs 集群组成

brick 端:manager/node

client 端:挂载存储业务机器

[root@node2 ~]# gluster peer help # 将 node 节点加入集群 [root@node2 ~]# gluster peer probe node1 peer probe: success. # 从集群中删除 node [root@node2 ~]# gluster peer detach node4 All clients mounted through the peer which is getting detached need to be remounted using one of the other active peers in the trusted storage pool to ensure client gets notification on any changes done on the gluster configuration and if the same has been done do you want to proceed? (y/n) y peer detach: success # 查看集群信息 [root@node2 ~]# gluster peer status [root@node2 ~]# gluster pool list [root@node2 ~]# gluster peer status Number of Peers: 2 Hostname: node1 Uuid: 809111f4-8a0e-40fb-af53-d2d8a56cd41e State: Peer in Cluster (Connected) Hostname: 192.168.98.203 Uuid: 7396a19d-a2a7-4b27-86d3-12c89ac4df39 State: Peer in Cluster (Connected) 或者 [root@node2 ~]# gluster pool list UUID Hostname State 809111f4-8a0e-40fb-af53-d2d8a56cd41e node1 Connected 7396a19d-a2a7-4b27-86d3-12c89ac4df39 192.168.98.203 Connected 0ace00a1-0612-4395-ac9b-f1516207ead1 localhost Connected

c、所有 storage 服务器建立连接,成为一个集群

4个 storage 服务器建立连接不用两两连接,只需要找其中 1 个, 连接另外 3 个各一次就 OK 了 ## 集群管理 # 将 node 节点加入集群 [root@node2 ~]# gluster peer probe node1 peer probe: success. [root@node2 ~]# gluster peer probe node4 peer probe: success. [root@node2 ~]# gluster peer probe node3 -- 这里使用 ip, 主机名, 主机名别名都可以 然后在所有存储上都可以使用下面命令来验证检查 [root@node2 ~]# gluster peer status Number of Peers: 3 Hostname: node1 Uuid: 809111f4-8a0e-40fb-af53-d2d8a56cd41e State: Peer in Cluster (Connected) Hostname: 192.168.98.203 Uuid: 7396a19d-a2a7-4b27-86d3-12c89ac4df39 State: Peer in Cluster (Connected) Hostname: node4 Uuid: b2ea8b19-658c-40ec-84b4-6568c627eefd State: Peer in Cluster (Connected)

注意:

如果这一步建立连接有问题(一般问题会出现在网络连接, 防火墙,selinux, 主机名绑定等);

如果想重做这一步,可以使用 gluster peer detach xxxxx [force] 来断开连接,重新做

存储收集

必须是一个文件夹

1)一块磁盘[分区 格式化 挂载到节点上的指定目录]

  1. 一个磁盘文件[分区 格式化 挂载到节点上的指定目录]

3)分区上的一个文件夹

d、所有 storage 服务器准备存储目录

[root@node2 ~]# mkdir /opt/data{1..5}

e、创建存储卷, 创建存储卷(在任意一个 storage 服务器上做)

glusterfs 支持多种卷
Distribut 卷  分布卷
Replica 卷    复制卷
Disperse 卷   冗余卷

注意:从 6.0 版本开始之前和 Striped 卷相关的卷类型就全部废弃了。https://docs.gluster.org/en/latest/Administrator%20Guide/Setting%20Up%20Volumes/

Replica 卷

文件同步复制到多个 brick 上,文件级 RAID 1,具有容错能力,写性能下降,读性能提升。缺点是磁盘利用率低。

# 创建一个 replica 卷(raid1) 数据会在每个 brick 上存储一份 # 复制卷类似 raid1 所有一般会选择两台来完成, 文件保存两份,如果希望保存多个机器,可以用多台机器,这里用两台。 [root@node2 ~]# gluster volume create gv1-replica replica 2 node{1..2}:/opt/data force volume create: gv1-replica: success: please start the volume to access data replica 代表创建的是镜像卷 2 代表 2 个台机器 由于使用的是根分区 所以要加上强制 force # 查看卷创建情况 [root@node2 ~]# gluster volume info gv1-replica Volume Name: gv1-replica Type: Replicate Volume ID: f93a83dc-9ed6-43fe-99e4-5346d5d1d702 Status: Created Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: node1:/opt/data Brick2: node2:/opt/data Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off

Distribut 卷—数据随机存储在某个 brick

文件通过 hash 算法分布到所有 brick server 上,这种卷是 glusterfs 的基础和最大特点。优点是容量大,缺点是没冗余。

# 如果不指定创建卷的类型,则默认是 Distribute 卷,可以是多个机器。 # 分布卷数据随机存储在某个 brick, 一般是应用在不需要冗余的环境。 [root@node2 ~]# gluster volume create gv2-distribute node{1..3}:/opt/data2 force volume create: gv2-distribute: success: please start the volume to access data # 查看卷 [root@node2 ~]# gluster volume info gv2-distribute Volume Name: gv2-distribute Type: Distribute Volume ID: 079a2f5c-23ac-43f8-9f54-f6a454a53706 Status: Created Snapshot Count: 0 Number of Bricks: 3 Transport-type: tcp Bricks: Brick1: node1:/opt/data2 Brick2: node2:/opt/data2 Brick3: node3:/opt/data2 Options Reconfigured: transport.address-family: inet nfs.disable: on

Disperse 卷(冗余卷)

disperse 卷是 v3.6 版本后发布的一种卷模式,类似于 raid5/6, 分布式分散卷 disperse 必须大于 2, 大于 4 才可以有一块 redundancy 盘 大于 5 块可有 redundancy 盘两块

文件分片存储在各个硬盘上,但有部分硬盘用于冗余用途,数量可以指定。比如一共 10 块硬盘,2 块盘用于冗余,那么就可以承受同时损坏两块硬盘,总容量是 8 块盘。

优点是在冗余和性能之间取得平衡

# 创建卷(raid5 raid6) # 建议不少于 4 个机器 [root@node2 ~]# gluster volume create gv3-disperse disperse 4 node{1..4}:/opt/data3 force There isn't an optimal redundancy value for this configuration. Do you want to create the volume with redundancy 1 ? (y/n) y 指定一个磁盘为校验磁盘 volume create: gv3-disperse: success: please start the volume to access data #查看卷信息 [root@node2 ~]# gluster volume info gv3-disperse Volume Name: gv3-disperse Type: Disperse Volume ID: 754523b3-7e8e-4133-bb77-60c2247711d9 Status: Created Snapshot Count: 0 Number of Bricks: 1 x (3 + 1) = 4 Transport-type: tcp Bricks: Brick1: node1:/opt/data3 Brick2: node2:/opt/data3 Brick3: node3:/opt/data3 Brick4: node4:/opt/data3 Options Reconfigured: transport.address-family: inet nfs.disable: on

distribute replica 分布复制卷

# 创建分布复制卷,机器为偶数 # 每两个分布卷组成一个复制卷, 创建两个复制卷 [root@node2 ~]# gluster volume create gv2-distribute-replica replica 2 node{1..4}:/opt/data4 force volume create: gv2-distribute-replica: success: please start the volume to access data # 查看磁盘信息 [root@node2 ~]# gluster volume info gv2-distribute-replica Volume Name: gv2-distribute-replica Type: Distributed-Replicate Volume ID: 90d70fef-54a9-4555-98ad-0d1a342f6763 Status: Created Snapshot Count: 0 Number of Bricks: 2 x 2 = 4 Transport-type: tcp Bricks: Brick1: node1:/opt/data4 Brick2: node2:/opt/data4 Brick3: node3:/opt/data4 Brick4: node4:/opt/data4 Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off

f、启动卷

gluster volume star 卷名称

# 查看卷 [root@node2 ~]# gluster volume list gv1-replica gv2-distribute gv2-distribute-replica gv3-disperse # 启动卷 [root@node2 ~]# gluster volume start gv1-replica volume start: gv1-replica: success [root@node2 ~]# gluster volume start gv2-distribute volume start: gv2-distribute: success [root@node2 ~]# gluster volume start gv2-distribute-replica volume start: gv2-distribute-replica: success [root@node2 ~]# gluster volume start gv3-disperse volume start: gv3-disperse: success

存储卷管理 - 卷的增删改查

# [root@node2 ~]# gluster volume help 打印帮助信息 # 卷的创建 gluster volume create [root@node2 ~]# gluster volume create <NEW-VOLNAME> [stripe <COUNT>] [replica <COUNT> [arbiter <COUNT>]] [disperse [<COUNT>]] [disperse-data <COUNT>] [redundancy <COUNT>] [transport <tcp|rdma|tcp,rdma>] <NEW-BRICK>... [force] <NEW-VOLNAME> 卷名 [stripe <COUNT>] [replica <COUNT> [arbiter <COUNT>]] [disperse [<COUNT>]] [disperse-data <COUNT>] 卷类型 stripe 条带 replica 复制 什么都不加 默认分布 disperse 冗余 redundancy 校验磁盘 transport 传输方式 tcp rdma 内存 force 强制,如果存储在根分区 # 卷删除 [root@node2 ~]# gluster volume delete <VOLNAME> # 卷查看 [root@node2 ~]# gluster volume list #卷列表 [root@node2 ~]# gluster volume info [<VOLNAME> | all] #卷详细信息 [root@node2 ~]# gluster volume status [<VOLNAME> | all] #卷启动或关闭的状态信息 # 扩容卷 [root@node2 ~]# gluster volume add-brick <VOLNAME> [<stripe|replica> <COUNT> [arbiter <COUNT>]] <NEW-BRICK> ... [force] # 缩减卷 [root@node2 ~]# gluster volume remove-brick # 卷启动 [root@node2 ~]# gluster volume start <VOLNAME> # 卷关闭 [root@node2 ~]# gluster volume stop <VOLNAME> # 卷替换 [root@node2 ~]# gluster volume replace-brick

客户端设置挂载分布式卷

客户端安装软件

[root@manage01 ~]# dnf install glusterfs glusterfs-fuse -y # 客户端在安装软件的时候注意版本,如果服务端与客户端使用的版本不一致,会导致挂载失败

客户端挂载,验证上述卷数据存储方式

# 建立挂载点并挂载 [root@manage01 ~]# mkdir /opt/gluster_disk{1..4} [root@manage01 ~]# mount -t glusterfs node1:/gv1-replica /opt/gluster_disk1/ [root@manage01 ~]# mount -t glusterfs node1:/gv2-distribute /opt/gluster_disk2 [root@manage01 ~]# mount -t glusterfs node1:/gv2-distribute-replica /opt/gluster_disk3 [root@manage01 ~]# mount -t glusterfs node1:/gv3-disperse /opt/gluster_disk4 # 查看挂载 [root@manage01 ~]# mount |grep "gluster" node1:/gv1-replica on /opt/gluster_disk1 type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072) node1:/gv2-distribute on /opt/gluster_disk2 type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072) node1:/gv2-distribute-replica on /opt/gluster_disk3 type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072) node1:/gv3-disperse on /opt/gluster_disk4 type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072) # 分别存储数据 [root@manage01 ~]# dd if=/dev/zero of=/opt/gluster_disk1/file bs=1M count=100 记录了100+0 的读入 记录了100+0 的写出 104857600字节 (105 MB) 已复制,1.281 秒,81.9 MB/ 秒 [root@manage01 ~]# dd if=/dev/zero of=/opt/gluster_disk2/file bs=1M count=100 记录了100+0 的读入 记录了100+0 的写出 104857600字节 (105 MB) 已复制,0.974837 秒,108 MB/ 秒 [root@manage01 ~]# dd if=/dev/zero of=/opt/gluster_disk3/file bs=1M count=100 记录了100+0 的读入 记录了100+0 的写出 104857600字节 (105 MB) 已复制,1.53898 秒,68.1 MB/ 秒 [root@manage01 ~]# dd if=/dev/zero of=/opt/gluster_disk4/file bs=1M count=100 记录了100+0 的读入 记录了100+0 的写出 104857600字节 (105 MB) 已复制,1.80071 秒,58.2 MB/ 秒 # 验证 # 复制卷 数据每个节点都存储了一份 [root@node1 ~]# ls /opt/data -lh 总用量 100M -rw-r--r-- 2 root root 100M 77 08:51 file [root@node2 ~]# ls /opt/data -lh 总用量 100M -rw-r--r-- 2 root root 100M 77 08:51 file # 分布卷 数据存在了 node1 [root@node1 ~]# ls /opt/data2 -lh 总用量 100M -rw-r--r-- 2 root root 100M 77 08:51 file [root@node2 ~]# ls /opt/data2 -lh 总用量 0 [root@node3 ~]# ls /opt/data2 -lh 总用量 0 # 冗余卷 发现数据平均分布在每个存储节点 [root@node1 ~]# ls /opt/data3 -lh 总用量 34M -rw-r--r-- 2 root root 34M 77 08:52 file [root@node2 ~]# ls /opt/data3 -lh 总用量 34M -rw-r--r-- 2 root root 34M 77 08:52 file [root@node3 ~]# ls /opt/data3 -lh 总用量 34M -rw-r--r-- 2 root root 34M 77 08:52 file [root@node4 ~]# ls /opt/data3/ -lh 总用量 34M -rw-r--r-- 2 root root 34M 77 08:52 file # 分布复制卷 发现数据存在了 node3 node4 这对复制卷上, [root@node1 ~]# ls /opt/data4 -lh 总用量 0 [root@node2 ~]# ls /opt/data4 -lh 总用量 0 [root@node3 ~]# ls /opt/data4 -lh 总用量 100M -rw-r--r-- 2 root root 100M 77 08:51 file [root@node4 ~]# ls /opt/data4/ -lh 总用量 100M -rw-r--r-- 2 root root 100M 77 08:51 file

删除卷

  1. 删除卷中数据
  2. 客户端卸载
  3. 在任意一个节点执行删除
  4. 验证删除

实践练习

删除卷中数据

[root@manage01 ~]# rm -rf /opt/gluster_disk1/*

客户端卸载

[root@manage01 ~]# umount /opt/gluster_disk1/

卷删除

#3. 在任意一个节点删除 [root@node1 ~]# gluster volume stop gv1-replica [root@node1 ~]# gluster volume delete gv1-replica Deleting volume will erase all information about the volume. Do you want to continue? (y/n) y volume delete: gv1-replica: failed: Volume vg0 does not exist

验证删除

[root@node1 ~]# gluster volume info gv1-replica Volume gv1-replica does not exist

在线裁减与在线扩容

在线裁减要看是哪一种模式的卷,比如 stripe 模式就不允许在线裁减。下面我以 distributed 卷来做裁减与扩容

在线扩容

# 查看卷 [root@node2 ~]# gluster volume info gv2-distribute Volume Name: gv2-distribute Type: Distribute Volume ID: 079a2f5c-23ac-43f8-9f54-f6a454a53706 Status: Started Snapshot Count: 0 Number of Bricks: 3 Transport-type: tcp Bricks: Brick1: node1:/opt/data2 Brick2: node2:/opt/data2 Brick3: node3:/opt/data2 Options Reconfigured: transport.address-family: inet nfs.disable: on # 扩容 [root@node2 ~]# gluster volume add-brick gv2-distribute node4:/opt/data2 force volume add-brick: success # 验证 [root@node2 ~]# gluster volume info gv2-distribute Volume Name: gv2-distribute Type: Distribute Volume ID: 079a2f5c-23ac-43f8-9f54-f6a454a53706 Status: Started Snapshot Count: 0 Number of Bricks: 4 Transport-type: tcp Bricks: Brick1: node1:/opt/data2 Brick2: node2:/opt/data2 Brick3: node3:/opt/data2 Brick4: node4:/opt/data2 Options Reconfigured: transport.address-family: inet nfs.disable: on

在线裁减(注意要 remove 没有数据的 brick)

# 裁剪卷. [root@node2 ~]# gluster volume remove-brick gv2-distribute node4:/opt/data2 force Remove-brick force will not migrate files from the removed bricks, so they will no longer be available on the volume. Do you want to continue? (y/n) y volume remove-brick commit force: success # 查看验证 [root@node2 ~]# gluster volume info gv2-distribute Volume Name: gv2-distribute Type: Distribute Volume ID: 079a2f5c-23ac-43f8-9f54-f6a454a53706 Status: Started Snapshot Count: 0 Number of Bricks: 3 Transport-type: tcp Bricks: Brick1: node1:/opt/data2 Brick2: node2:/opt/data2 Brick3: node3:/opt/data2 Options Reconfigured: performance.client-io-threads: on transport.address-family: inet nfs.disable: on 关于裁剪卷, 线上几乎不会裁剪,基本上都是扩容,而且裁剪只能裁剪没有数据的,否则可能数据丢失。所以,有些卷是不支持裁剪的。

在线替换卷

[root@node2 ~]# gluster volume list gv1-replica gv2-distribute gv2-distribute-replica gv3-disperse [root@node2 ~]# gluster volume info gv1-replica # 查看源信息 Volume Name: gv1-replica Type: Replicate Volume ID: f93a83dc-9ed6-43fe-99e4-5346d5d1d702 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: node1:/opt/data Brick2: node2:/opt/data Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off # 卷替换 [root@node2 ~]# gluster volume replace-brick gv1-replica node2:/opt/data node4:/opt/data commit force volume replace-brick: success: replace-brick commit force operation successful # 验证替换 [root@node2 ~]# gluster volume info gv1-replica Volume Name: gv1-replica Type: Replicate Volume ID: f93a83dc-9ed6-43fe-99e4-5346d5d1d702 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: node1:/opt/data Brick2: node4:/opt/data Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off

拓展:4 个存储想扩容为 5 个存储怎么做?

答案: 第 5 个存储服务器安装服务器软件包,启动服务,然后 gluster peer probe storage5 加入集群 # 加入集群 [root@node2 ~]# gluster peer probe node5 peer probe: success. [root@node2 ~]# gluster peer status Number of Peers: 4 Hostname: node1 Uuid: 809111f4-8a0e-40fb-af53-d2d8a56cd41e State: Peer in Cluster (Connected) Hostname: 192.168.98.203 Uuid: 7396a19d-a2a7-4b27-86d3-12c89ac4df39 State: Peer in Cluster (Connected) Hostname: node4 Uuid: b2ea8b19-658c-40ec-84b4-6568c627eefd State: Peer in Cluster (Connected) Hostname: node5 Uuid: 82f424cb-1c7d-4057-8f40-f236015f8940 State: Peer in Cluster (Connected)

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-06-09发表,共计16831字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中