glusterfs 使用心得

Glusterfs 个人使用心得

Glusterfs是一个开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端。

是整合了许多存储块(server)通过 Infiniband RDMA或者 Tcp/Ip方式互联的一个并行的网络文件系统。

其具有如下特点:

容量可以按比例的扩展,且性能却不会因此而降低。

廉价且使用简单,完全抽象在已有的文件系统之上。

扩展和容错设计的比较合理,复杂度较低

适应性强,部署方便,对环境依赖低,使用,调试和维护便利

有3种基本类型的券,可以组合成7种使用方式。

一,部署

1,准备

两台主机:

IP:192.168.204.128  主机名:linux-test-1

IP:192.168.204.129  主机名:linux-test-node1

目录规划:

在 128 主机上,建立:mkdir -p /root/gluster/data/{exp1,exp3,exp5}

在 129 主机上,建立:mkdir -p /root/gluster/data/{exp2,exp4,exp6}

在2台主机上分别创建 3 个目录

2,安装部署 glusterfs(2台主机均安装)

1,先查看当前系统时候有安装源

[root@linux-test-1 data]# yum search  centos-release-gluster

2,使用某一个源,如果没有,可以参考网上源,进行添加,然后安装。

[root@linux-test-1 data]# yum install -y centos-release-gluster7.noarch

3,安装部署 glusterfs

[root@linux-test-1 data]# yum -y install glusterfs-server

4,启动 glusterfs

[root@linux-test-1 data]# systemctl start glusterd

二,创建卷

1 ,创建分布式卷

1,分别在 128 和 129 主机上启动 glusterfs 

[root@linux-test-1 data]# sytemctl start glusterd

2,建立信任,在其中一台机器上操作即可

[root@linux-test-1 data]# gluster peer probe 192.168.204.129

3,查看状态

[root@linux-test-1 data]# gluster peer status

4,建立分布式卷。

[root@linux-test-1 data]# gluster volume create test-volume 192.168.204.128:/root/glusterfs/data/exp1 192.168.204.129:/root/glusterfs/data/exp2 force

5,查看刚刚建立好的分布式卷

[root@linux-test-1 data]# gluster volume info

 

 

 2,创建复制式卷

1,创建复制是卷

[root@linux-test-1 data]# gluster volume create repl-volume replica 2 transport tcp 192.168.204.128:/root/glusterfs/data/exp3 192.168.204.129:/root/glusterfs/data/exp4 force

2,查看状态

[root@linux-test-1 data]# gluster volume info

3,创建条带式卷

1,创建

[root@linux-test-1 data]#  gluster volume create raid0-volume stripe 2 transport tcp 192.168.204.128:/root/glusterfs/data/exp5 192.168.204.129:/root/glusterfs/data/exp6 force

4,启用卷

1,查看卷的状态

[root@linux-test-1 data]# gluster volume status

 

 

 2,启动卷

[root@linux-test-1 data]# gluster volume start repl-volume

volume start: repl-volume: success

[root@linux-test-1 data]# gluster volume start test-volume

volume start: test-volume: success

[root@linux-test-1 data]# 

三,挂载卷进行使用

挂载需要安装 glusterfs 原生的 gluster-client,默认安装 server时候已经安装了

1,创建挂载点

创建3个目录

[root@linux-test-1 mnt]# mkdir -p /root/glusterfs/mnt/{g1,g2,g3}

2,挂载卷到目录中

[root@linux-test-1 mnt]# mount.glusterfs 192.168.204.128:/test-volume /root/glusterfs/mnt/g1/

[root@linux-test-1 mnt]# mount.glusterfs 192.168.204.128:/repl-volume /root/glusterfs/mnt/g2/ 

 

 

 3,分布式卷的使用

1,进入挂载目录

[root@linux-test-1 g1]# cd /root/glusterfs/mnt/g1

2,测试

[root@linux-test-1 g1]# echo 1 > test1.txt

3,观察这个文件写入哪个服务器中

