站長資訊網
        最全最豐富的資訊網站

        CentOS 7.5下部署GlusterFS分布式存儲集群環境

        最小化安裝的CentOS 7.5
        內存大于1GB
        關閉selinux,防火墻端口放行(port:24007,111)(測試建議關閉firewalld)

        一、環境部署

        所有軟件包離線安裝,原因是yum安裝的不能很好的控制版,用到的軟件包統一放到/gfs目錄,包已整理好

        ——————————————分割線——————————————

        Matlab R2017b的Linux版下載地址可從以下信息的得到下載:

        點擊這個http://www.linuxidc.com/Linux/2013-12/93755.htm 鏈接關注 Linux公社官方微信,關注后回復數字158712。即可得到網友的分享密碼。

        如果取消關注Linux公社公眾號,即使再次關注,也將無法提供本服務!

        鏈接: https://pan.baidu.com/s/1eSSX46yaGBUoEmCqjeAeqw 密碼:獲得見上面的方法,地址失效請在下面留言。

        ——————————————分割線——————————————

        • 測試用的磁盤分配以及服務器架構圖
          CentOS 7.5下部署GlusterFS分布式存儲集群環境

        • basic代表服務器本來使用的磁盤,基礎上再添加上圖相應的磁盤,由于是測試用,為方便直觀理解,磁盤大小就是后面的數字:如sdb3,該磁盤大小為3GB。
        • 卷的分布方案

        卷名稱 卷類型 空間大小/GB  存儲塊
        dis-volume 分布式卷 12 node1(/sde6),node2(/sde6)
        stripe-volume 條帶卷 10 node1(/sdd5),node2(/sdd5)
        rep-volume 復制卷 5 node3(/sdd5),node4(/sdd5)
        dis-stripe 分布式條帶卷 12 node1(/sdb3),node2(/sdb3),node3(/sdb3),node4(/sdb3)
        dis-rep 分布式復制卷 8 node1(/sdc4),node2(/sdc4),node3(sdc4),node4(sdc4)
        • 全部主機修改主機名
        • 全部主機配置hosts文件,一樣的
        • 全部node主機創建掛載文件夾,依實際掛載點創建
        • 全部主機創建/gfs文件夾,將所需軟件包放入

          mkdir /{gfs,sdb3,sdc4,sdd5} cat /etc/hosts

        127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4  ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6  192.168.64.11 node1  192.168.64.12 node2  192.168.64.13 node3  192.168.64.14 node4  192.168.64.15 client
        • 完畢之后進行ping測試
        • 通過傳輸方式將軟件包上傳到/gfs文件(里面有一個repo文件夾也要上傳)
        • 以上一切完成之后,全部node主機執行以下腳本
        vim install.sh  #!/bin/bash  for i in $(fdisk -l | grep -wo "/dev/sd[b-z]" | sort)  do  dd if=/dev/zero of=$i bs=1024 count=1024  fdisk $i << EOF  n  p        w  EOF  #空行很重要不要刪除  partprobe $i   #//不重啟系統識別分區  mkfs.ext4 ${i}1   #//格式化分區  done    mkdir /b3 /c4 /d5 /e6   fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(/d.{8}).*/1/g' | sed -r 's/(.*)(.{3}):(.*)/mount 121 /23/' | bash  fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(/d.{8}).*/1/g' | sed -r 's/(.*)(.{3}):(.*)/121 /23 xfs default 0 0/' >> /etc/fstab  #-w 只顯示全字符合的列。  iptables -F  systemctl stop firewalld  setenforce 0    cat << EOF >> /etc/yum.repos.d/gfs.repo   [gfs]  name=gfs  baseurl=file:///gfs  gpgcheck=0  enabled=1  EOF    yum clean all && yum makecache  yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma  systemctl start glusterd  systemctl enable glusterd  EOF

        sh install.sh //執行腳本 netstat -lnpt //查看gluster服務端口是否開啟
        腳本簡單理解

        • 再node1上執行如下命令構建gluster集群
        [root@node1 ~]# gluster peer probe node2  peer probe: success.   [root@node1 ~]# gluster peer probe node3  peer probe: success.   [root@node1 ~]# gluster peer probe node4  peer probe: success. 

        [root@node1 ~]# gluster peer status //在每個節點上執行查看集群狀態;正常時為(Connected)

        二、創建卷

        1.創建分布式卷(擴大磁盤空間,讀寫速度快,沒有容錯能力)

        [root@node1 ~]# gluster volume create dis-volume node1:/sde6 node2:/sde6 force //dis-volume為卷名稱,未指定創建卷類型,默認為分布式卷 volume create: dis-volume: success: please start the volume to access data [root@node1 ~]# gluster volume start dis-volume volume start: dis-volume: success [root@node1 ~]# gluster volume info dis-volume //查看該卷的相關信息

        2.創建條帶卷(以數據塊為單位存儲,沒有容錯性)

        [root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/sdd5 node2:/sdd5 force [root@node1 ~]# gluster volume start stripe-volume volume start: stripe-volume: success //stripe表示卷類型條帶卷,后面的數量表示條帶數

        3.創建復制卷(磁盤空間為總空間一半,具備容錯性,讀快,寫慢)

        [root@node1 ~]# gluster volume create rep-volume replica 2 node3:/sdd5 node4:/sdd5 force [root@node1 ~]# gluster volume start rep-volume volume start: rep-volume: success

        4.創建分布式條帶卷(加大容量,讀取快,沒有容錯性)

        [root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/sdb3 node2:/sdb3 node3:/sdb3 node4:/sdb3 force //指定類型為Distributed-Stripe,數值為2,而且后面跟了4個Brick Server,是2的2倍,所以創建的是分布式條帶卷。 volume create: dis-stripe: success: please start the volume to access data [root@node1 ~]# gluster volume start dis-stripe volume start: dis-stripe: success

        5.創建分布式復制卷(擴展空間,總空間的一半,且具有容錯能力)

        [root@node1 ~]# gluster volume create dis-rep replica 2 node1:/sdc4 node2:/sdc4 node3:/sdc4 node4:/sdc4/ force //指定類型為Distributed-Replicate,數值為2,而且后面跟了4個Brick Server,是2的2倍,所以創建的是分布式復制卷。 volume create: dis-rep: success: please start the volume to access data [root@node1 ~]# gluster volume start dis-rep volume start: dis-rep: success

        三、部署Gluster客戶端

        1.安裝客戶端軟件
        • 將軟件包放至/gfs文件夾
        • 修改前面提到的hostname以及hosts
        • 運行如下腳本
        vim in_cl.sh  #!/bin/bash    cat << EOF >> /etc/yum.repos.d/gfs.repo   [gfs]  name=gfs  baseurl=file:///gfs  gpgcheck=0  enabled=1  EOF    yum clean all && yum makecache  yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma  systemctl start glusterd  systemctl enable glusterd

        sh in_cl.sh netstat -lnpt | grep glu //可以看到服務已經啟動
        [root@client ~]# mkdir -pv /test/{dis,stripe,rep,dis_stripe,dis_rep} //創建掛載目錄 [root@client ~]# mount -t glusterfs node1:dis-volume /test/dis [root@client ~]# mount -t glusterfs node1:stripe-volume /test/stripe/ [root@client ~]# mount -t glusterfs node1:rep-volume /test/rep/ [root@client ~]# mount -t glusterfs node1:dis-stripe /test/dis_stripe/ [root@client ~]# mount -t glusterfs node1:dis-rep /test/dis_rep/ //掛載glusterfs文件系統到本地客戶端,所制定的node1節點只是為了獲取配置信息,不代表只和他進行數據傳輸,會根據配置針對集群來進行數據的存放

        • 修改fstab文件實現永久掛載
        • 添加如下文件

          vim /etc/fstab

        node1:dis-volume        /test/dis               glusterfs defaults,_netdev 0 0  node1:stripe-volume     /test/stripe            glusterfs defaults,_netdev 0 0  node1:rep-volume        /test/rep               glusterfs defaults,_netdev 0 0  node1:dis-rep           /test/dis_rep   glusterfs defaults,_netdev 0 0  node1:dis-stripe        /test/dis_stripe        glusterfs defaults,_netdev 0 0

        四、測試

        • 生成測試文件(該文件雖沒有數據,但是可以進行測試用途)

          [root@client ~]# for i in {1..5};do dd if=/dev/zero of=/root/demon$i.log bs=1M count=43;done [root@client ~]# cp demon* /test/dis && cp demon* /test/dis_rep/ && cp demon* /test/dis_stripe/ && cp demon* /test/rep/ && cp demon* /test/stripe/

        • 查看文件分布狀態
        • 分布式卷(node1和node2的/sde6目錄查看,可以看到文件被分散開存放)
        [root@node1 ~]# ll -h /sde6/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   3 2019 lost+found  [root@node2 ~]# ll -h /sde6/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found
        • 條帶卷(node1和node2的/sdd5目錄查看,清晰看到是以數據塊為單位存儲的)
        [root@node1 ~]# ls -lh /sdd5/  總用量 108M  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon1.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon2.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon3.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon4.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon5.log  [root@node2 ~]# ls -lh /sdd5/  總用量 108M  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon1.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon3.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon4.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon5.log
        • 復制卷(node3和node4的/sdd5目錄,數據有備份)
        [root@node3 ~]# ls -lh /sdd5/  總用量 216M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon4.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon5.log  drwx------. 2 root root 16K 4月   3 03:03 lost+found  [root@node4 ~]# ls -lh /sdd5/  總用量 216M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon4.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon5.log  drwx------. 2 root root 16K 4月   3 02:55 lost+found
        • 分布式條帶卷(節點1、2、3、4的/sdb3目錄,我日期沒有調整,海涵)
        [root@node1 ~]# ls -lh /sdb3/  總用量 65M  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   2 18:37 lost+found  [root@node2 ~]# ls -lh /sdb3/  總用量 65M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon3.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon4.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node3 ~]# ls -lh /sdb3/  總用量 44M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:03 lost+found  [root@node4 ~]# ls -lh /sdb3/  總用量 44M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 02:55 lost+found
        • 分布式復制卷(節點1、2、3、4的/sdc4目錄,可看到文件沒有被分片,但是是分布開來存放的)
        [root@node1 ~]# ls -lh /sdc4/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   3 2019 lost+found  [root@node2 ~]# ls -lh /sdc4/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon4.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node3 ~]# ls -lh /sdc4/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node4 ~]# ls -lh /sdc4/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found
        破壞測試
        • 直接點關閉node2節點。關機操作。
        • 客戶端操作
        [root@client ~]# ls /test/dis/  demon1.log  demon3.log  demon4.log  lost+found  //可以看到另外兩個文件直接找不到了  [root@client ~]# ls /test/stripe/  [root@client ~]#   //條帶卷因為文件都是分散開放,所以都沒有了  [root@client ~]# ls /test/dis_stripe/  demon2.log  demon5.log  lost+found  //分布式條帶卷,因為是分布式存儲node2宕機導致數據不完整不會顯示,1,3,4號文件丟失  [root@client ~]# ls /test/dis_rep/  demon1.log  demon2.log  demon3.log  demon4.log  demon5.log  lost+found  //分布式復制卷完全不受任何影響  //總而言之,了解各卷的特點,再細心觀察以下文件分布的具體位置,才能盡可能保證數據可靠性

        五、維護命令

        [root@node3 ~]# gluster volume list  dis-rep  dis-stripe  dis-volume  rep-volume  stripe-volume  //任何一個節點都可以查看集群列表  [root@node1 ~]# gluster volume info   //查看所有卷的信息  [root@node1 ~]# gluster volume status         //查看卷的狀態  [root@node3 ~]# gluster volume stop dis-stripe  Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y  volume stop: dis-stripe: success  //停止卷  [root@node3 ~]# gluster volume start dis-stripe  //啟動卷  [root@node3 ~]# gluster volume delete dis-stripe  //刪除卷
        贊(0)
        分享到: 更多 (0)
        網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
        主站蜘蛛池模板: 亚洲国产婷婷综合在线精品| 亚洲国产美女精品久久久久∴| 久久免费99精品国产自在现线| 8AV国产精品爽爽ⅴa在线观看| 欧美午夜精品一区二区三区91| 在线欧美v日韩v国产精品v| 日韩精品久久无码人妻中文字幕| 久久成人国产精品一区二区| 精品国内片67194| 精品久久久久久亚洲精品| 四虎精品影库4HUTV四虎| 国产精品亚洲二区在线观看| 欧美精品国产精品| 国产精品福利网站导航| 国产精品免费大片| 久久丫精品国产亚洲av| 无码日韩精品一区二区三区免费| 四虎永久在线精品国产馆V视影院| 国产精品最新国产精品第十页| 亚洲精品线在线观看| 久草视频在线这里精品| 91精品国产色综合久久| 国产精品熟女高潮视频| 孩交VIDEOS精品乱子| 人妻精品久久久久中文字幕69 | 91精品国产福利尤物| 精品亚洲麻豆1区2区3区| 四虎成人精品无码| 亚洲精品tv久久久久久久久| 伊人精品视频在线| 亚洲日韩一页精品发布| 中文字幕一精品亚洲无线一区 | 国产精品亚洲综合一区| 国产精品高清在线观看| 99久久精品免费看国产免费| 真实国产乱子伦精品免费| 国产AV国片精品一区二区| 国产精品99| 国产精品午夜一级毛片密呀| 国语自产精品视频在线观看| 久久久精品国产Sm最大网站|