• GlusterFS 分布式文件系统的使用入门-管理GlusterFS卷


                  GlusterFS 分布式文件系统的使用入门-管理GlusterFS卷

                                             作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

    一.卷的扩容

      您可以根据需要在群集联机且可用时扩展卷。例如,您可能希望向分布式卷添加块,从而增加分发并增加GlusterFS卷的容量。

    1>.添加扩展卷

    [root@node101 ~]# df -h | grep gluster
    node101.yinzhengjie.org.cn:/test-volume                         23G  312M   22G   2% /mnt/gluster1
    node101.yinzhengjie.org.cn:/replicated-volume                   12G  156M   11G   2% /mnt/gluster2
    node101.yinzhengjie.org.cn:/raid0-volume                        23G  312M   22G   2% /mnt/gluster3
    node101.yinzhengjie.org.cn:/distributed-replication-volume      12G  156M   11G   2% /mnt/gluster4
    node101.yinzhengjie.org.cn:/my-distributed-replication-volume   12G  156M   11G   2% /mnt/gluster10
    [root@node101 ~]#  
    [root@node101 ~]# mkdir /home/yinzhengjie/glusterfs/file8                                            #我们这里创建一个目录,用来模拟设备的挂载点
    [root@node101 ~]# 
    [root@node101 ~]# gluster volume add-brick test-volume node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8         #我们将块存储挂载到分布式卷中
    volume add-brick: success
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# gluster volume info test-volume
     
    Volume Name: test-volume
    Type: Distribute
    Volume ID: d73f1306-1984-4fea-8fe2-a37771b471d5
    Status: Started
    Snapshot Count: 0
    Number of Bricks: 3
    Transport-type: tcp
    Bricks:
    Brick1: node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Brick2: node102.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Brick3: node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8        #这块磁盘就是咱们刚刚加上去的,注意生产环境操作基本上也是这样,只不过不是我们随手创建一个目录,而是把存储社保挂载到咱们指定到挂载点上而已!
    Options Reconfigured:
    transport.address-family: inet
    nfs.disable: on
    [root@node101 ~]# 

    2>.重新均衡扩展卷

      往卷中添加一块设备后,需要咱们手动均衡一下,否则数据不会往新设备上存储哟,具体操作如下:

    [root@node101 ~]# gluster volume rebalance test-volume start              #重新均衡的适合需要等待一定的时间!
    volume rebalance: test-volume: success: Rebalance on test-volume has been started successfully. Use rebalance status command to check status of the rebalance process.
    ID: 7bd59481-af36-4fcc-9b04-9d421e4d6c0f
    [root@node101 ~]# 

    3>.往卷中添加数据

    [root@node101 ~]# ls  /home/yinzhengjie/glusterfs/file8/
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# touch /mnt/gluster1/{1..100}.txt
    [root@node101 ~]# 
    [root@node101 ~]# ls /mnt/gluster1/               
    100.txt  13.txt  17.txt  20.txt  24.txt  28.txt  31.txt  35.txt  39.txt  42.txt  46.txt  4.txt   53.txt  57.txt  60.txt  64.txt  68.txt  71.txt  75.txt  79.txt  82.txt  86.txt  8.txt   93.txt  97.txt  blog.txt
    10.txt   14.txt  18.txt  21.txt  25.txt  29.txt  32.txt  36.txt  3.txt   43.txt  47.txt  50.txt  54.txt  58.txt  61.txt  65.txt  69.txt  72.txt  76.txt  7.txt   83.txt  87.txt  90.txt  94.txt  98.txt
    11.txt   15.txt  19.txt  22.txt  26.txt  2.txt   33.txt  37.txt  40.txt  44.txt  48.txt  51.txt  55.txt  59.txt  62.txt  66.txt  6.txt   73.txt  77.txt  80.txt  84.txt  88.txt  91.txt  95.txt  99.txt
    12.txt   16.txt  1.txt   23.txt  27.txt  30.txt  34.txt  38.txt  41.txt  45.txt  49.txt  52.txt  56.txt  5.txt   63.txt  67.txt  70.txt  74.txt  78.txt  81.txt  85.txt  89.txt  92.txt  96.txt  9.txt
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# ls /home/yinzhengjie/glusterfs/file8/
    100.txt  24.txt  2.txt  30.txt  36.txt  38.txt  44.txt  54.txt  5.txt  60.txt  64.txt  65.txt  69.txt  74.txt  7.txt  84.txt  87.txt  95.txt  98.txt
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# ls /home/yinzhengjie/glusterfs/file1/
    10.txt 12.txt 15.txt 18.txt 20.txt 22.txt 3.txt 47.txt 57.txt 67.txt 70.txt 72.txt 77.txt 92.txt
    11.txt 14.txt 16.txt 1.txt 21.txt 25.txt 43.txt 55.txt 61.txt 6.txt 71.txt 75.txt 88.txt blog.txt
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# ssh node102.yinzhengjie.org.cn
    Last login: Mon Feb 18 19:09:42 2019 from node101.yinzhengjie.org.cn
    [root@node102 ~]# 
    [root@node102 ~]# ls /home/yinzhengjie/glusterfs/file1/
    13.txt 23.txt 28.txt 32.txt 35.txt 40.txt 45.txt 49.txt 51.txt 56.txt 62.txt 68.txt 78.txt 81.txt 85.txt 8.txt 93.txt 97.txt
    17.txt 26.txt 29.txt 33.txt 37.txt 41.txt 46.txt 4.txt 52.txt 58.txt 63.txt 73.txt 79.txt 82.txt 86.txt 90.txt 94.txt 99.txt
    19.txt 27.txt 31.txt 34.txt 39.txt 42.txt 48.txt 50.txt 53.txt 59.txt 66.txt 76.txt 80.txt 83.txt 89.txt 91.txt 96.txt 9.txt
    [root@node102 ~]#

    二.卷的缩容

      您可以根据需要在群集联机且可用时缩小卷。例如,您可能需要删除由于硬件或网络故障而在分布式卷中无法访问的块。

    [root@node101 ~]# gluster volume info test-volume
    
    Volume Name: test-volume
    Type: Distribute
    Volume ID: d73f1306-1984-4fea-8fe2-a37771b471d5
    Status: Started
    Snapshot Count: 0
    Number of Bricks: 3
    Transport-type: tcp
    Bricks:
    Brick1: node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Brick2: node102.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Brick3: node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8
    Options Reconfigured:
    performance.client-io-threads: on
    transport.address-family: inet
    nfs.disable: on
    [root@node101 ~]#
    [root@node101 ~]# gluster volume remove-brick test-volume node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8 start
    Running remove-brick with cluster.force-migration enabled can result in data corruption. It is safer to disable this option so that files that receive writes during migration are not migrated.
    Files that are not migrated can then be manually copied after the remove-brick commit operation.
    Do you want to continue with your current cluster.force-migration settings? (y/n) y        #这里会有一个提示,提示咱们可能存在数据丢失的风险,我输入y即可!由此可见官方并不推荐我们对GlusterFS进行缩容操作,对扩容操作倒是很支持呢!
    volume remove-brick start: success
    ID: 8e121850-c23b-4be3-94c4-c854148e5077
    [root@node101 ~]# 
    [root@node101 ~]# 
    [root@node101 ~]# ls /home/yinzhengjie/glusterfs/file8/        #很显然这个目录对数据已经不再了,当然里面对数据会被转移走,这就是为什么执行上面的那条命令会等很长一段时间的缘由!
    [root@node101 ~]# 
    [root@node101 gluster1]# gluster volume remove-brick test-volume node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8 status
                                        Node Rebalanced-files          size       scanned      failures       skipped               status  run time in h:m:s  
                                   ---------      -----------   -----------   -----------   -----------   -----------         ------------     --------------
                                   localhost               19        0Bytes            47             0             0            completed        0:00:00      #大家看着一行的status的值,如果为completed时,则说明可以执行下面的一条命令了,官方网站是这么说的!
    [root@node101 gluster1]# 
    [root@node101 gluster1]# 
    [root@node101 gluster1]# gluster volume remove-brick test-volume node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8 commit      #提交我们一处该块磁盘的操作
    volume remove-brick commit: success
    Check the removed bricks to ensure all files are migrated.
    If files with data are found on the brick path, copy them via a gluster mount point before re-purposing the removed brick. 
    [root@node101 gluster1]# 
    [root@node101 gluster1]# gluster volume info test-volume            #再次查我们会发现node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file8这个文块设备不见啦!
     
    Volume Name: test-volume
    Type: Distribute
    Volume ID: d73f1306-1984-4fea-8fe2-a37771b471d5
    Status: Started
    Snapshot Count: 0
    Number of Bricks: 2
    Transport-type: tcp
    Bricks:
    Brick1: node101.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Brick2: node102.yinzhengjie.org.cn:/home/yinzhengjie/glusterfs/file1
    Options Reconfigured:
    performance.client-io-threads: on
    transport.address-family: inet
    nfs.disable: on
    [root@node101 gluster1]# 

      博主推荐阅读:https://docs.gluster.org/en/latest/Administrator%20Guide/Managing%20Volumes/

  • 相关阅读:
    如何使用NuGet package .nupkg文件?
    利用Z.Expressions.Eval表达式求值
    表达式实现填写“阶段标记”属性
    NX导入DWG失败
    简单工厂模式(Simple Factory Pattern)
    电脑装系统蓝屏未解决
    idea intellij 配置总结
    poiexcel 笔记
    Springboot
    Springboot--maven命令子模块单独打包
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/10397424.html
Copyright © 2020-2023  润新知