站長資訊網(wǎng)
        最全最豐富的資訊網(wǎng)站

        CentOS 7.5下部署GlusterFS分布式存儲集群環(huán)境

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

        一、環(huán)境部署

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

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

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

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

        如果取消關(guān)注Linux公社公眾號,即使再次關(guān)注,也將無法提供本服務(wù)!

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

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

        • 測試用的磁盤分配以及服務(wù)器架構(gòu)圖
          CentOS 7.5下部署GlusterFS分布式存儲集群環(huán)境

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

        卷名稱 卷類型 空間大小/GB  存儲塊
        dis-volume 分布式卷 12 node1(/sde6),node2(/sde6)
        stripe-volume 條帶卷 10 node1(/sdd5),node2(/sdd5)
        rep-volume 復(fù)制卷 5 node3(/sdd5),node4(/sdd5)
        dis-stripe 分布式條帶卷 12 node1(/sdb3),node2(/sdb3),node3(/sdb3),node4(/sdb3)
        dis-rep 分布式復(fù)制卷 8 node1(/sdc4),node2(/sdc4),node3(sdc4),node4(sdc4)
        • 全部主機修改主機名
        • 全部主機配置hosts文件,一樣的
        • 全部node主機創(chuàng)建掛載文件夾,依實際掛載點創(chuàng)建
        • 全部主機創(chuàng)建/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主機執(zhí)行以下腳本
        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   #//不重啟系統(tǒng)識別分區(qū)  mkfs.ext4 ${i}1   #//格式化分區(qū)  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 //執(zhí)行腳本 netstat -lnpt //查看gluster服務(wù)端口是否開啟
        腳本簡單理解

        • 再node1上執(zhí)行如下命令構(gòu)建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 //在每個節(jié)點上執(zhí)行查看集群狀態(tài);正常時為(Connected)

        二、創(chuàng)建卷

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

        [root@node1 ~]# gluster volume create dis-volume node1:/sde6 node2:/sde6 force //dis-volume為卷名稱,未指定創(chuàng)建卷類型,默認為分布式卷 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 //查看該卷的相關(guān)信息

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

        [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表示卷類型條帶卷,后面的數(shù)量表示條帶數(shù)

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

        [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.創(chuàng)建分布式條帶卷(加大容量,讀取快,沒有容錯性)

        [root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/sdb3 node2:/sdb3 node3:/sdb3 node4:/sdb3 force //指定類型為Distributed-Stripe,數(shù)值為2,而且后面跟了4個Brick Server,是2的2倍,所以創(chuàng)建的是分布式條帶卷。 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.創(chuàng)建分布式復(fù)制卷(擴展空間,總空間的一半,且具有容錯能力)

        [root@node1 ~]# gluster volume create dis-rep replica 2 node1:/sdc4 node2:/sdc4 node3:/sdc4 node4:/sdc4/ force //指定類型為Distributed-Replicate,數(shù)值為2,而且后面跟了4個Brick Server,是2的2倍,所以創(chuàng)建的是分布式復(fù)制卷。 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 //可以看到服務(wù)已經(jīng)啟動
        [root@client ~]# mkdir -pv /test/{dis,stripe,rep,dis_stripe,dis_rep} //創(chuàng)建掛載目錄 [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文件系統(tǒng)到本地客戶端,所制定的node1節(jié)點只是為了獲取配置信息,不代表只和他進行數(shù)據(jù)傳輸,會根據(jù)配置針對集群來進行數(shù)據(jù)的存放

        • 修改fstab文件實現(xiàn)永久掛載
        • 添加如下文件

          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

        四、測試

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

          [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/

        • 查看文件分布狀態(tài)
        • 分布式卷(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目錄查看,清晰看到是以數(shù)據(jù)塊為單位存儲的)
        [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
        • 復(fù)制卷(node3和node4的/sdd5目錄,數(shù)據(jù)有備份)
        [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
        • 分布式條帶卷(節(jié)點1、2、3、4的/sdb3目錄,我日期沒有調(diào)整,海涵)
        [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
        • 分布式復(fù)制卷(節(jié)點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
        破壞測試
        • 直接點關(guān)閉node2節(jié)點。關(guān)機操作。
        • 客戶端操作
        [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宕機導(dǎo)致數(shù)據(jù)不完整不會顯示,1,3,4號文件丟失  [root@client ~]# ls /test/dis_rep/  demon1.log  demon2.log  demon3.log  demon4.log  demon5.log  lost+found  //分布式復(fù)制卷完全不受任何影響  //總而言之,了解各卷的特點,再細心觀察以下文件分布的具體位置,才能盡可能保證數(shù)據(jù)可靠性

        五、維護命令

        [root@node3 ~]# gluster volume list  dis-rep  dis-stripe  dis-volume  rep-volume  stripe-volume  //任何一個節(jié)點都可以查看集群列表  [root@node1 ~]# gluster volume info   //查看所有卷的信息  [root@node1 ~]# gluster volume status         //查看卷的狀態(tài)  [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)
        網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號
        主站蜘蛛池模板: 久久久久久国产精品无码下载| 亚洲国产综合精品中文字幕| 亚洲精品99久久久久中文字幕| 精品久久久久一区二区三区| 国产成人无码精品久久久免费 | 国产欧美日韩精品a在线观看| 久久精品国产亚洲AV不卡| 精品国产福利尤物免费| 98精品国产自产在线XXXX| 成人亚洲日韩精品免费视频| 91精品啪在线观看国产| 欧美黑人巨大精品| 久久精品综合一区二区三区| 久久久无码人妻精品无码| 国产亚洲美女精品久久久| 97久久精品无码一区二区| 国产伦精品一区二区三区| 99热日韩这里只有精品| 日韩精品专区在线影院重磅| 91麻豆精品国产自产在线观看一区 | 国内精品伊人久久久久| 国产成人高清精品免费观看| 亚洲国产精品尤物yw在线| 国产精品久久久久久久久鸭 | 久久久精品午夜免费不卡| 欧美久久亚洲精品| 3级黄性日本午夜精品| 精品人妻va出轨中文字幕| 精品人妻伦一二三区久久| 久热这里只精品99re8久| 亚洲精品蜜桃久久久久久| 国产精品青草视频免费播放 | 在线观看亚洲精品福利片| 欧美一区二区精品| 日韩精品久久久肉伦网站 | 思思99热在线观看精品| 精品国产乱码久久久久久浪潮| 亚洲AV午夜福利精品一区二区| 国产精品成人免费观看| 99精品国产丝袜在线拍国语| 午夜国产精品无套|