分别在 128 和 129 主机上,进入下面的目录

[root@linux-test-1 data]#  cd /root/glusterfs/data

[root@linux-test-1 data]# tree

 

 

 4,复制式卷的使用

1,进入挂载目录

[root@linux-test-1 g2]# cd /root/glusterfs/mnt/g2

2,测试

[root@linux-test-1 g1]# echo 2 > test2.txt

3,观察这个文件写入哪个服务器中

分别在 128 和 129 主机上,进入下面的目录

[root@linux-test-1 data]#  cd /root/glusterfs/data

[root@linux-test-1 data]# tree

 

 

 上面是 128 主机的情况,下面是 129 主机的查看情况。

 

 

 

 

四,分布式复制卷使用

目录规划:

在 128 主机上,建立:mkdir -p /root/gluster/data/{exp7,exp9}

在 129 主机上,建立:mkdir -p /root/gluster/data/{exp8,exp10}

其中 exp7 和 exp9 为分布式,而 exp8 和 exp10 分别为对应的 exp7 和 exp9 的复制

1,创建卷

[root@linux-test-1 data]# gluster volume create fenbu-repl-volume replica 2 transport tcp 192.168.204.128:/root/glusterfs/data/exp7 192.168.204.129:/root/glusterfs/data/exp8 192.168.204.128:/root/glusterfs/data/exp9 192.168.204.129:/root/glusterfs/data/exp10 force

2,挂载使用

1,创建挂载点:

[root@linux-test-1 mnt]# mkdir -p /root/glusterfs/mnt/g4

2,挂载

[root@linux-test-1 mnt]# mount.glusterfs 192.168.204.128:/fenbu-repl-volume /root/glusterfs/mnt/g4

3,进入挂载目录

[root@linux-test-1 g4]# cd /root/glusterfs/mnt/g4

4,测试

[root@linux-test-1 g4]# man tcp > test1.txt

[root@linux-test-1 g4]# man tcp > test2.txt

[root@linux-test-1 g4]# man tcp > test3.txt

[root@linux-test-1 g4]# man tcp > test4.txt

5,观察这个文件写入哪个服务器中

分别在 128 和 129 主机上,进入下面的目录

[root@linux-test-1 data]#  cd /root/glusterfs/data

[root@linux-test-1 data]# tree

 

 

 

五,扩展和收缩

1,扩展 - (这里以扩展分布式卷为实例)

1,创建增加的目录 exp11

[root@linux-test-1 ~]# cd /root/glusterfs/data/

[root@linux-test-1 data]# mkdir exp11

2,查看当前分布式卷的情况

[root@linux-test-1 data]# gluster volume info test-volume

 

 3,新增卷到分布式卷 test-volume 中

[root@linux-test-1 data]# gluster volume add-brick test-volume 192.168.204.128:/root/glusterfs/data/exp11 force

 

 4,重新均衡卷 test-volume 的卷。

[root@linux-test-1 data]# gluster volume rebalance test-volume start

5,测试

[root@linux-test-1 ~]# cd /root/glusterfs/mnt/g1/

[root@linux-test-1 g1]# touch {1..100}.txt

[root@linux-test-1 data]# tree /root/glusterfs/data/

 

 查看 exp11 的目录是否有文件,有文件则,表明已生效。

2,收缩

收缩,可能会造成数据的丢失

1,进行收缩

[root@linux-test-1 data]# gluster volume remove-brick test-volume 192.168.204.128:/root/glusterfs/data/exp11 start

2,查收收缩后,查看 exp11 的目录是否还有文件。

 

 3,查看 test-volume 卷中,时候还包含 exp11 

[root@linux-test-1 data]#  gluster volume info test-volume

 

 4,强制移走

[root@linux-test-1 data]# gluster volume remove-brick test-volume 192.168.204.128:/root/glusterfs/data/exp11 force

 

 

posted @ 2020-05-19 22:29  流年浮生  阅读(229)  评论(0)    收藏  举报